dtosrtf() header file?

I have a sketch that was built, compiled, and running in a previous version of the Arduino IDE.

It included only four header files LiquidCrystal_I2C.h, Wire.h, OneWire.h, DallasTemperature.h; but also used the dtostrf() function.

I have a new computer and installed the current IDE v1.6.9 and the sketch will no longer compile. I receive an error about dtostrf() not being declared. Which header file needs to be included with IDE v1.6.9 to allow the sketch to compile?

Sigh ......

Please post your full code or a smaller but complete program that illustrates the problem.

Sigh...

Not sure what you expect to see beyond the original concise and direct problem description and question but you get what you ask for.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
dtostrf(pump_min, 4, 1, pump_minutes);

error: 'dtostrf' was not declared in this scope

Four included libraries, one line of code with an error, and an error message as previously described. I hope this clarifies the problem for you, it doesn't help me at all.

UKHeliBob:
Sigh ......

Please post your full code or a smaller but complete program that illustrates the problem.

#include<stdlib.h>

googled it

"stdlib.h" should, by rights, be automatically included from "Arduino.h"

Not sure what you expect to see beyond the original concise and direct problem description and question but you get what you ask for.

Actually I didn't

OldSteve:
"stdlib.h" should, by rights, be automatically included from "Arduino.h"

That would be the sensible thing to do...
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L23

void setup() 
{
  char buffer[31];
  dtostrf( PI, 10, 10, buffer );
}

void loop() { }
Sketch uses 2,028 bytes (6%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.

adwsystems:
error: 'dtostrf' was not declared in this scope

I suggest comparing your sketch to mine. Your bug is in the difference between the two.

OldSteve:
"stdlib.h" should, by rights, be automatically included from "Arduino.h"

[quote author=Coding Badly date=1467532506 link=msg=2825097]
That would be the sensible thing to do...
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L23[/quote]
I worded it badly. I knew that it was included from "Arduino.h". (I looked. :slight_smile: )

Coding Badly is 100% correct. that code compiles without any error

void setup() 
{
  char buffer[31];
  Serial.begin(115200);
  dtostrf( PI, 10, 10, buffer );
  Serial.println(buffer);
}

void loop() { }

and leads to 3.1415927000 being printed to the console.

no warning, no error... so something else is happening in your code. You might have a syntax error above that statement which gets the parser confused

I did not see a copy of the error message, only a transcript.

If you look at the tilte of the thread, the error could be the same typo in the code.

And to answer the titel question: there is no header file for a function named dtosrtf() I know of.

Whandall:
I did not see a copy of the error message, only a transcript.

If you look at the tilte of the thread, the error could be the same typo in the code.

And to answer the titel question: there is no header file for a function named dtosrtf() I know of.

Good point. The title has a typo, but it isn't the only one in this thread. LOL (titel SP?)

What else of the error message is relevant? There is only one instance of the function dtostrf in the program and I copied the line the error message pointed to.

I tried including various combination of stdlib.h, stdio.h, and Arduino.h (although I have never had to include Arduino.h before). I only see one item to try, from Coding Badly. I get the same error; although J-M-L appears to be able to make it work.

Here is the full error buffer if it helps anyone.

C:\Users\anthony\Documents\Arduino\sketch_jul03a\sketch_jul03a.ino: In function 'void setup()':

sketch_jul03a:5: error: 'dtostrf' was not declared in this scope

   dtostrf( PI, 10, 10, buffer );

                              ^

exit status 1
'dtostrf' was not declared in this scope

Here is the full error buffer if it helps anyone.

But not the code that generated it, so no, no-one is helped.

adwsystems:
I only see one item to try, from Coding Badly. I get the same error; although J-M-L appears to be able to make it work.

Here is the full error buffer if it helps anyone.

C:\Users\anthony\Documents\Arduino\sketch_jul03a\sketch_jul03a.ino: In function 'void setup()':

sketch_jul03a:5: error: 'dtostrf' was not declared in this scope

dtostrf( PI, 10, 10, buffer );

^

exit status 1
'dtostrf' was not declared in this scope

AWOL:
But not the code that generated it, so no, no-one is helped.

I'm sorry that wasn't clear enough the error was the result of trying to compile the program example from Coding Badly, (above)

Here is the code:

void setup() 
{
  char buffer[31];
  Serial.begin(115200);
  dtostrf( PI, 10, 10, buffer );
  Serial.println(buffer);
}

void loop() { }

Are you trying to be funny?
It's not working.

AWOL:
Are you trying to be funny?
It's not working.

Not at all, quite serious in fact. I'm very frustrated. Something changed between the two versions of the IDE and broke my code.

I hit the POST button instead of the PREVIEW button before I could add the code. I think your response was in the five minute delay that I am subject to. (I look forward to hitting the 100 post mark and getting back to normal).

Any thoughts?

Which board do you selected?

Something changed between the two versions of the IDE and broke my code.

Any thoughts?

Coding Badly and J-M-L's codes compile for me with ide v 1.6.9. Are you using the ide from arduino.cc (not arduino.org which is at 1.7.x)

If using the ide from arduino.cc then version of the ide you are using is possibly corrupted, and your best option is to download it again.

I have selected the Arduino/Genuino Uno Board, which is what I have.

I have downloaded the compiler from arudino.cc (the download button above) and the version is 1.6.9. I don't know whom arduino.org is.