Tutorial – Part 4 – Experiments! Using an Analog to Digital Converter with your Raspberry Pi
Did you ever want to read a voltage (rather than a 1 or 0) on your Raspberry Pi? You can do this with an Analog to Digital Converter (ADC).
Have you ever wanted to read analog (voltage level) levels and sensors on your Raspberry Pi? While you can read digital sensors with the Raspberry Pi, there is no built in analog to digital converter on your Raspberry Pi.
In this Tutorial, you will learn how use an 4 Channel 16 bit Analog to Digital Converter (ADC) on your Raspberry Pi.
In part 4, we are showing several experiments using our sensors and the ADC along with the Raspberry Pi.
In This Tutorial
We are going to show you how to read these four sensors:
- An O2 (Oxygen Gas Sensor)
- An analog light sensor (light variable resistor)
- An analog air quality sensor
- A voltage divider connected to 5V on the Raspberry Pi
In part 1 to this tutorial, we discussed each of the various parts used to build this project.
The Four Parts to this TutorialPart 1 - Overview of the ADC Raspberry Pi Project Part 2 - Hooking up the Hardware Part 3 - The ADC Raspberry Pi Project Software Part 4 - Two Really Cool Experiments with the ADC Raspberry Pi
We are showing two experiments. The first is a complete documented test of the Air Quality sensor and the second is burning a candle in a glass bowl to see what the Oxygen percent goes down to before the candle burns out.
Air Quality Sensor Test
It is always interesting to know what is going on in your indoor environment. With that in mind, the gremlins at SwitchDoc Labs decided it was time to test out the Air Quality sensor and see just how sensitive it is. After running the whole ADC for a while at the Labs, our CTO said he would take it home for the weekend and try it out in the home environment. His results were interesting and showed that the unit was a lot more sensitive than we initially expected.
The chip on the Air Quality Sensor is a TP-401A.
What is the TP-401A?
The TP-401A sensor is very sensitive to a number of air-contaminating substances at low concentrations. Some of these are: Second hand smoke, carbon monoxide (CO), alcohol, volatiles of cosmetics (especially hair spray as we will see later), acetone, thinner, insecticides, benzene, formaldehyde, etc.
The sensor is composed of SnO2 materials doped with a catalyst making it a metal oxide semiconductor type of gas sensor. The resistance of the sensor will decrease when there are contaminating gases and will increase when the gases are removed from the environment. To operate the device needs to be heated to about 200-400 degrees C and this is what causes the current for this device to be about 50mA. A typical response of the sensor to 20 ppm (parts per million) of CO will to take the voltage up about 0.25V ~ 0.60V when the CO is detected.
Annotations from the Weekend at SwitchDoc Labs CTO House, all times in UTC (+8 Hours to Pacific Time):
A – Dryer Door opened, ironing begun. Could smell fabric softener.
B – Door opened to outside first for Panther The Cat, then door left open for a while. Finally dinner was cooked in oven.
F – Night time – ripples are probably auto fan and air conditioning effects.
C – Door opened for cat. Cat slow to go out. Very slow.
D – First hairspray test. Short sets of hairspray in the bathroom – noted air conditioner was on.
E – Dinner was cooked. Spinach Salad (with fresh Bacon bits).
F – Night again.
G – Hairspray in bathroom, this time the real thing as the family got ready for work.
We were amazed at how sensitive this inexpensive sensor was. We could detect all sorts of events in the entire house. One thing to point out is that virtually all of the time the sensor was under 3200 (rated fresh air) and the average was 2727 across the entire period.
We waited for the morning particulate count to drop and we ran one more test. We decided to do the ultimate hairspray test and use the hairspray near the sensor to see how fast it would react and how bad it would conclude the air was.
Test findings? The Air Quality System really does not like hairspray. The hairspray was sprayed about 18 inches above the sensor and not directly into the sensor. It peaked about 11,000 (High Pollution) and quickly trailed down in the next 15 minutes.
Conclusion of Air Quality Sensor Test
The Air Quality Sensor using the TP-401A device is a pretty sensitive sensor. While it is not very discriminating (with the possible exception of Hairspray), it is sensitive to a wide range of different air contaminants. The system was very easy to build using Grove devices and was a piece of cake to setup to log the data using the DataLogger software.
Oxygen Candle Burning Test
In this experiment, we took the Grove Oxygen sensor (see Part 1 for description) and placed it under a more-or-less sealed glass jar with a lit candle. The idea was to measure the Oxygen in the glass jar and watch it go down as the candle consumes the Oxygen. After a quick search on the Internet, we expected it to drop about 30% before the flame was extinguished. That would be from 21% Oxygen to about 14.7% Oxygen.
We set up the DataLogger system to sample the Oxygen every second, store the data in the MySQL database and then generate a graph update every minute.
Then we lit the candle and watched the data on the browser window connected to the Raspberry Pi.
The candle stayed lit for about 90 seconds and then slowly went out.
Next we started looking at the data, Our annotated chart is shown below.
Looking at the numbers, we determined that we started with about 21% Oxygen and the candle went out about 15.8% Oxygen level a reduction of about 25%. This is lower than the expected 30% The differences? We would guess a combination of sensor accuracy and candle type. One more thing to note: Look at the graph right after the candle went out. You can see that the seal wasn’t perfect as the Oxygen started to creep up.
As you can see in the past 4 postings, there is a lot you can do with an Analog to Digital Converter and a Raspberry Pi. We use an Analog to Digital converter in many of our products, such as OurWeather and the upcoming SmartPlant Pi Kickstarter.
Subscribe to SwitchDoc via Email
- New Grove Product – Grove Rotary Dial and Button Combo for Raspberry Pi on
- New Grove Product – Grove Rotary Dial and Button Combo for Raspberry Pi on
- New Kickstarter! SmartPlantPi – Raspberry Pi Based Plant Monitoring and Watering System Kit on
- IOT ESP8266 Tutorial – Using nodeMCU/LUA on
- Tutorial: Intro to Grove Connectors for Arduino/Raspberry Pi Projects on
- January 2017
- December 2016
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- 3D Printing
- 8 GPIO I2C Board
- Arduino Software
- Bluetooth Low Energy
- Breakout Boards
- Building Tips
- Computer Security
- Featured Topic
- FTDI Cable
- Grove 4Ch 16Bit ADC Board
- Grove Digital Extender
- Grove I2C Mux Breakout Board
- Grove OLED
- Grove Sensors
- Guest Blogs
- I2C Mux Breakout Board
- IBM Bluemix
- IOT Projects Book
- Matplotlib Graphs
- Pi Camera
- Pro Mini LP
- Project Curacao
- Python Raspberry Pi Software
- Quad Power Management I2C Board
- Raspberry Pi
- Real Time Clocks
- Smart Plant
- Solar Cells
- Solar Power
- SwitchDoc Dual WatchDog Timer
- SwitchDoc Products
- USB Power Control
- Weather Board
- Wind Power