nkitanov / iaq_board

IAQ Board is a DIY (Do-It-Yourself) device for measuring internal air quality
358 stars 32 forks source link

IAQ (Indoor Air Quality) Board

IAQ Board is a DIY (Do-It-Yourself) device for measuring internal air quality. I needed a device for measuring some air quality parameters which is compact, cheap, simple and capable. After I prototyped it, decided instead of mounting into some odd box with cables hanging inside between the sensors, why not just solder everything on a printed circuit board. I had some experience with this from the time when I was a student years ago and luckily now it's much easier to crate PCB and very cheap to get it printed.

And here is my device. I am publishing all the details and documentation under 'open source hardware' CC-BY-CA license, so everyone can build, adapt and sell it, as long as share under the same license

Table of Contents

What exactly is this thing?

The device is based on widely available and cheap essential components (MCU and sensors). The core component is a simple PCB (printed circuit board) that's why I called it IAQ Board. The board integrates all the components in a very small footprint (size of a cigarette box). All parts are soldered on it and everyone can assemble it with basic soldering skills. The total price if you build it yourself is about 50-60 EUR. I also made simplistic holder for 3D print (6-7 EUR is you don't have a 3D printer). For these amount of money you get the following air parameters measured adequately (you might not install all sensors if you want to save money):

On top of that:

Here is a video with all you need to know:

Click to see the video

Who can build it?

The device is just a simple PCB board and almost everyone with some soldering skills can assemble it in a few steps:

  1. Download the PCB files and print the PCB somewhere like https://jlcpcb.com/
  2. Buy some components (listed in the bill of materials section) from Aliexpress or any other source.
  3. Solder everything on the board. With the exception of the ambient light sensor, all the rest is pretty easy with general soldering skills. Soldering light sensor can be done with regular soldering iron, but because of the small size of the IC, it's easier if you have heat gun or SMD reflow oven/plate. Here is video how to complete device from assembled PCB.
  4. Flash the microcontroller with the esphome firmware following the manual. You can write your own firmware if you have the skills. :smile:
  5. Print the holder case on 3D printer if you wish. I have some sensors without it and they are perfectly fine, so it's up to you.

If you have experience with electronics and microcontrollers just check the schematics and make whatever you wish - build your own firmware, do another PCB, connect external sensors, don't use it at all because you can make it better :smile:. The device is quite simple for embedded electronics enthusiasts anyway...

What about ordering a device?

I made this device for me and then decided to share it. I think a lot of people might be interested to have such air quality sensor. I did not have intension to make money from it, that's why it's "open hardware" and I publish all of the information, so everyone can build it.

However I know that someone might be interested in the device, but lack the skills to build it. Please follow this link for more details.

Components Details

The device with AAA battery size comparison:

1. PCB

The PCB (printed circuit board) is very simple and compact. It's 70x43mm (photos above are showing it larger than the actual size). It just connects a few sensors, microcontroller and displays. I wanted to integrate it in as much smaller footprint as possible, so the whole device is like a cigarette box. Most of the parts are surface mounted which makes the soldering just a bit more complicated, but still not a big deal. And of course it could be integrated even more by soldering all individual components on the PCB but then it's not really a hobby project anymore and much more difficult to build it. It's designed on KiCad and in the kicad folder you can find full KiCad project, PCB gerber files, etc.

2. Holder case

For any device the box is important. However my idea was to expose the PCB and electronics as much as possible in order to simplify it. I like the "raw" view of electronics and in this form I find it beautiful.

Taking into account this, I designed a simple holder case for "sliding" the PCB in it and holding the particle sensor. The case can stay at about 45 degrees angle. It is designed on Fusion 360 and the details are here. The holder case is not perfect, I was thinking to redesign it but no time for this. I am sure someone can do it better. :smile: Or design a complete box to cover the electronics fully, for me it is better in this minimalistic style.

3. Microcontroller Board

