April 3, 2012
I found a post on the Arduino forum:
#include<stdlib.h> dtostrf(FLOAT,WIDTH, PRECISION,BUFFER);
(At the bottom of the post, that may help...)
If this works, please let us know and I will add it the Arduino tutorials.
June 16, 2013
Here's how I have done it:
char buffer2; //make buffer large enough for 7 digits
String tempStr = dtostrf(allSensors[i].averageTemp, 7,2,buffer2);
//'7' digits including '-' negative, decimal and white space. '2' decimal places
tempStr.trim(); //trim whitespace, important so ThingSpeak will treat it as a number
The std lib.h is included by default.
January 25, 2014
June 16, 2013
Thanks, gadjet, thats very cool. That led me to read all the String object methods:
October 10, 2015
I used this: -
This takes the float value from my DS18B20 temp sensor.
If anyone is around I used a slightly different take to get decimal values to two decimal places.
I needed 3 values passed to thingspeak. Most of the code below is just debug stuff but I left it in.
The lines that do the work are the FLOAT.
Yes I borrowed the code from another thingspeak member and just tweaked it a little as it seemed slightly more modular and easier to add sensor routines see http://community.thingspeak.com/forum/arduino/ds18b20-temp-sensor/ Raklinks post
float WT = sensors.getTempC(WaterTemp); // was int
float OT = sensors.getTempC(OutsideTemp); // was int
Serial.print("Room Temp is: ");
// read value of 5V solar panel 0 to 500
float LT = (analogRead(A0)); // was int
//String AP = String(analogRead(A0), DEC);
Serial.print(LT/100); // divide by 100 to get voltage produced
// Update ThingSpeak
if(!client.connected() && (millis() - lastConnectionTime > updateThingSpeakInterval))
updateThingSpeak("field1="+String(WT, DEC) +"&field2="+String(OT, DEC)+"&field3="+String(LT, DEC));
January 10, 2019
Decimals have much higher precision and are usually used within financial applications that require a high degree of accuracy. Decimals are much slower (up to 20X times in some tests) than a double/float. Decimals and Floats/Doubles cannot be compared without a cast whereas Floats and Doubles can. Decimals also allow the encoding or trailing zeros.
February 18, 2019
I am sending voltage readings to thingspeak as float values, but I'm only seeing two decimals at this end. As my values are in the range of 0,001 -0,5 V, I am loosing everything below 0,01V. As far as I understand, the float values from the arduino should not be truncated, so do i need to change anything in thingspeak?
March 7, 2017
Are you seeing truncated values on plots or on data that you have exported? You can use a rest call or the data export button or tab to view your data. ThingSpeak does not truncate data you send but data on plots might be rounded. There is a setting in the plot settings for rounding.
If you try this in your browser, you should get the raw data back for the last data point in a private channel (be sure to change to your Read API key:
Does the last point have the number of decimals you need?
Most Users Ever Online: 166
Currently Browsing this Page:
Guest Posters: 1
Newest Members:faaramin, swarnak32, SaiHarish.M, vikas, abhisheksharma, khoshghadam
Moderators: cstapels: 460
Administrators: Hans: 405, lee: 457