Public Lab Research note

How to Monitor Indoor TVOC with Raspberry PI

by Makepcb | July 12, 2021 02:17 12 Jul 02:17 | #27056 | #27056

Do you spend about 70 percent of your daily life indoor like me?

Do you pay attention to the air quality of the room? If the TVOC level is too high indoor, it will be bad for your health.

So, in this project, we will make an indoor TVOC monitor with Raspberry Pi, with voice broadcast to remind us: Hey, time to open the window!angry

1. What is TVOC?

TVOC means Total Volatile Organic Compounds. Volatile organic compounds are organic chemicals that become a gas at room temperature. There are many kinds of VOCs and they can be at the same time present. Some VOCs are bad for the health, they will cause eye and nose irritation, shortness of breath, headaches, and so on. Higher concentrations may cause physical irritation even damage. Most people are not affected by short-term exposure to the low levels of VOCs found in homes. But for your health, it suggests avoiding exposure at high VOC levels.

VOC's come from many sources, even you can be a polluter! The Cleansers, disinfectants; Pesticides, air fresheners, construction materials, new furniture, and so on are the VOC sources. They may increase the indoor concentration of VOC's due to off-gassing that may cause serious threats to your well-being. To stayed the room at low levels, try to open the window frequently for changing the Air.

2. How to Measure TVOC Value?

The VOCs are no color, no taste, and it required a specified sensor for measuring them. As the previous project showed, the SGP30 is an air quality sensor for measuring the VOC and eCO2. Using the SGP30 senor is the best option that I have been familiar with it. To make SGP30 work, it is required to set up the I2C bus in the configuration.

3. TVOC Monitor Based on Raspberry Pi

I made a sketch for this project. For getting the TVOC reading, the SGP30 sensor was connected with raspberry Pi via I2C. For controlling and computing, I used the Raspberry platform instead of the single-chip that Raspberry has more strong computing ability. Besides, I had to prepare the speak and the audio coding part for voice reminders. The Raspberry Pi has to convert the text to audio what the speaker play. I also had to prepare an LCD to display the TVOC reading. I spent a long time looking for a platform that is suitable for this project.

Raspberry Pi Embedded System Development Platform is designed for designed by Makerfabs, it is based on Raspberry Pi Zero W to develop. The mainboard of the kit has a 3.2-inch SPI display with a touch for display something, and it has an audio coding part with WM8960 and a speaker for the audio output. Besides, the mainboard also provides many kinds of ports, such as UART, I2C, ADC, GPIO, that are very suitable for this embedded project. The kit also provides the SGP30 module that was no need to prepare the sensor again.
I have an idea about displaying the TVOC measuring, that is showing the SGP30 reading history. The history of the SGP30 reading can help us to find the cause of the TVOC changing.

3.1 Connect SGP30 with Raspberry Pi

Connect the SGP30 sensor with the I2C port of the main board via cable.

3.2 Program

The code is available and you can obtain it from Github.

1. For working with the SGP30 sensor, Raspberry Pi Zero has to install the specified library for driving the SGP3O. Use the following command to install.

sudo pip3 install pimoroni-sgp30
sudo pip3 install smbus2

2. Get the TVOC measuring.

sgp30 = SGP30()
result = sgp30.get_air_quality()

co2 = result.equivalent_co2
tvoc = result.total_voc

3. Display the historical values of the SGP30 on the LCD, these values would be composed of a historical line.
4. There is a function in about TTS which converts the text to audio via the internet.

def request_tts(TEXT,Result_name):

3.3 See the Result

Running the program, the TVOC reminder can work. Place it on the desk in the living room, kitchen or official. When you open the air freshener or cleanser that something will increase many VOCs, the TVOC reminder will remind you the TVOC is too high, and you have to open the window for changing the air. When the TVOC concentration is at a low level, the TVOC reminder also will remind you the level is normal.

I did this Help out by offering feedback!

People who did this (0)

None yet. Be the first to post one!


@Makepcb The combo of data display and audio reminders is so cool! Thanks for sharing this!

You mentioned that the SGP30 sensor is the best option you've come across--what features have made it the sensor that you prefer?

Is this a question? Click here to post it to the Questions page.

Reply to this comment...

Login to comment.