Initially I developed the board with using the most popular WiFi enabled MCU ESP8266 mounted on the cheap and small Wemos D1 Mini board. However this MCU have some limitations described in the tech details, so I changed it with the same size board compatible with Wemos D1 Mini, but running the newer much more powerful MCU of the same company - ESP32. In that way the device is quite stable, can run web server and since the board is having the same layout, on top of the D1 Mini ESP32 board you can connect extra display designed for d1 mini very easy. PCB is compatible with both D1 Mini ESP8266 or ESP32, even the labels are the same like on the older D1 board. However I do not recommend to use D1 mini with ESP8266! Also if I have to build next version of the PCB (I still have some 25 pcs), I will change the pins of one of the dust sensors.

These small size MCU board are pretty nice, they are tiny, have USB connector, onboard power supply and USB converter for programming or serial output. And you are powering the whole device just with a mini USB cable.

4. Dust Sensor

Dust sensor is the Chinese Plantower PMS7003 - 1, 2.5 and 10 micron particle laser sensor. It's very small and is perfect for indoor environment.

5. CO2 sensor

Carbon dioxide sensor is the Chinese Winsen MH-Z19B - the most expensive part of the device. It's quite popular for hobby air quality meters and can adequatly measure up to 5000 ppm CO2 concentration.

Keep in mind that there are some fake MH-Z19B sensors, explained here.

6. Temperature/Humidity/Pressure sensor

This sensor is the popular Bosch BME280, mounted on 3.3V only breakout board from China. There are also smaller breakout boards from China working both on 5V and 3.3V, but these have voltage regulator which can theoretically warm the board and change the temperature reading. That's why I use the boards with 3.3V only.

Please note that due to semiconductor shortage these are difficult to find now (June 2021). I am currently using my own breakout where I solder the BME directly. BME280 as IC can be found occasionally in stock from DigiKey

7. Ambient Light Sensor

The light sensor is TSL 2561 and it's the only sensor you need to solder directly on the board without a breakout board. I added this sensor not because I need to measure the ambient light but because I am a brightness freak, and I need the LEDs brightness to depend on the ambient light. Also wanted during the night when the lights are off the device to turn off the LEDs and displays automatically. You can also change the behavior of this brightness control and I spend some extra time developing the config only for the brightness features. :smile:

8. LEDs

The device have three Neopixel 5050 RGB multicolor LEDs. These LEDs are mostly found in the colorful LED strips and are controlled over a single wire. In my esphome based firmware left LED color is indicating the level of PM2.5 and change the colors depending on the value. Middle (LED2) indicates Air Quality Index based on PM2.5 only and the right one (LED3) indicates CO2 value. Keep in mind PM2.5 values are close to EEA levels (especially AQI). Some other devices like Xiaomi Air Purifiers have some very high levels on their displays and logic - it's green up to 70 microns which is already considered unhealthy both by EEA and EPA. In China "healthy" is considered bellow 50 microns. That's why AUTO mode of these Chinese devices works so bad. I try to keep indoor PM2.5 around 5-10 microns. I normally control my purifiers by Home Assistant and do not rely on their auto logic. If you have Xiaomi Purifier it can still show green, and the iaq device shows stable red, but it is correct according to the EU regulations.

Colors of the LEDs depends on this table: PM2.5 value (um/m3)
LED 1
AQI by EEA (Air Quality Index for PM2.5 24h average)
LED 2
CO2 value (ppm)
LED 3
Color R G B
< 10 < 10 (Good) < 700 off on off
11 - 20 10 - 20 (Fair) 700 - 1000 off on on
20 - 30 20 - 25 (Moderate) 1000 - 1500 on on off
30 - 40 25 - 50 (Poor) 1500 - 2100 on off on
> 50 > 50 (Very Poor) > 2100 on off off

9. Displays

The main display is the popular SSD1306 128x64 OLED display. On the top of the MCU board you can install extra OLED 63x48 shield from Lolin which shows temperature, humidity and air pressure only.

10. Volatile Organic Compound sensor

This is the Sensirion SGP30 senor mounted on a breakout board from China. I do not use it on all my devices, but I added it because I can. :smile: Also with it the device measures almost completely the internal air quality. SGP30 is also showing equivalent CO2 based on VOC but it's not precise compared with MH-Z19B NDIR sensor. Also it needs periodic calibration hardcoded in the firmware which makes it more tricky to use.

Please check here for the known issues with these boards.

11. Other electrical components

