The blog of a dedicated radio amateur and electronics enthusiast

"Having fun on the air and in the workshop - communicating and creating"

12 February 2023

Displaying PM2.5 data from the PM1006 sensor

After I had received the raw data, ( see 9 February ), I then wanted to connect a display module to show the PM2.5 particulate matter concentration value, which would also be a very useful addition to the domestic air quality monitor.
The setup in use while I was developing the software is shown in the image below. The setup comprises an ESP32 microcontroller development board, 128x64 pixel blue OLED display, control board and PM1006. The serial data connection to a hardware UART peripheral on the ESP32 required a resistive level shifter because the PM1006 outputs 5 volt logic high level, whereas the ESP32 UART input is for 3.3 volt and is not 5 volt tolerant. 
PM2.5=47ug/m3, (top-left) note the resistive level shifter
Each time the PM1006 is polled the software filters those bytes received by the UART that I had previously identified as containing the PM2.5 information, does the conversion to ug/cubic metre and sends the result to the display module. The software also selects the header and checksum bytes and uses them to detect any data errors to prevent corrupted data being displayed.
Now it is time to think about re-assembling the air-quality monitor. I'll need to choose a smaller micro-controller board and a different OLED display module to fit in the available space. I'd also like to fit additional sensors for measuring air temperature, relative humidity, TVOC and CO2.
  

09 February 2023

Reading PM2.5 data from the Cubic PM1006

Continuing the topic of the last post I can now decode the PM2.5 concentration data from the PM1006 particulate matter sensor. 
I dis-assembled the air-quality monitor, ( AQM ). Inside is an electronic circuit board and the PM1006. To access the data I connected the 'REST' test-pad and 'GND' test-pad on the circuit board to the 'RX' and 'GROUND' respectively of a 'USB-UART' protocol converter dongle. The dongle connects to a pc via usb in order to display the data using a serial terminal program.
(L) USB-UART dongle, (R) AQM control board & PM1006
The PM1006 data sheet states that the serial data format is 8 data bits, 1 stop bit, no check bit and speed 9600bits/second. When I had configured a serial terminal program to match, I was able to view the data bytes. 
I have observed that the control board switches on the sensor's fan, then polls the sensor 7 times. Each time 20bytes of data are output on the 'REST' connection. This process takes about 15 seconds, after which the fan is switched off for 20 seconds before the cycle repeats.
7 x 20 bytes (columns) of data displayed in hexadecimal form
The PM1006 data sheet also states that after 3 bytes of header, ( always 16 11 OB ), there are 16 bytes of data ( data fields DF1-DF16 ) and a checksum byte at the end. DF3 and DF4 ( columns 6 & 7 counting from the left ) contain data relating to the PM2.5 concentration. The actual concentration is found first by converting the hex to decimal and then using the formula ( DF3 x 256 ) + DF4. So '00 26' gives 38ug/cubic metre and '00 25' gives 37ug/cubic metre. The front of the AQM was illuminated yellow at the time; 36-85 is medium concentration and air quality 'OK'.
I extinguished a burning match near the PM1006. DF3 and DF4 peaked at 02 & 81 corresponding to PM2.5 of 641ug/cubic metre. The front was illuminated red.
The next step will be to parse the raw data ( in the image above ) in software and fit a display module to display the actual PM2.5 concentration in a 'user-friendly' form. That's a task for a micro-controller and the topic of a future blog-post !
 
Notes: 2 hex digits = one byte, and UART = Universal Asynchronous Receiver Transmitter. 
 
  

05 February 2023

Particulate Matter Detector

I've recently been using several different gas sensors, some of which I have already mentioned. But I also wanted a 'Particulate Matter' ( PM ) sensor to detect microscopic solid particles in the air, particularly as I am frequently sneezing in my work-area ! Realising that such sensors are also used in home 'air-quality' monitors, I bought a very cheap one for about GBP15 to take apart. Refering to the image below, green indicates 'good' air quality; PM2.5 between 0 and 35 ugms/cubic metre.
The domestic air quality monitor I bought
I removed the sensor from inside and identified the type as PM1006 made by Cubic. Searching for a data-sheet for more information, it is described as a LED Particle Sensor for detecting particles ranging in size from 0.3 to 10 microns. Especially interesting was to read that it has a built-in micro-controller which directly outputs the particle mass concentration in digital form, ( units of micro-grams per cubic metre ), as a serial bit stream at 9600bits/s which I should be able to hack in order to decode the data and display the concentration value. In fact a permanent numerical display would be a useful addition to the air quality monitor to supplement the changing colour of the visual effect.
Next time I'll be describing how I hacked the data.

micron = one millionth of a metre.
PM2.5 = Particulate Matter 2.5 micron ( reference particle size adopted internationally in particle concentration definitions of air quality ).