This module is a firmware for Nebula 2.0 In order to run this you will need to
- Install Wiced Studio by Cypress
- Clone this repository using
git clone https://github.com/scriptrdotio/nebula20-bluemix.io.git
- Copy cloned project into your workspace
- Configure your wifi connection under apps/nebula/bluemix/wifi_config_dct.h by setting CLIENT_AP_SSID and CLIENT_AP_PASSPHRASE
- Generate a new build target by clicking on "new" under "Make Target" and naming it "nebula.scriptr-NEB1DX_02 download download_apps run"
- Run the build
Note: In order to run this demo you will need to enable MQTT Bridges in scriptr.io, available as a free trial from inside the IDE.
The code is built using the following . click board BME 280 from click board samples (drivers and wrappers) . mqtt code from secure_mqtt, sample code provided by default under apps/snip
- mqtt.c and mqtt.h, code for connecting over mqtt to the scriptr.io mqtt broker
- wifi_config_dct.h for wifi configuration (SSID and PASSPHRASE)
- bluemix.c, code for connecting to bme280 sensor, button events, connectivity to bluemix
- bluemix.h, config file for bluemix connectivity (mqtt endpoint, topic,...)
- If you don't have a scriptr.io account, you will need to register for a free one
- Create a default script, name it "echo" with content
return request
This script will simply return (and log) the request as it received it - Create a channel named "nebula-demo"
- Create a device named "nebula20"
- Go External Endpoints (Under account / Settings) and enable bridges feature. Note, this configuration can be done before setting up the board. Continue with part 2 once the firmware is install and the board is booted
- set CLIENT_AP_SSID to your wifi network name
- set CLIENT_AP_PASSPHRASE to your wifi password
For a more complete demo, please refer to our corresponding blog post
Once the firmware is installed, the main method (application_start) will be started. The system will
- initialize the network
- initialize mqtt for tls
- connect to bluemix mqtt endpoint, using quickstart mode
- initialize BME sensor module (and do one initial forced reading, as per sample code provided by FE)
- register an event handler for button clicks
- read dct for previous device configuration, generate new device id on first run.
- button 1 click will publish the sensor data to bluemix using the generated device id
Note, sensor readings are formatted as JSON
{"parameters": {"p": 94465.42,"h_unit": "%","p_unit": "Pa","t": 28.41,"h": 52.71,"t_unit": "°C"}}
For more details about bridges module in scriptr.io please refer to the documentation
Once the board is started, it will print out the needed information about the quickstart account, by providing the generated device id. In order to process the data pushed to bluemix in scriptr.io, you will need to start a new mqtt bridge, link it to channel "nebula-demo" and subscribe it to your "echo" script. Configuration of the bridge will be printed out on the terminal in the following format:
Protocol: MQTTS
URL: quickstart.messaging.internetofthings.ibmcloud.com
Port: 8883
Topic: iot-2/type/scriptr-demo/id/0rzkzdj/evt/scriptr-demo/fmt/json
ClientId: a:quickstart:scriptr-demo