Project - Sending data to

Sending data to

This is a demo data feed from a 4.2 Spider to

It simply sends a random number between 0 and 100 every 20 seconds over Wifi, using JSON format.

The RS21 Wifi code and NTP server calling code is from a post by Duke Nukem

The JSON classes are from Huysentruit Wouter -

The DataFeed class encapsulates most of the mechanics of posting to

In the main program, you’ll need to provide your own API key, and the numeric ID of your own feed.

The main program kicks off when a button click occurs, connects to the WiFi network, gets the current time, and starts the timer, which every 20 seconds posts the random value.

Exception handling is left as an exercise for the reader :slight_smile:


Given my device has a number of feeds I’m trying to send it this:

{\"feed_id\": \"34154\", \"value\": \"36.939999999999998\"},
{\"feed_id\": \"34157\", \"value\": \"890.07228744749955\"},
{\"feed_id\": \"34153\", \"value\": \"500\"},
{\"feed_id\": \"34156\", \"value\": \"2.6432234432234432\"},
{\"feed_id\": \"34152\", \"value\": \"22.174986821669155\"},
{\"feed_id\": \"34155\", \"value\": \"6.6910866910866913\"},
{\"feed_id\": \"34151\", \"value\": \"22.879999999999999\"}

and I’m getting back a

"<html><head><title>500 Internal Server Error</title></head><body><h1>Internal Server Error</h1>The server encountered an error while processing this request:<br><pre>{error,{badmatch,{comma,{decoder,null,52,1,53,trim}}},\n       [{mochijson2,json_decode,2,[{file,\"src/mochijson2.erl\"},{line,308}]},\n        {ee_web_event_resource,malformed_post_request,2,\n                               [{file,\"src/ee_web_event_resource.erl\"},\n                                {line,112}]},\n        {webmachine_resource,resource_call,3,\n                             [{file,\"src/webmachine_resource.erl\"},\n                              {line,169}]},\n        {webmachine_resource,do,3,\n                             [{file,\"src/webmachine_resource.erl\"},\n                              {line,128}]},\n        {webmachine_decision_core,resource_call,1,\n                                  [{file,\"src/webmachine_decision_core.erl\"},\n                                   {line,48}]},\n        {webmachine_decision_core,decision,1,\n                                  [{file,\"src/webmachine_decision_core.erl\"},\n                                   {line,183}]},\n        {webmachine_decision_core,handle_request,2,\n                                  [{file,\"src/webmachine_decision_core.erl\"},\n                                   {line,33}]},\n        {webmachine_mochiweb,loop,1,\n                             [{file,\"src/webmachine_mochiweb.erl\"},\n                              {line,87}]}]}</pre><P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></body></html>"

Any suggestions?

Use this to validate your JSON format json formatter