Pages: [1]   Go Down
Author Topic: Arduino due and dtostrf function problem  (Read 2048 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
I have a problem with the function 'dtostrf'

the sketch is very easy :

#include<stdlib.h>
void setup()
{
  char temp[8];
  dtostrf(0.012, 8 ,2 ,temp);
}

the arduino IDE is the 1.5.1r2 and I use an Arduino due.
With older IDE version and other Arduino (nano, Uno), I use this function with no problem.

The error message in the IDE is : error: 'dtostrf' was not declared in this scope
but I have include stdlib.h

Where is the problem ?
Have you another way to convert a float to string with a specific digit (not for serial.print) ?

thanks in advance for your answer.
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I had a similar problem with itoa() not being found. The sprintf() function worked better for my application.

There is a library search and path problem when compiling for the Due.
Logged

Portugal
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the same problem too. The arduino IDE is the 1.5.1r2 with the Arduino due doesn't recognize the 'dtostrf' function .
Is there any solution for this?

Thanks 
Logged

St. Petersburg, FL
Offline Offline
Jr. Member
**
Karma: 1
Posts: 61
Retired physicist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might try to find the library containing the function and put it in the #include section. I've tried it with other functions using the complete path and it still doesn't see it. Even the math.h file is not found. There appears to be a serious path problem with this version of the IDE. Not sure what your function does but sprintf() may work in it's place. It worked nicely for my application.
Logged

Portugal
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The sprintf() function doesn´t work for my application. I will try to find the library and put it on the IDE.

Thanks anyway
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I added #include <dtostrf.h> to my code for Arduino DUE but no work. Then I search a solution from C/C++ text book that is about write your function and including.I was found the core folder and seem missing dtostrf.h. So i trial re-add the file and compiled...........OK  smiley-razz.

That have been solved by adding header file   #include <avr/dtostrf.h> to WString.h file.
Path: \\arduino-1.5.6-r2\hardware\arduino\sam\cores\arduino
Logged

Pages: [1]   Go Up
Jump to: