Detecting oxygen with an Analog to Digital Converter.

antimartina, 123RF

Burning Both Ends

We hook up a simple IoT device that detects the concentration of oxygen and push the data to online dashboards so anyone can monitor it..

It has been a busy month at SwitchDoc Labs. I am on the team designing a new Robotics and AI (Artificial Intelligence) course at the University of Idaho. Boy, the things we are going to be doing! And a number of these things are going to make their way to this column in the next months.

We promised last time to take a look at Alexa and the Raspberry Pi and we did build a prototype. However, things are still too raw and complicated for us to do a column on that project. Soon, I promise. To see our progress, check out this video using the Amazon Alexa and the Raspberry Pi [1].

But back to this issue. Today we are going to take a look at a simple project based on a Raspberry Pi, an Analog to Digital Converter (ADC) and an Oxygen sensor. In Raspberry Pi Geek Issue 16 [2] we talked about Grove connectors and how to use them with the Raspberry Pi. You will be using three Grove devices for this great experiment to create a sophisticated Oxygen sensor. We have previously used an ADC with the Raspberry Pi in our Air Quality Sensor column in Raspberry Pi Geek Issue 18 [3].

Interface Board

The Pi2Grover board (Figure 1) provides 15 Grove connectors: 10 Grove Digital, 4 Grove I2C, and one Grove UART. Fast prototyping with many, many Grove devices is supported. No software drivers are required, so you are right next to the hardware.

Figure 1: The Pi2Grover Board.

The board plugs right into your Raspberry Pi with a special connector that supports installing other boards or HATs on top of the Grove board itself.

The Grove 4 Channel 16 Bit ADC Board for the Raspberry Pi is based on the industry standard ADS1115 (Figure 2). It supports voltages of both 3.3V and 5V and also uses Grove connectors. The board has four 16 bit Analog-to-Digital Channels, which can be programmed in many different ways.

Figure 2: Grove 4 Channel 16 Bit ADC Board.

The O2 Grove Gas Sensor (Figure 3) works by outputting voltage values proportional to the current oxygen concentration in the air around you. You can interpret these numbers by referring to the oxygen concentration linear characteristic graph.

Figure 3: Grove Oxygen Sensor.

This sensor value only reflects the approximate trend of gas concentration in a permissible error range, so it is not exact. Detecting the specific makeup components in the air usually requires a more expensive device, which is far more precise than a simple gas sensor. This sensor also requires around half an hour to warm up (Figure 4).

Figure 4: Grove Oxygen Sensor Curve takes about 30 minutes to reach the correct level.

All of the connections save one Jumper are Grove connections (Figure 5). All Grove connections use the same cable to connect to one another.

Figure 5: Project wiring diagram.


The ADC board is based on the TI ADS1115 16 bit 4 channel I2C ADC. Any software that supports the ADS1116 will work either with Arduino or the Raspberry Pi. You are going to use two examples of Python Software to read the ADC devices. The first is a simple test of the ADS1115 board, reading all the values, doing a little math and then printing the values out to the screen. This test program is included in the Raspberry Pi DataLogger shown below.

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content