Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Govee Permanent Outdoor Lights Prism review: Call it a triple play

    SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed

    How to build your own air quality meter with a Raspberry Pi and CO2 sensor

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      A new pope, political shake-ups and celebs in space: The 2025-in-review news quiz

      December 31, 2025

      AI has become the norm for students. Teachers are playing catch-up.

      December 23, 2025

      Trump signs executive order seeking to ban states from regulating AI companies

      December 13, 2025

      Apple’s AI chief abruptly steps down

      December 3, 2025

      The issue that’s scrambling both parties: From the Politics Desk

      December 3, 2025
    • Business

      Top 10 cloud computing stories of 2025

      December 22, 2025

      Saudia Arabia’s STC commits to five-year network upgrade programme with Ericsson

      December 18, 2025

      Zeroday Cloud hacking event awards $320,0000 for 11 zero days

      December 18, 2025

      Amazon: Ongoing cryptomining campaign uses hacked AWS accounts

      December 18, 2025

      Want to back up your iPhone securely without paying the Apple tax? There’s a hack for that, but it isn’t for everyone… yet

      December 16, 2025
    • Crypto

      Zcash Buyers Absorb The 10% Profit-Booking Hit — Breakout Attempt Back On Track?

      January 1, 2026

      Lighter CEO Addresses “FUD” Claims As LIT Price Dips 8% in 24 Hours

      January 1, 2026

      Why Could Dogecoin (DOGE) Set a New Low in Early 2026?

      January 1, 2026

      What Crypto Whales Are Buying and Selling on New Year’s Day 2026

      January 1, 2026

      Berkshire Hathaway’s $382 Billion Cash Pile Sparks Crypto Speculation as Buffett Retires

      January 1, 2026
    • Technology

      Govee Permanent Outdoor Lights Prism review: Call it a triple play

      January 1, 2026

      SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed

      January 1, 2026

      How to build your own air quality meter with a Raspberry Pi and CO2 sensor

      January 1, 2026

      A timeline of the major deals between publishers and AI tech companies in 2025

      January 1, 2026

      For platforms, here’s what’s not going to happen in 2026

      January 1, 2026
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»How to build your own air quality meter with a Raspberry Pi and CO2 sensor
    Technology

    How to build your own air quality meter with a Raspberry Pi and CO2 sensor

    TechAiVerseBy TechAiVerseJanuary 1, 2026No Comments6 Mins Read0 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    How to build your own air quality meter with a Raspberry Pi and CO2 sensor
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    How to build your own air quality meter with a Raspberry Pi and CO2 sensor

    Skip to content

    Image: Foundry

    A reliable indicator of the air quality in offices, classrooms, or living rooms is the CO2 content.

    In fresh air, the concentration of carbon dioxide is around 400 ppm. This stands for “parts per million”, in this case 400 CO2 molecules per million air molecules. Although this is only 0.04 per cent, it has a noticeable effect.

    Indoors, the concentration rises rapidly due to human respiration (ie. breathing). Surprisingly, during a film screening in a movie theater, CO2 levels of several thousand ppm can be quickly reached. If CO2 levels are high enough, this can lead to lack of concentration, tiredness, and headaches.

    A CO2 measuring station can tell you when it’s the right time to open the windows—fresh air is needed if CO2 levels reach 1500 ppm or higher.

    What you’ll need

    Firstly, you need a Raspberry Pi with a reasonably up-to-date Raspberry Pi OS. It doesn’t matter which Raspberry model you use.

    You also need a CO2 sensor. The MH-Z19C sensor from the Chinese manufacturer Winsen Electronics Technology is used in this article. The MH-Z19B model works in the same way.

    When buying, you should choose a model with pins, otherwise you will have to solder it yourself. Pins or headers are small pins that you use to connect the sensor to the Raspberry Pi. The version with headers is available on Amazon so make sure you choose that version when you buy it.

    Finally, you will also need jumper wires. You will need the female/female variant for the sensor.

    Overall, the investment is less than $40, whereas professional CO2 measuring devices cost many times more if you were to buy ready-made models.

    Important: To read out the sensor, the Raspberry Pi communicates via the serial interface, which is deactivated by default. To change this, use the tool

    raspi-config

    and select “Serial Port” under “Interface Options”.

    How the sensor works

    The MH-Z19C (or B) is a non-dispersive infrared sensor (NDIR). These are based on the concentration-dependent absorption of electromagnetic radiation in the infrared wavelength range. Carbon dioxide absorbs infrared radiation in a specific and measurable way.

    The light source transmits IR radiation through the air to be measured by the actual sensor. A filter is attached to the front which allows the absorption wavelength of the target gas to pass through.

    If the concentration increases, the absorption increases according to Lambert-Beer’s law and the signal decreases accordingly. The sensor determines the resulting light intensity and converts it into ppm.

    How to connect the sensor to the Raspberry Pi. The sensor should be viewed from the underside.

    Foundry

    Setting up the circuit

    To set up the circuit, first shut down the Raspberry Pi and disconnect it from the power supply. Then connect the circuit board to the sensor. You will need four jumper wires female/female, i.e. with sockets at both ends.

    You can see the function of each connection on the underside of the sensor. Connect pin 6 of the sensor (labelled “VCC” or “Vin”) to pin 4 on the Raspberry Pi. This is the power supply with five volts. Pin 4 is the second from the top on the right-hand side of the GPIO strip.

    Now connect pin “GND” (7) on the sensor to pin 6 on the Raspberry board. This is the earth wire. It is located directly under pin 4.

    Halfway through, continue on the other side of the sensor, which has five connections: Pin “Rx” (2) on the sensor must be connected to pin 8 on the mini computer, directly under pin 6.

    Finally, connect pin “Tx” (3) on the sensor to pin 10 on the Raspberry Pi, directly below pin 8. The illustration above shows the complete setup again. Finally, start the Raspberry Pi by reconnecting it to the power supply.

    Read out measured values

    The CO2 sensor is ready for use. A Python script is needed to read out the current CO2 value. Thankfully, one was developed by a Japanese developer – just for information, to explain the Github address. You install the script together with other components by opening a terminal on the Raspberry Pi and entering the following command:

    git clone https://github.com/UedaTakeyuki/mh-z19.git

    Then change to the newly created folder “~/mh-z19” and execute the installation script:

    ./setup.sh

    To determine the current CO2 value, use this command in future:

    sudo python -m mh_z19

    You will receive a result such as “{“co2″: 3128}”. The unit is the current ppm of CO2.

    The measured values can be automatically displayed online and clearly show the effect of ventilation.

    Foundry

    Measured values online

    Always reading out the measured values manually on the Raspberry Pi is annoying and too tedious in the long run. So it’s better to display the measured values online over time.

    Use a free online service to access the history of the measured values via PC or smartphone. Go to monitor3.uedasoft.com and enter an e-mail address and password to log in. You will receive a “view_id”, which you do not need.

    Click on the menu item Elements. Make a note of the second letter combination in the list, in the example “prgrvpqg”, and set the corresponding option to Active. Click on Save to finalize the setup.

    Now open a terminal on the Raspberry Pi and switch back to the “mh-z19” folder. There you call the command

    ./setid.sh [abcdefgh]

    replacing the sequence of letters with the eight-digit letter combination that you have just noted. This call is used to check whether everything is working properly:

    sudo python -m pondslider

    If the word “true” appears in the bottom line of the output, then everything is OK. In order to regularly receive measured values from now on and enter them in the Monitor app, enter the command

    ./autostart.sh --on

    In the browser, you can now see how the diagram on the Monitor page grows by one measured value every five minutes. The number of measured values displayed can be set directly below using the “Settings” button.

    To cover ten hours, you need 120 values. With the diagram, you can see at a glance whether someone has been airing the room while you were at lunch or shopping.

    The graph with the measured values can also be conveniently called up with a smartphone and downloaded as a CSV file via the “Download” button in order to analyze it in Excel. After rebooting the Raspberry Pi, the measurement script restarts automatically.

    The concept can be expanded further. With a red LED, a suitable 330 Ohm resistor and a slightly modified Python script, a circuit can be created in which the LED lights up as soon as the measured value exceeds a specified CO2 limit value.

    This article originally appeared on our sister publication PC-WELT and was translated and localized from German.


    Author: Brad Chacos
    , Executive Editor, PCWorld

    Brad Chacos spends his days digging through desktop PCs and tweeting too much. He specializes in graphics cards and gaming, but covers everything from security to Windows tips and all manner of PC hardware.

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleA timeline of the major deals between publishers and AI tech companies in 2025
    Next Article SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    Govee Permanent Outdoor Lights Prism review: Call it a triple play

    January 1, 2026

    SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed

    January 1, 2026

    A timeline of the major deals between publishers and AI tech companies in 2025

    January 1, 2026
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025567 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 2025209 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 2025114 Views

    6 Best MagSafe Phone Grips (2025), Tested and Reviewed

    April 6, 202599 Views
    Don't Miss
    Technology January 1, 2026

    Govee Permanent Outdoor Lights Prism review: Call it a triple play

    Govee Permanent Outdoor Lights Prism review: Call it a triple play Skip to content Image:…

    SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed

    How to build your own air quality meter with a Raspberry Pi and CO2 sensor

    A timeline of the major deals between publishers and AI tech companies in 2025

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    Govee Permanent Outdoor Lights Prism review: Call it a triple play

    January 1, 20260 Views

    SteelSeries Apex Pro Gen 3 review: A gaming keyboard built for speed

    January 1, 20260 Views

    How to build your own air quality meter with a Raspberry Pi and CO2 sensor

    January 1, 20260 Views
    Most Popular

    What to Know and Where to Find Apple Intelligence Summaries on iPhone

    March 12, 20250 Views

    A Team of Female Founders Is Launching Cloud Security Tech That Could Overhaul AI Protection

    March 12, 20250 Views

    Senua’s Saga: Hellblade 2 leads BAFTA Game Awards 2025 nominations

    March 12, 20250 Views
    © 2026 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.