Přeskočit na obsah

pyramidak air quality

Why another DIY project?

All DIY smart home switches are ready, but because every smart home includes air quality sensors, and because commercial products have their own ailments – a closed system that often first sends data outside and only then shares the data with the home, so I really don’t like this system with possible logical breakdowns. Moreover, why depend on a commercial solution when even this more complex device can be made at home. A survey of similar DIY projects showed that a few such projects exist, but they do not allow for easy variability of indoor and outdoor sensor use. This is how the new project pyramidak air quality was born, inspired by the long-term use of commercial air quality sensors AWAIR and uRadMonitor.

What was behind the preparation of such a project?

30 hours spent studying air quality sensors, looking for reviews, researching availability and most importantly the availability of drivers. I researched what and how commercial products use as well. In addition, the sensor research revealed that there is a major Swiss brand Sensirion, that you won’t be able to ignore on a project like this because they provide working software examples with their own sensor chips, and thus the use of their sensors eventually became a priority. Then of course there are companies like Adafruit who does custom modules of available chips on the market, and they make it really easy to build such projects, but it’s logically bought out by the price. The important thing was to be sure how to connect so many sensors to one ESP*/D1 mini logic unit. It’s done with the I2C serial communication protocol, which only needs two GPIO communication contacts SDA and SDC to serve all the sensors. Thus, I2C support becomes the main requirement on the sensor.

What sensors must not be missing?

A temperature sensor that today always has a humidity sensor as well. I have never used the external pressure sensor and the smart home has no use for it. The carbon dioxide sensor will teach you how to ventilate properly. It will help you ensure constant access to fresh air. The dust particle sensor is especially important for outdoor use, because it warns you in time when not to ventilate. In the room, it will show you the dust caused by you or caused by ventilation at the wrong time. The TVOC sensor measures volatile organic compounds (Volatile Organic Compound), but it does not measure gases separately, but their mixture TotalVOC as a total increase of hazardous substances. The aim is not to show exact values, but to point out in summary that something is causing air pollution, and it is necessary to ventilate properly. If you need to accurately monitor a room for a specific dangerous gas, then sensors marked MQ-number are suitable for this, but they require calibration, greater heating and analog reading. Their use with other sensors in this project is inappropriate. Let’s discuss suitable individual sensors in detail.

But the most important sensor is the virtual one, the index or percentage that tell the user what the overall state of the air is. Real values are a nice thing, but ultimately you just need to know if you need to ventilate for lack of fresh air or if the air condition is already so bad that you need to ventilate immediately. The outdoor air condition index tells whether it is appropriate to ventilate or even if the air condition is so bad that it is not reasonable to even go outside. Yes, people live in such places too, it is enough if everyone in the neighborhood in his house heats up the boiler with crap in order to save money and not freeze, and of course they don’t care that others around can’t ventilate and breathe healthily. This virtual sensor must evaluate the output from each sensor and give it an appropriate weight. In practice, the resulting three conditions are sufficient – 1 clean air, 2 slightly polluted air, 3 heavily polluted air. By combining a virtual sensor outside and at home, the smart home will be able to control the complete ventilation and heating logic flawlessly. This is the principle of simple effective automation.

Carbon dioxide

If it was easy to choose any sensor, it was the carbon dioxide sensor. The NDIR (Non Dispersive Infra-Red) sensor uses the fact that CO2 molecules absorb infrared radiation of certain wavelengths. The higher the concentration of CO2, the more radiation CO2 absorbs. An infrared radiation source is located at one end of the tube, and two sensors with optical filters are located at the other end. All these sensors are calibrated and accurate enough, but the Sensirion SCD30 sensor deviates. This sensor is the only one with two chambers. One chamber changes the air and the other is permanently closed. As the radiation source decays over time, the closed chamber serves as a reference value for the decay of the emitter. Thanks to this, the measurement quality remains at a high level even years later. And that’s not all, this sensor is temperature compensated thanks to a thermistor. For the same price, you get a conveniently located, high-quality SHT31 temperature and humidity sensor.

