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:
- Watching individual readings scroll down our screen (boring)
- Saving data to a local file and then viewing the data later using a spreadsheet application or the matplotlib – sounds a lot like work
- 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.
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.
To collect the temperature data we will use the following:
- A Raspberry Pi which has been preloaded with the ppDAQC Python module. Go here if you need to perform this step.
- A ppDAQC board from Pi-Plates.com
- Two DS18B20 temperature sensors. We got ours here at Amazon.
- Two 4.7K ohm resistors. Available from Radio Shack, Digikey, and Mouser to name a few.
- Hookup wire
- A proto-board for quick and dirty or a ppPROTO for a semi permanent setup.
Step 2: Build It
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.
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.
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:
2014-12-18T15:50:57.837852Z,”Lab Temperature Data”,”Stream Starting”
For more detail: Streaming Sensor Data from a ppDAQC Pi-Plate Using InitialState