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.
Locked
User avatar
huguescmoi
 
Posts: 13
Joined: Sat Jan 23, 2016 12:29 pm

How to post a float value to a feed ?

Post by huguescmoi »

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" ?

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

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

Post by clemens »


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

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

Post by huguescmoi »

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 ?

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

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

Post by clemens »

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

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

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

Post by huguescmoi »

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...

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

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

Post by clemens »

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.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”