Temperature and humidity

For outdoor use, an extra sensor will be needed and the choice is the very accurate Sensirion SHT40 (+humidity), which I am curious about, or the Bosch BMP280 (+pressure) or the Bosch BME280 (+pressure +humidity), which I already know.

Dust particles

Inside the sensor, a laser diode emits, the light of which hits particles of various sizes and is reflected to a photodetector, which determines the size of the particles based on the intensity of the signals. The sensors measure the number of particles per unit volume (number concentration) and then convert it to mass concentration based on particle mass estimates. Well-known is the Chinese manufacturer Plantower, whose products have been on the market for a long time PMS5003 and PMS7003, and boxes from other manufacturers often look the same. The manufacturer’s sensor lifetime is 4 years, while Western manufacturers promise up to 8 years, which include Honeywell HPMA115S0 or Sensirion SPS30. If twice the lifespan is realistic, then the price is also appropriate. There are also cheaper sensors on the market and they are actually sufficient for home use, but their lifespan is even less than 4 years. And how is the measurement quality? From the Plantower upwards, the same technology is used, and if the construction also, the measurement corresponds to it. Named products are slightly less able to detect larger particles than other designs. Investing in a dust sensor is therefore mainly about the lifetime of the sensor. I’ve long been persuaded to buy the more expensive SPS30, but hopefully the durability will even out.


TVOC sensors are heated to the required temperature for the measurement to work. For accurate calculations in the TVOC sensor, the ambient temperature and humidity must be transmitted to it. Therefore, the thermistor and the TVOC sensor cannot be placed together. The advantage of these sensors is that they calibrate themselves based on the principle that they find the lowest level during the day, and accordingly show a value increase, except for the SGP40 and 41 sensors, which only show an index of increase or improvement. This means that after switching on the values will only make sense after a few hours, preferably the next day. The disadvantage is that even if the sensor sometimes provides measured values of individual gases, these are only calculated imprecise values. Choosing a sensor is not easy. Sensirion SGP30 captures mainly mixtures of ethanol and hydrogen, more sensitive SGP40 ethanol and SGP41 ethanol and nitrogen dioxide. In a larger combination like the Bosch BME680, the thermistor serves mainly to transfer the temperature to the TVOC sensor, which captures a mixture such as ethane, isoprene, methyl, butadiene, ethanol, acetone and carbon monoxide. Both SGP30 and BME680 react even with the transmitted increasing temperature by increasing gases. An interesting one with an analog output is the Sensortech MICS-5524, which captures a mixture of carbon monoxide, ethanol, hydrogen, ammonia and methane. The MICS-4514 additionally captures nitrogen dioxide, and has analog outputs for two mixtures of carbon monoxide and nitrogen dioxide. The MICS-6814 captures extra propane and butane, and has a triple output mix for carbon monoxide, nitrogen dioxide, and ammonia. However, you do not transfer temperature correction to analog sensors, and any calibration is up to you. What conclusion to draw from all this. For home use, the SGP30 sensor, which is also used by AWAIR, is completely sufficient. However, if there is a stove or gas burner in the room, the BME680 or MICS-5524 will be a better choice.

Final project plan

On the electronics side, sensor research has shown that most modules can be purchased with I2C communication and power for both 3V3 and 5V, thanks to the companies that make the chip modules. With one exception, everything can be operated on 5V. I2C communication also brings pleasant auto-detection of sensors. Some TVOC sensors do not have I2C communication available and the D1 mini can handle one analog input. The choice is 5V and I2C, +1 analog.

It is more difficult in terms of construction. The modules are of different sizes, some cannot be next to each other, combinations for indoors and outdoors, all with the goal of one small universal PCB board. And then to close everything so that the air gets to the sensors properly. It’s a big challenge that I have thought up, but the realization can bring surprises.

See the finished project in the Hardware menu