Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

How to post a float value to a feed ?
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

How to post a float value to a feed ?

by huguescmoi on Wed Feb 03, 2016 2:17 pm

Hi,
Context : ESP8266 Arduino, posting sensor data to a feed.
Issue : I succeed to post int values to a feed (with command MyTestFeed.send(x), x being an integer); but as soon as I try to execute the same command with x being a float, it fails to write x to the feed.

Can we only post interger to Adafruit IO ? If not, what do I have to change to post a number (a float) like "21.35" ?

huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

Re: How to post a float value to a feed ?

by clemens on Wed Feb 03, 2016 3:12 pm


clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: How to post a float value to a feed ?

by huguescmoi on Wed Feb 03, 2016 3:31 pm



I do not see any solution in this other forum topic you are pointing to, only confirmation of the problem. Concretely what and where is the patch they are mentionning ?

huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

Re: How to post a float value to a feed ?

by clemens on Wed Feb 03, 2016 4:31 pm

viewtopic.php?f=56&t=87611&p=441930#p441189
I've found a workaround. Using dtostrf on it and posting the string works :).

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Re: How to post a float value to a feed ?

by huguescmoi on Thu Feb 04, 2016 5:36 am

Thx.
However this command converts a float into a string. Isn't that a problem for IO Adafruit to draw charts requiring number values and not strings ? It does not seem very logical...

huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

Re: How to post a float value to a feed ?

by clemens on Thu Feb 04, 2016 8:43 am

In my setup it is working well, and the string / char definition is on the Arduino side only. So the Adafruit IO gets only some json or whatever stuff and no information that the variable is a char!

Nevertheless yes, that's a bit funny but not so unique. It's necessary for some other payloads also, e.g. the RFM69 lib expects also char as payload.

clemens
 
Posts: 41
Joined: Fri Jan 06, 2012 12:21 am

Please be positive and constructive with your questions and comments.