append a float 2 a string?

I'm using a one-wire temp sensor with the one-wire library(v2.0) and everything works fine. I'm trying to show the temp on a serial 4-dig LED display (sparkfun). The problem is I need to seperate the decimal point from the float variable the 1-wire library gives me. I tried to use the string library's .append to make a string out of the float, but I get:

error: call of overloaded 'append(float)' is ambiguous.

I have to send 4 bytes (1 for each digit) to the display, as the actual values for each digit or ASCII char values for the numbers. My display will print a blank for the or a negative sign.

Any suggestions on how to convert a float to a char string?

Thanks, DJ

Can you show the code that caused the compile error? Do you want to display the decimal point?

This thread migt be worth reading:

I didn't save the code. I didn't put much time into it. I used the Dallas Temperature library and copied the single device example sketch and I used method 1 in the printTemperature() functionin of the example to scan for devices. Then I set up the led display's RX to the TX of serial1 on the arduino Mega. I used the standard serial port for debugging. The only changes I made to the example code were adding the string library, setup 'stringX' of length Y, and at the bottom of the printTemperature() function I added the following code:


Thats where the error occured. I also wrote a small function to do some string manipulation and got no errors there. I believe the problem is that I'm trying to append a float to a char string with the string lib. I was hoping someone here had an easy solution for what I'm trying to do.

Thanks for any help, DJ

I didn't put much time into it

But you hope others will?

But you hope others will?

No Sir, I apologize if it sounds that way. :-[ I love to learn. My question is a simple one (I think, I may be wrong. :-?). How can I get the string library to accept the float variable that the dallas library outputs? I'll keep reading until I find the answer. I thought the forum was a place for everyone to learn from each other. ;)

Always thankful for replies, DJ

drhex <<

Thanks for the thread tip! :slight_smile: That is exactly what I was trying to do. If anyone else out there is looking for a easier way to convert a floating point to a string, goto the thread posted by drhex above.

Much Thanks! :slight_smile: :slight_smile: :slight_smile: