0

Adafruit IO - parsing?
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.

Adafruit IO - parsing?

by campu0999 on Tue Apr 19, 2016 4:07 am

I have the adafruit flora accelerometer and was wondering if the data feed to my adafruit io could be parsed or modified so I can display the X, Y, Z values?

campu0999
 
Posts: 16
Joined: Sun Apr 03, 2016 7:11 pm

Re: Adafruit IO - parsing?

by adafruit_support_mike on Wed Apr 20, 2016 6:47 pm

[moved to the ADAFRUIT.IO forum]

adafruit_support_mike
 
Posts: 61876
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit IO - parsing?

by jwcooper on Thu Apr 21, 2016 11:08 am

You could send the data as a group of 3 feeds. Or you can just send them each 3 times as individual feeds of x,y,z. Groups will be more efficient, but a bit more complicated to code.

jwcooper
 
Posts: 756
Joined: Tue May 01, 2012 9:08 pm

Re: Adafruit IO - parsing?

by campu0999 on Sat Apr 23, 2016 8:37 am

Okay so the data gets sent from the flora through Bluetooth then sent to adafruit.io in a single feed ( it gets xyz of both the gyro and accelerometer.)
Last edited by campu0999 on Wed Apr 27, 2016 4:55 am, edited 1 time in total.

campu0999
 
Posts: 16
Joined: Sun Apr 03, 2016 7:11 pm

Re: Adafruit IO - parsing?

by campu0999 on Wed Apr 27, 2016 4:55 am

How am I able to do this on a adafruit flora please?

campu0999
 
Posts: 16
Joined: Sun Apr 03, 2016 7:11 pm

Re: Adafruit IO - parsing?

by hepaestus on Sat May 07, 2016 9:45 am

jwcooper wrote:You could send the data as a group of 3 feeds. Or you can just send them each 3 times as individual feeds of x,y,z. Groups will be more efficient, but a bit more complicated to code.


What is the syntax for this? What would the URL and the JSON data look like?
Thanks,
P.

hepaestus
 
Posts: 40
Joined: Sat May 07, 2016 6:54 am

Re: Adafruit IO - parsing?

by jwcooper on Mon May 09, 2016 12:09 pm

You can send it as a POST payload, or in the url as a GET request using the helper method 'send'.

Something like this should work:
https://io.adafruit.com/api/groups/grou ... &y=25&z=24

You can also send it like as a POST (this is prefered, as it doesn't put your x-aio-key in the url, which isn't great for security):
https://io.adafruit.com/api/groups/group_name/send

Body:
Code: Select all | TOGGLE FULL SIZE
{
  "feeds": {
    "humidity": 45,
    "temperature": 80
  },
  "location": {
    "lat": 45.539999999999999,
    "lon": -93.343500000000006
  }
}


Full request headers and body:

Code: Select all | TOGGLE FULL SIZE
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: application/json
x-aio-key: secret key
Accept-Language: en-us

{
  "feeds": {
    "humidity": 45,
    "temperature": 80
  },
  "location": {
    "lat": 45.539999999999999,
    "lon": -93.343500000000006
  }
}

jwcooper
 
Posts: 756
Joined: Tue May 01, 2012 9:08 pm

Re: Adafruit IO - parsing?

by hepaestus on Mon May 09, 2016 1:39 pm

Here is what I am trying to send and the response I am getting:
Code: Select all | TOGGLE FULL SIZE
PUT /hepaestus/feeds/temperature_f.json HTTP/1.1
Accept: */*
Accept-Encoding: gzip,deflate
Content-Type: application/json
x-aio-key: SECRET_KEY
Accept Language: en-us

{"feeds":{ "humidity": 37.80,"temperature_f": 71.06},"location": { "lat": 42.306640, "lon": -72.644436}}
HTTP/1.0 400 Bad request
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>

Here is a Gist of the code: https://gist.github.com/hepaestus/de3cd ... 2cf36484f1
Is the URL Correct?
Is the format OK?
Thanks,
Pete.

hepaestus
 
Posts: 40
Joined: Sat May 07, 2016 6:54 am

Please be positive and constructive with your questions and comments.