Daily tips and tricks from the experts at Adafruit!
View this email in your browser

Adafruit’s SGP30 gas sensor is calibrated out of the box to measure a large range of volatile organic compounds (VOCs) and CO2. It can actually measures with 10x more precision than the previous generation of sensors. It peaks at 60,000 PPB for VOCs. The temperature and humidity are automatically compensated for. Probably the best part is that unlike other sensors which require a 24-48 “burn in” this one requires less than 20 seconds on startup to warm up and stabilize. Since VOCs include alcohol and acetone (a by-product of ketone production) this sensor is fun to use as a breath tester. This post will focus on how to connect, enclose and view the output of the breath tester. 

The I2C interface on the SGP30 makes for a super simple connection. We are using the Trinket M0 microcontroller running CircuitPython to read the output. A more detailed explanation of using the SGP30 is available in this tutorial. It is important to note that the latest versions of adafruit_sgp30 and adafruit_bus_device libraries can be obtained from the CircuitPython Bundle.

    $ unzip adafruit-circuitpython-bundle-2.2.1-mpy-20180204.zip

    $ cp adafruit_sgp30.mpy /Volumes/CIRCUITPY/lib

    $ cp -pr adafruit_bus_device /Volumes/CIRCUITPY/lib

The Trinket M0 has a REPL>>> console which we can use to press the enter key when ready to test and view the results. After 30 seconds of gathering breath samples the code will select the highest VOC reading detected and display it for us. If we were trying to find a correlation to blood ketones and breath acetone we could record this high VOC value to the results of a blood ketone meter like the Precision Xtra from Abbott. After collecting data lots of samples from both devices we could come up with a possible correlation from breath readings to blood ketones.

Adafruit sells small modular snap boxes. These are great for a breath tester as the lid pops open to let the humidity out. All that is needed to modify the case is a 3/32″ drill bit for the mounting bolts (M2 size x 10mm). The uni-bit on the left can be used to for drill out space for a USB plug and the 1/4″ hole required for the straw. The nice thing about using drinking straws is that they are an easy way for people to share the breath tester and not share germs.


Once the components are soldered and secure in the enclose we connect via the micro USB cable to upload the code and watch the console. Here is an example from a OS/X command line. I usually just search for /dev/*modem* to find the Trinket device.

$ cp code.txt /Volumes/CIRCUITPY

screen /dev/tty.usbmodem1421