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.
Hardware
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
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.
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