Sending Multiple Values to Initial State using JSON

Sending Multiple Values to Initial State using JSON

bg opacity:.75

Review: Uses of Dashboards

  • View real-time sensor data

  • Compare data to historical trends
  • Monitor IoT devices for errors or network issues
  • Map devices GPS location
  • Remote control (execute functions) on devices
  • We will use Initial State (https://initialstate.com) but others are listed at the end

Goal: Use JSON to send Multiple Values to Initial State at Once

  • It is faster and uses less bandwidth to send multiple sensor in a single package
  • We will use JSON to package all the data and send to Initial State
  • The following examples are provided as a quick reference
  • More detailed steps are described in the lecture

Reminder: Steps to Connect Argon and Initial State

  1. Create account at https://initialstate.com
  2. Create stream bucket at https://initialstate.com
  3. Create an integration -> webhook on Particle console
  4. Write firmware sketch and flash Argon

Configure Initial State to Receive JSON

Initial State Settings

image-20200703180348874

Configure Particle Cloud to Pass JSON

Particle integration settings

image-20200703160032339

Configure Particle Cloud to Pass JSON

Particle integration settings

JSON Data: {{{PARTICLE_EVENT_VALUE}}}

URL: https://groker.init.st/api/events

image-20200703180944077

Configure Particle Cloud to Pass JSON

Particle integration settings

img

Configure Particle Cloud to Pass JSON

Particle integration setting: HTTP Headers

X-IS-AccessKey > «USE YOUR OWN API KEY»>

X-IS-BucketKey > «USE YOUR OWN BUCKET KEY»>

Sending Multiple Values

  • Sending one data point at a time is valid, but is tedious if there are many values to send
  • Instead, we can send a JSON array with many data points
  • JSON uses stores data in key / value pairs
  • JSON representation consists of objects and arrays

JSON Format

  • The example below contains one JSON object {...}
{"key": "temp", "value": 32}

Where temp is the your chosen data label, and 32 is the current value

  • The example below contains one JSON array [...] containing three JSON objects {...}
[
 {"key":"temperature", "value":79.000000},
 {"key":"humidity", "value":22.000000},
 {"key":"weather", "value": "sunny"}
]

Where temperature, humidity, and weather are the data labels, and 22.000000, 22.000000, and sunny are the corresponding values

Creating JSON

Lab - Send Photoresistor Value to Initial State

  • Connect photoresistor to Argon
  • Read photoresistor value and send to InitialState
  • Determine light threshold (dark, ambient, bright) and send this value to InitialState

Lab - Send Photoresistor Value to Initial State

Other Dashboard Platforms

Credits

Updated: