Cloud Bluemix Demo

Demonstrates IBM Bluemix communication over the MQTT protocol

API Features Demonstrated

Platforms

This app works on:

Requirements and Prerequisites

This app requires ZentriOS 3.1+.

The application is written to transmit thermistor data. The Zentri AMW004-E03 and AWM106-E03 evaluation boards have a thermistor connected to a standard ADC and GPIO.

For other platforms you can substitute another data source, by modifying the periodic_publish function.

Resources

The manifest.json file is configured to download two lookup tables to the device:

Description

This demonstration does not require a user account or security certificates.

The application connects to the Bluemix Quickstart broker: quickstart.messaging.internetofthings.ibmcloud.com

After connection is established, the app periodically reads the thermistor and converts the value to temperature, using lookup tables. It also reads the signal strength of the Access Point. The result is then published to the quickstart topic. The period is by default 5 seconds.

You can view a graph of the transmitted values on the IBM Quickstart IoT site:

https://quickstart.internetofthings.ibmcloud.com

Usage Instructions

Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.

This app assumes your ZentriOS device is set up with the credentials to join your local network. If you have not already set up network credentials, on the ZentriOS terminal, run the commands:

network_up -s
save

See the Wi-Fi Command API documentation for network_up and save.

On starting up, the app displays messages similar to the following on the ZentriOS terminal:

> Network is down, restarting...
[Associating to Zentri_Guest]
> Security type from probe: WPA2-AES
Obtaining IPv4 address via DHCP
IPv4 address: 192.168.6.113
[Associated]
>
IBM Bluemix MQTT Demo Application Started
  - Broker: quickstart.messaging.internetofthings.ibmcloud.com
  - Client ID: d:quickstart:type:zentri_4422
  - Topic/Queue: iot-2/evt/zentri/fmt/json

Opening connection with broker quickstart.messaging.internetofthings.ibmcloud.com:1883
[Opening: quickstart.messaging.internetofthings.ibmcloud.com:1883]
> Resolving host: quickstart.messaging.internetofthings.ibmcloud.com
Connecting (TCP): 184.172.124.189:1883
[2016-03-29 | 06:14:35: Opened: 0]
> Connection established
Connecting...
Send CONNECT frame

If the connection is successful, the app displays messages similar to the following:

Received CONNACK
CONNECTED
Publishing to topic: 'iot-2/evt/zentri/fmt/json', message: '{"d":{"signal strength": -72, "temperature": 25.7693}}'
Send PUBLISH frame
MESSAGE PUBLISHED
Publishing to topic: 'iot-2/evt/zentri/fmt/json', message: '{"d":{"signal strength": -67, "temperature": 25.7436}}'
Send PUBLISH frame
MESSAGE PUBLISHED
Publishing to topic: 'iot-2/evt/zentri/fmt/json', message: '{"d":{"signal strength": -75, "temperature": 25.7693}}'
Send PUBLISH frame
...

To view the transmitted values on the IBM Quickstart IoT site, open the following URL in a browser:

https://quickstart.internetofthings.ibmcloud.com

In the Quickstart page Device ID box, enter the client ID type displayed in the ZentriOS terminal when the app starts up. For example if the app displays:

- Client ID: d:quickstart:type:zentri_4422

then enter zentri_4422 in the Device ID box

The device ID is unique to the device, in the form zentri_xxxx where xxxx represents the least significant 4 bytes of the device WLAN MAC address.

Implementation

common.h

Configuration values and constants

bluemix.c

Sets up global variables:

zn_app_init

mqtt_app_connect

mqtt_connection_event_cb

periodic_publish

mqtt_app_publish

Source

See: