Pages: [1]   Go Down
Author Topic: append a float 2 a string?  (Read 3769 times)
0 Members and 1 Guest are viewing this topic.
San Pedro, CA.
Offline Offline
Full Member
***
Karma: 3
Posts: 155
My head HURTS!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 dec.pt. or a negative sign.

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

Thanks,
DJ
Logged

DigitalJohnson

Knivsta,Sweden
Offline Offline
Sr. Member
****
Karma: 0
Posts: 274
Low level's cool
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

This thread migt be worth reading: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1200716061
« Last Edit: June 26, 2010, 06:55:10 am by drhex » Logged

San Pedro, CA.
Offline Offline
Full Member
***
Karma: 3
Posts: 155
My head HURTS!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

stringX.append(sensors.getTempF(deviceAddress));

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  
Logged

DigitalJohnson

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26248
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I didn't put much time into it
But you hope others will?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

San Pedro, CA.
Offline Offline
Full Member
***
Karma: 3
Posts: 155
My head HURTS!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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. smiley-wink

Always thankful for replies,
DJ
Logged

DigitalJohnson

San Pedro, CA.
Offline Offline
Full Member
***
Karma: 3
Posts: 155
My head HURTS!!!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

>> drhex <<

Thanks for the thread tip!  smiley 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!  smiley smiley smiley
DJ
Logged

DigitalJohnson

Pages: [1]   Go Up
Jump to: