Plotly + Atlas Scientific: Graph Real-Time Dissolved Oxygen With Raspberry Pi
by plotlygraphs in Circuits > Sensors
33503 Views, 84 Favorites, 0 Comments
Plotly + Atlas Scientific: Graph Real-Time Dissolved Oxygen With Raspberry Pi
Atlas Scientific makes an amazing suite of scientific grade environmental monitoring sensors that have a perfect synergy with the Plotly data visualization platform.
This Instructable will show you how to hook up an Atlas Dissolved Oxygen sensor and a Raspberry Pi to Plotly's real-time graphing platform. You will view your data in real-time in your web-browser! Here is our final product: A graph of our dissolved oxygen sensor in our Montréal office: http://plot.ly/~streaming-demos/52/!
You can also use Atlas's pH, ORP, and EC sensors simply by swapping out the appropriate circuit and probe. Calibration functions will vary for each sensor. This will work with the Arduino Yun, Beaglebone Black, or any other embedded linux platform.
Hardware You Will Need
Parts:
- Raspberry Pi
- Raspberry Pi Budget Pack
- SD Card
- Micro USB Power Adapter
- Pi Cobbler
- Breadboard
- Wires
- Raspberry Pi Case
- Atlas Dissolved Oxygen Kit
- Dissolved Oxygen Circuit
- Dissolved Oxygen Sensor
- BNC Connector
- Ethernet Cord
Setup Raspberry Pi
- Load Raspbian onto your SD card. There are plenty of tutorials out there on this. Here's a good one: http://elinux.org/RPi_Easy_SD_Card_Setup
- Insert SD card into the Pi, plug in the micro USB power adapter, and connect the Ethernet cord to the Pi and your local router.
- SSH into your Raspberry Pi. (To quickly find the IP address assigned to the Pi, I like using the Fing app on my iPhone.)
- Setup the serial port and download appropriate libraries:
Open the /etc/inittab file:
vi /etc/inittab
Add a '#' at the beginning of the following line so that it looks like this:
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt10
Run the following commands in your Pi's terminal:
sudo apt-get install python-serial
sudo apt-get install git-core
sudo apt-get install python-pip
sudo pip install rpi.gpio
sudo pip install plotly
Reboot the Pi:
sudo reboot
Sign Up With Plotly
- Go to https://plot.ly and sign up for an account!
- Once you sign up and sign in, go to your settings: https://plot.ly/settings or in the drop-down on the top right in https://plot.ly
- Take note of your API Key
- Click the Stream Tokens tab, then click Generate token
- Take note of your Token
Clone the Atlas-Scientific Repository
Clone the Repository from Github:
git clone https://github.com/plotly/atlas-scientific.git
Open the Directory:
cd atlas-scientific
Or just copy the code from the files here: https://github.com/plotly/atlas-scientific
Add Username, API Key, and Streaming Token
Open atlas-pi.py
vi atlas-pi.py
Fill in your Username, API Key, and Streaming Token.
Here is an example of what it should look like in the file:
token = '5jpi07w226' username = 'arkeon' api_key = 'u6jlwbypiq'
Wire It Up
- If you haven't already, connect your Pi to power and your Internet router
- Connect the Pi Cobbler to your Pi's GPIOs and to your breadboard
- Put Atlas circuit onto breadboard
- Connect Ground on the Atlas stamp to Ground on the Pi Cobbler
- Connect VCC on the Atlas stamp to 5V on the Pi Cobbler
- Connect RX on the Atlas circuit to TX on the Pi Cobbler
- Connect TX on the Atlas circuit to RX on the Pi Cobbler
- Plug in your BNC connector aligning it with the Atlas circuit as seen in the picture.
Note: You could connect the Atlas circuit directly to the Raspberry Pi GPIOs using male-to-female jumper wires. Using the Pi Cobbler is good if you want to easily prototype with other sensors/devices.
Calibrate the Sensor
Calibration should be done the first time the circuit is used. Dip your probe in water, just to get it wet. Let it sit in the air for 5 minutes. Do not leave it in water, it must calibrate to the oxygen level in the surrounding atmosphere. After 5 minutes, run the DOcalibrate.py file located in the /Calibrate/Pi folder in the atlas-scientific repository.
sudo python DOcalibrate.py
You should see "Your Dissolved Oxygen Sensor is now Calibrated." in your terminal.
See It in Action
You're ready to go now!
Run the atlas-pi.py file with this command:
sudo python atlas-pi.py
If all goes well you should see the values spitting out in your terminal!
Check the Plot
Now go to your Plotly account and you should see a graph called "Atlas Real-Time dOxy". Open the graph and see those beautiful values live streaming!!
Note that the plot above has had the Traces, Layout, and Axes all styled. Try out some customization of your own once you've created your plot. Have fun with it!
Experiment!
The dissolved oxygen sensor is great for hydroponics, aquaculture, or any type of aerobic ferment, like a compost tea brewer. Wastewater treatment is another one. And if you decide to experiment with Atlas' other sensors, the sky is the limit. Do an experiment, stream your data, learn something awesome, and share what you find!