Main Site Documentation

Project - Sending data to Open.Sen.se


#1

Sending data to Open.Sen.se

This is a demo data feed from a 4.2 Spider to Open.Sen.se.

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 http://www.ghielectronics.com/community/forum/topic?id=9411&page=3.

The JSON classes are from Huysentruit Wouter - http://www.ghielectronics.com/community/codeshare/entry/282

The DataFeed class encapsulates most of the mechanics of posting to Open.Sen.se.

In the main program, you’ll need to provide your own Open.Sen.se 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:


#2

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?


#3

Use this to validate your JSON format json formatter https://jsonformatter-online.com