Sending Multiple Values to Initial State using JSON
Sending Multiple Values to Initial State using JSON
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
- Create account at https://initialstate.com
- Create stream bucket at https://initialstate.com
- Create an integration -> webhook on Particle console
- Write firmware sketch and flash Argon
Configure Initial State to Receive JSON
Initial State Settings
Configure Particle Cloud to Pass JSON
Particle integration settings
Configure Particle Cloud to Pass JSON
Particle integration settings
JSON Data: {{{PARTICLE_EVENT_VALUE}}}
URL: https://groker.init.st/api/events
Configure Particle Cloud to Pass JSON
Particle integration settings
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
- To create JSON data, you can use
String
variables to manually build the JSON data, or you can use a library. - Generating this value as a
String
can be tedious so a library is recommendedis going to be messy - Instruction and examples for creating JSON manually with
String
variables` - Instruction and examples for creating JSON with
JsonParserGeneratorRK
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
- Google Cloud IoT (many IoT services)
- Microsoft Azure IoT (many IoT services)
- Amazon Web Services (many IoT services)
- Losant (many IoT services)
- Ubidots
- Tinamous
- Initial State
Credits
- Growthlakes CC BY-SA
- Image created with Fritzing