I am having a setup using a Nano to collect the UPS battery volt and then post it to the Thingspeak server via a Node MCU board.
The setup itself is working fine. The only hitch is that I am not able to post decimal values ... tried all possible things on the Thingspeak site using the edit form for Graphs. In fact there is no mention of any data type there...
Anyone try to post decimal values ? In my application i am getting the battery volt as an integer multiplied by 100 and finally before posting trying to convert it to volts. The Node MCU queries the Nano via serial and parses it and then posts. This is the code :
void parseDataAndPost()
{
char * strtokIndx; // This is used by strtok() as an index
strtokIndx = strtok(dataFromNano, ","); // Get the first part - Ch0 volt. The delimiter comma is replaced with a NULL
ch00Volt = atoi(strtokIndx); // Convert to integer
strtokIndx = strtok(NULL, ","); // Previous comma is now NULL .. get the data till the next comma
ch01Volt = atoi(strtokIndx);
strtokIndx = strtok(NULL, ">"); // Get the last part of data..Ch2 Volt
ch02Volt = atoi(strtokIndx);
ch00FVolt = float(ch00Volt/100); // Convert to Float
ch01FVolt = float(ch01Volt/100);
ch02FVolt = float(ch02Volt/100);
ThingSpeak.setField(1, ch00FVolt);
ThingSpeak.setField(2, ch01FVolt);
ThingSpeak.setField(3, ch02FVolt);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
}
But what I see posted on Thingspeak is a rounded value of the float. I expect to see something like 24.32 and I see only 24. So is there any way to get decimals to be posted ? ( Just to keep my query compact, I have not posted the whole code consisting of the Serial and WiFi routines )