Plotly + Atlas Scientific: Graph Real-Time Dissolved Oxygen With Raspberry Pi




Introduction: 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:!

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.

Step 1: Hardware You Will Need


Step 2: Setup Raspberry Pi

  1. Load Raspbian onto your SD card. There are plenty of tutorials out there on this. Here's a good one:
  2. 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.
  3. SSH into your Raspberry Pi. (To quickly find the IP address assigned to the Pi, I like using the Fing app on my iPhone.)
  4. 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

Step 3: Sign Up With Plotly

  1. Go to and sign up for an account!

  2. Once you sign up and sign in, go to your settings: or in the drop-down on the top right in

  3. Take note of your API Key

  4. Click the Stream Tokens tab, then click Generate token

  5. Take note of your Token

Step 4: Clone the Atlas-Scientific Repository

Clone the Repository from Github:

git clone

Open the Directory:

cd atlas-scientific

Or just copy the code from the files here:

Step 5: Add Username, API Key, and Streaming Token



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'

Step 6: Wire It Up

  1. If you haven't already, connect your Pi to power and your Internet router
  2. Connect the Pi Cobbler to your Pi's GPIOs and to your breadboard
  3. Put Atlas circuit onto breadboard
  4. Connect Ground on the Atlas stamp to Ground on the Pi Cobbler
  5. Connect VCC on the Atlas stamp to 5V on the Pi Cobbler
  6. Connect RX on the Atlas circuit to TX on the Pi Cobbler
  7. Connect TX on the Atlas circuit to RX on the Pi Cobbler
  8. 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.

Step 7: 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 file located in the /Calibrate/Pi folder in the atlas-scientific repository.

sudo python

You should see "Your Dissolved Oxygen Sensor is now Calibrated." in your terminal.

Step 8: See It in Action

You're ready to go now!

Run the file with this command:

sudo python

If all goes well you should see the values spitting out in your terminal!

Step 9: 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!

Step 10: 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!

Sensors Contest

Participated in the
Sensors Contest

Be the First to Share


    • Jewelry Challenge

      Jewelry Challenge
    • Raspberry Pi Contest

      Raspberry Pi Contest
    • Photography Challenge

      Photography Challenge



    4 years ago

    This is nice. Is there a way to do in in I2C mode rather than UART?


    6 years ago

    Hi good noon. could this be use in aquaculture industry and can this be submerged in fish pond for longer time?


    7 years ago on Introduction

    I'm attempting to execute this project using the pH sensor from Atlas. The sensor returns a value but I keep getting a 502 bad gateway error in addition to this Traceback:

    Traceback (most recent call last):

    File "", line 48, in <module>

    stream.write({'x': time_now, 'y': line})

    File "/usr/local/lib/python2.7/dist-packages/plotly/plotly/", line 49 0, in write

    self._stream.write(jdata, reconnect_on=reconnect_on)

    File "/usr/local/lib/python2.7/dist-packages/plotly/plotly/chunked_requests/ch", line 53, in write

    Exception: Server responded with status code: 502

    and message: <html><body><h1>502 Bad Gateway</h1>

    The server returned an invalid or incomplete response.


    I assume this means that plotly is not accepting data I'm sending. My username, apikey and token are all correct in the sensor code. There are no syntax errors either. I am very new to python so I'm certain that I'm missing something simple. Any help would be appreciated. The tutorial is very well written and appreciated.


    Reply 7 years ago on Introduction

    Hey ecoons --

    Thanks so much for trying out the tutorial and awesome job getting going with Python :)

    It looks like the error isn't caused by you, but actually from the server. Sometimes it gets overloaded, and has trouble responding. Give it another try in a bit. On our end, I'll keep you posted if anything changes!


    Reply 7 years ago on Introduction

    Thanks for the brisk response. Sounds like I have an opportunity to learn how to code a polling script. ;)


    7 years ago on Introduction

    I dont fully understant what plotty does.
    ¿Is there a server which performs all the calculations and return the graphs? Is this case our computer is just a host, and there is a need to be connected to internet every time we want to see the measurements.
    Otherwise, the calculations are make on our computer, so we just need to wire a sensor network which can work just like a LAN?
    i want to work with this, looks awesome, but just cant get connected to the internet every time i want to work with sensors...


    Reply 7 years ago on Introduction

    Thanks for reaching out! In this case, the Raspberry Pi talks directly to your account on Plotly's servers and is viewed as a graph in your web browser. Your computer does not need to be connected to your Raspberry Pi. To do intermediate calculations, you can modify the Python example script. Your graphs have a unique url, and every viewer of the graph sees the same data, at the same time. So, you do need to be internet connected to run this tutorial!