Refrigeration Analyzer: Publishing Data

This topic outlines the initial steps for publishing newly acquired data with zymbit.connect. This topic is specifically in reference to the Raspberry Pi - Refrigeration Analyzer application. Please keep questions and comments related to publishing refrigeration data. Technical questions related to zymbit.connect should be posted in the connect section of the community.

Before data can be published the device first needs to be registered with Zymbit. Directions for registering a Raspberry Pi can be found at getting started with zymbit.connect. Once Zymbit is installed publishing data requires only three lines of python code:

from zymbit.client import Client 
client = Client()
client.send('data', {'key': 'analyzer.{}.{}'.format(device, address), 'value': value})

It is strongly recommended to format routing keys uniquely, yet in a way that makes them easy to identify. The Zymbit client will automatically identify the data stream by your uuid for security purposes. Subaddressing from here is left to the developer. In the above example I have amended the stream with the application, name of device that is being monitored, and the temperature probe’s unique device ID/address. The result will look something like:

data.<UUID>.analyzer.compressor.28000006151b77

Now lets bring data acquisition and publishing together!

The following script, fridge_pub.py, acquires and publishes data through zymbit.connect. Incoming data-points must differ from the previous in order to be published. This helps diminish overflow. If there is nothing published in 5 minutes then the entire payload is sent.

Remember, if you are using this code for yourself, be sure to populate self.address (line 16) with your own device IDs. You can determine the temperature probes’ device IDs by reading the data acquisition thread for this application.