Streaming Sensor Data from a ppDAQC Pi Plate Using InitialState




The Pi-PlatesppDAQC Data Acquisition and Control board is an ideal interface between sensors and a Raspberry Pi. With eight analog and eight digital inputs, up to sixteen channels of real world data can be captured by a single ppDAQC Pi-Plate. But, what can you do with that data? You can use it to control a process by turning around and driving the Digital and Analog outputs on the board. But chances are you will also want the ability to monitor it. Furthermore, the beauty of small, inexpensive single board computers (SBC) like the Raspberry Pi, is that they can be used in remote locations without a keyboard or a monitor. All they need is a source of power, and a WiFi adapter. Using a SBC in this way is referred to as a “headless” setup.

So that’s our plan: use a headless Raspberry Pi collecting sensor data in a remote location. Our options for viewing the data include:

  1. Watching individual readings scroll down our screen (boring)
  2. Saving data to a local file and then viewing the data later using a spreadsheet application or the matplotlib – sounds a lot like work
  3. Use InitialState to stream our data to the cloud and then look at beautiful plots of it in real time. This is how all the cool kids are doing it these days.

In this article we’re going to use option 3 to monitor two DS18B20 sensors measuring the ambient temperature in a storage closet as well as the temperature in a refrigerator used for keeping solder paste chilled.Streaming Sensor Data from a ppDAQC Pi Plate Using InitialState

Step 1: Stuff You Need

InitialState Access and Python Library

To begin, head to www.InitialState.com and apply for an account. While you’re waiting for approval, install their python module on your Raspberry Pi. We prefer to use pip since it makes life so easy. Go here to learn more about pip: https://pypi.python.org/pypi/pip. From the command prompt, type:

sudo pip install ISStreamer

Once you have access to the InitialState service, you’re ready to start.

Hardware

To collect the temperature data we will use the following:

  1. A Raspberry Pi which has been preloaded with the ppDAQC Python module. Go here if you need to perform this step.
  2. A ppDAQC board from Pi-Plates.com
  3. Two DS18B20 temperature sensors. We got ours here at Amazon.
  4. Two 4.7K ohm resistors. Available from Radio Shack, Digikey, and Mouser to name a few.
  5. Hookup wire
  6. A proto-board for quick and dirty or a ppPROTO for a semi permanent setup.

Step 2: Build It

Hardware

Using the materials called out in the previous step, perform the connections as shown in the drawing. Note: we were out of luck when we went looking for the 4.7K resistors so we ended up putting two 10K resistors in parallel.

Software

First you will need to create a new logging Client Key from your Initial State account. After you’ve done this, use your favorite text editor on your Raspberry Pi (this is Nano for most people) and type in the following program:

Save the above in your home directory as tempLOG.py, launch your program from the command prompt with the command sudo python tempLOG.py, and verify that no errors occur.

What’s happening in this code? Well first, we import three modules that we will need: time, piplates.ppDAQC and ISStreamer.Streamer. Then we create a stream to the InitialState data logger with:

After that, we go into an infinite loop and use ppDAQC.getTEMP to read the two DS18B20 temp sensors. After each read, we “log” the data along with a label to our log file at InitialState. We sleep for 300 seconds (5 minutes) and then we take another measurement.Streaming Sensor Data from a ppDAQC Pi Plate Using InitialState schematic

Step 3: Examining the Log Data – Step 1

You can start looking at your data right away but there won’t be much to see until a few hours have passed. Once you’re ready, log into your Initial State account. After you’ve completed that step you’ll be taken to your own page (see image) where you can access and view your log data.

You should have a log file called “Lab Temperature Data”. Click that and then click the button that says “Source.” You will then be presented with some pretty boring lines of raw data from your Raspberry Pi that looks like:

DateTime,SignalSource,OriginalPayload

2014-12-18T15:50:57.837852Z,”Lab Temperature Data”,”Stream Starting”

2014-12-18T15:50:58.841351Z,Cooler,37.6

2014-12-18T15:50:59.844371Z,Ambient,69.55

2014-12-18T15:56:00.947597Z,Cooler,36.5875

2014-12-18T15:56:01.950743Z,Ambient,68.7625

2014-12-18T16:01:03.052842Z,Cooler,36.5875

2014-12-18T16:01:04.056015Z,Ambient,68.65

 

For more detail: Streaming Sensor Data from a ppDAQC Pi-Plate Using InitialState


© 2015 Powered By Engineering Projects Team, Raspberry Pi Projects

Scroll to top