The device have 2 buttons - one for selection screens and settings, and another micro button for calibration of the CO2 sensor to 400ppm if you keep it pressed for more than 7 sec.

There are also four surface mounted bypass capacitors for the ambient light sensor and the LEDs.

Can you skip components?

Yes. The minimum you need is the microcontroller board. However since you don't have any sensors, you won't get any data. :smile: You can add only the sensors needed. Also if you skip ambient light sensor there will be no auto brightness control and the LEDs will operate always at 25% intensity. Installing only the ambient light sensor without any of the displays or any of the other I2C sensors (BME280, SGP30) will not work as there are no pullup resistors on the PCB for the I2C bus since it uses the resistors of the external breakout boards.

Bill of Materials (BOM)

Bellow is the list of all parts needed to assemble the device with links to sources where you can get them. Of course other sources can be used, just pay attention that the items are identical with the listed bellow. For example the SSD1306 display can be found with similar physical look and dimensions, but pins are not the same.

Schematic Ref ITEM pcs Comment
PCB Board 1 in kicad folder you can find all the data and GERBER PCB design files
U1 WeMos_D1_mini_ESP32 1 ESP8266 version also can work but not recommended
U2 PMS7003 Sensor 1 don't use the 2x5pin 1.27mm receptacle which comes normally wit these sensors, explanation is bellow
U3 SSD1306 Display 1 pay attention to correct pin order if you are buying from another source, as there are similar 4pin boards with different pinout
U4 BME280 breakout board 1 only 3.3V version with 6 pins which have both I2C and SPI. Please note that due to semiconductor shortage these are difficult to find now (June 2021). I am currently using my own breakout where I solder the BME directly. BME280 as IC can be found occasionally in stock from DigiKey
U5 MH-Z19B Sensor 1 Beware for fake sensors, as explained here. Buy from Winsen official store in Aliexpress.
U6 SGP30 breakout board 1
U7 TLS2561 light sensor 1
C1-C4 0.1 uF SMD Capacitor 4
D1-D3 Neopixel 5050 LED 3
SW1 Tactile Switch B3S-1000 1
SW2 Tactile Switch B3U-1000P 1
PCB Receptacle, 1.27 mm, 10 Contacts 1 This PCB Receptacle is for connecting PMS7003 dust sensor. Keep in mind these sensors come with such connector included but it's slightly taller and makes a gap of about half mm between sensor and PCB which is not ok.
SMD PCB Receptacle 8 pins 3 two are needed for the MCU board, 3rd you can skip. It's for extra pins on the PCB but with ESP32 MCU not needed so much as extra headers can be soldered directly on it's board
PCB Receptacle 4 pin 4 four is needed if all sensors are installed
OLED 63x48 shield 1 not required, only if you want an extra display on top of the MCU board
Holder case 1 it's not required to have it but it makes the device completed
Display holder 1 This small 3D printed part is holding tight the display from flapping
Various 2.54 headers You will need these for the CO2 sensor if you don't have available. Normally they come together with the breakout boards.
2mm nylon bolts/nuts If you want to make the display more stable you can install nylon bolts like explained in the video. Better use display holder.

Firmware

Firmware is created with ESPHome. The binary file, configuration and instructions are located in firmware folder.

Schematic

Find all KiCad project in kicad folder with schematic, PCB design file, 3D models, etc. In schematic U1 (microcontroller board) is based on ESP8266 version (original Wemos D1 mini).

Soldering tips

You need basic soldering skills and a soldering iron with thin tip. Because most of the components are SMD, it's much easier to buy some solder paste if you don't have. Most of the SMD components are quite large to solder easily with the iron, you can look in youtube, there are thousand of videos how to solder SMD components. Of course for some parts it's easier to use hotair rework station but not a requirement.

The only more difficult component to solder is the ambient light sensor which is quite small. I normally do these with a thin layer of solder paste and heatgun from bellow. However because of the footpint on the PCB is purposely made a bit bigger, I managed to solder it as well with a regular iron with a thin tip and solder paste. Also magnifying glasses will help.

If you use the small display over the MCU board, make sure i2c address is configured as 0x3D, which means to solder bottom two pads of the solder jumper like here:

User manual

