Measuring air quality with the Raspberry Pi


The TP-401A sensor is a pretty sensitive device. Although 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 set up for logging data with the DataLogger software. I believe this is the first Rasp Pi Hairspray detector ever built.

Coming Next Column

Next up at SwitchDoc Labs is building a low-power (key feature!) wireless link between the WeatherRack anemometer/wind gauge/rain bucket sensors [9] and a Grove AM2315 temperature/humidity sensor using the Rasp Pi and – you guessed it – Grove connections and devices [10]. Wireless communication is desirable when we build weather projects at SwitchDoc Labs with displays, so we don't have to run wires from the station to the outdoor weather sensors.

Parts List

  • Raspberry Pi 2 Model A/B, RPi3, or RPi Zero
  • Pi2Grover – Grove to Raspberry Pi interface [1]
  • Grove four-channel, 16-bit, analog-to-digital converter [2]
  • Grove TP-401A air quality sensor [3]
  • Grove INA3221 three-channel high-side current I2C sensor [4]
  • Various Grove cables

SwitchDoc Note

One thing about the TP-401A is that it is designed for indoor use. I'm really tempted to take it outside, put a rain cover on it, and run it for a while. With a 49mA current draw, I'm probably not going to use it in a solar power system. You have to let it warm up for several minutes before you get good data, so switching it on and off will still consume quite a bit of power.

I was amazed at how sensitive this inexpensive sensor was. I could detect all sorts of events in the entire house. One thing to point out is that virtually all of the time the sensor value was less than 3,200 (rated as fresh air), and the average was 2,727 across the entire period.

I waited for the morning particulate count to drop and ran one more test – the ultimate hairspray test – using the hairspray near the sensor to see how fast it would react and how bad it would rate the air (Figure 7).

Test findings? The AQS really does not like hairspray. I sprayed the hairspray about 18 inches above the sensor, but not directly into the sensor. It peaked about 11,000 (high pollution) and quickly trailed down during the next 15 minutes. When I tested the sensor in a partially enclosed cardboard box with hairspray, it took much longer to dissipate.

Figure 7: The ultimate hairspray test.

Questions & Answers

[UCC:interviewer]Q:[/UCC] In your last column on SunTracking, you got 28% more power from tracking the cell. How much of that was used by the stepper motor and motor circuitry?

Best regards, Sarah

[UCC:interviewee]A:[/UCC] That is a good question, and I should have answered it before I printed the last column. In answer, I took the SunTracker system and hooked up the Grove INA3221 current measuring device between the Rasp Pi and the stepper motor driver/controller.

Based on the resistance measurement of the wiring in the motors (55 ohms per winding – the specification said 42 ohms), I expected an idle current draw of about 180mA. I measured about 170mA with the windings energized (using the Grove INA3221). If I used the motor this way all day, it would burn up ~11Wh, which would be far more than the ~4Wh improvement I got from tracking the sun.

However, that is not how I am using the stepper motor, which turns two steps every six minutes. With no real torque on the motors from the panel just sitting on top of it (ignoring wind!), I can turn the windings off, for a huge power savings. Assuming I turn the motor on for 2 out of 360 seconds, instead of burning 11Wh, it burns 0.061mWh, which is less than 2% of the savings. So, in this system, it looks like a good trade-off. The I2C motor control itself only takes about ~0.6mA.

I could tie down more of my assumptions (e.g., measuring the maximum wind torque on the solar panels), but after just feeling how hard it is to turn the motor when it is off, I think with this system I am covered.

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content