It's quite simple, the device have only one "multi functional" button SW1, and one micro button SW2 for calibration of the CO2 sensor.

Multi function button

Also by default setting of these LEDs are to begin from 11% brightness. If it's bellow 11% they are turned off. As mentioned in the LED description setting these Chinese LEDs comes with different intensity and the ones listed in Bill of Materials section are too weak at the lowest setting. That's why I added brightness correction setting which can go from 0% to +40% in 5% step. This be done with press and hold the multi function button from 15 to 20 sec (explained above). This setting is saved in the non volatile memory of the MCU and it does not have to be configured after each reset. Alternatively if the device is added in Home Assistant, you will see a template switch called brightness_correction, which is doing exactly the same thing as the button on pin.

FAQ

Can I power it from a battery?

The device is powered from regular micro USB cable with 5V and consumes between 100-250 mA. You can power it with USB battery pack but not for too long (for example 4000 mAh battery will be depleted in about 20h). If you need to operate it from a battery, firmware have to enter the MCU in a deep sleep mode periodically. You have to build your own firmware. I do not run any of my devices in deep sleep as I do not see a reason for that.

Can it be installed outdoors?

The device is not waterproof. It can run outdoors if you install it in enclosure which is protecting it from water. It can handle high humidity maybe (never tested it). However the main purpose of the device is to be an internal air quality monitor. Measuring CO2 and VOC outside does not makes too much sense, but it can be used for dust pollution monitoring.

How to calibrate MH-Z19B CO2 sensor?

Periodically (let's say one time per month) and after installation of a new sensor calibration needs to be performed. The calibration is done by exposing it to the outside air which have about 400ppm CO2 concentration for about 20-30 min and then press and hold the micro button SW2 for more then 7 sec. In that way the value of the sensor is "zeroed" at 400 ppm. Alternatively if the device is added in Home Assistant, there is a template switch called switch.co2_sensor_zero_calibration and you just turn it on. It's doing the same as pusing the button but you are doing it remotely over the WiFi. Here are more details about this sensor and calibration.

How to calibrate SGP30 VOC sensor?

It's explained in ESPHome manual. You need periodically to update the firmware which is quite easy if you use Home Assistant. In my initial tests I noticed even without calibration value, the sensor shows some values and can detect smells, alcohol vapors, etc.

How to connect to WiFi?

After 1 minute of unsuccessful WiFi connection attempts, the microcontroller will start a WiFi hotspot with name iaq_device and password 12345678. When you connect to this fallback hotspot, the web interface should open automatically (see also login to network notifications). If that does not work, you can also navigate to http://192.168.4.1/ manually in your browser. Then type name and password of your local wifi hotspot, click save and MCU will restart and try to connect to the provided network. Additionally from this captive portal you can upload a new firmware.

How to add it in Home Assistant?

If you have Home Assistant you have to install the ESPHome addon, and after that add the device. All sensors, switches, LEDs will appear automatically as entities in Home Assistant. Then you can add them on the dashboard, here is one of my devices added on Home Assistant dashboard with all data from it.

What if some of the sensors/displays is disconnected while the device works?

Some of the sensors can be accidentally disconnected as on the original design they are not soldered on the PCB but are connected on a header receptacle. No worries with that. On the display you will see NaN and it means there is no value from the sensor or it's out of boundaries. Just reseat the sensor and push the reset button on the MCU board or disconnect and reconnect the USB cable.

What about short circuits of the exposed electronics?

Since all the components are exposed, there is some risk of making a short circuit with a metal object. The power supply is just 5V with limited current so it shouldn't be a big worry. However be careful not to short circuit anything with a conductive object as theoretically this can damage a component.

More Tech Details

As I mentioned above the initial design was based on ESP8266 microcontroller. Because of that the PCB is developed for Wemos D1 Mini board. Later on I decided it's much better to use ESP32 version, but PCB is not yet redeveloped and PCB silkscreen (writings) is for Wemos D1 Mini with esp8266.

Known issues

These are valid for ESP32 MCU:

These are valid for ESP8266 MCU (including the previous issues), not recommended to use that MCU because of the bellow issues:

License

The device is Open-source hardware, licensed by Open Source Hardware Association.