Difference between revisions of "Air-Monitoring-HAT"

From SB-Components Wiki

(Created page with "<div class="row"> <div class="large-8 column"> == Air Monitoring HAT == Air Monitoring HAT is a powerful and hi-tech PMSA003 sensor that provides the information of suspende...")
 
 
(12 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
* UART (Serial) Interface
 
* UART (Serial) Interface
  
</br>
 
 
=== Specifications ===
 
=== Specifications ===
 
* Model - Air Monitoring HAT
 
* Model - Air Monitoring HAT
Line 36: Line 35:
 
</div>
 
</div>
 
   <div class="large-4 column">
 
   <div class="large-4 column">
[[File:Air_monitoring_hat.png|thumb|left|alt=Air Monitoring HAT| Buy it From : ''[https://shop.sb-components.co.uk/products/air-monitoring-hat-for-raspberry-pi Click Here]'']]
+
[[File:Air_Monitoring_HAT.png|thumb|left|alt=Air Monitoring HAT| Buy it From : ''[https://shop.sb-components.co.uk/products/air-monitoring-hat-for-raspberry-pi Click Here]'']]
 
   </div>
 
   </div>
 
</div>
 
</div>
  
 
== Pinout ==
 
== Pinout ==
[[File:Round-lcd-pinmap.png|600 px]] [[File:Round_lcd_hat_pinout.PNG]]
+
<table class="wikitable">
 +
<tr> <th> Board Pins  </th> <th>Raspberry Pi</th>  </tr>
 +
<tr><td> 5V  </td> <td> 5V  </td> </tr>
 +
<tr><td> GND  </td> <td>  GND </td> </tr>
 +
<tr><td> PMS RX  </td> <td> GPIO 14  </td> </tr>
 +
<tr><td> PMS TX  </td> <td>  GPIO 15 </td> </tr>
 +
<tr><td> PMS SET  </td> <td> GPIO 27  </td> </tr>
 +
<tr><td> PMS RESET  </td> <td>  GPIO 17 </td> </tr>
 +
<tr><td> OLED SDA  </td> <td> GPIO 2  </td> </tr>
 +
<tr><td> OLED SCL  </td> <td>  GPIO 3 </td> </tr>
 +
 
 +
</table>
  
 
== Installation ==
 
== Installation ==
 
==== Python ====
 
==== Python ====
* Open a terminal and run the following commands to enable I2C and Serial:
+
===== Required Hardware =====
 +
* Raspberry Pi x 1
 +
* Air Monitoring HAT x 1
 +
 
 +
===== Enable I2C and Serial Interface =====
 +
* Open a terminal and run the following commands to enable I2C:
 
<source lang="shell"> sudo raspi-config </source>
 
<source lang="shell"> sudo raspi-config </source>
  
* Choose Interfacing Options -> SPI -> Yes
+
Choose Interfacing Options -> I2C ->yes
 +
 
 +
* Again run below command to enable Serial
 +
<source lang="shell"> sudo raspi-config </source>
 +
Choose Interfacing Options -> Serial -> No -> Yes
  
* You can also use GUI method to enable SPI Go to Menu > Preferences > Raspberry Pi Configuration > Interfaces, and enable SPI
+
* You can also enable Serial and I2C using Graphical method, Open Menu by clicking on <b> Raspberry Pi icon >> Preferences >> Raspberry Pi Configurations >> Interfaces </b>, and select below option.
  
[[File:Spi_en_gui.png]]
+
[[File:Serial_i2c_en_graphical.PNG]]
  
* Stack Round LCD HAT on top of Raspberry Pi GPIO Header pins.
+
* Now reboot your pi by running the below command :
* Make Sure SPI is Enabled (As mentioned above)
+
<source lang="shell"> sudo reboot </source>
* Now clone Round LCD HAT Github repository by running below command in terminal
+
 
<source lang="shell"> git clone https://github.com/sbcshop/Round-LCD-HAT.git </source>
+
===== <b> Board Test </b> =====
* Enter dowloaded directory
+
 
<source lang="shell"> cd Round-LCD-HAT </source>
+
* Clone Github repository of Air monitoring HAT by running below command and enter its directory.
* Now run demo.py by running below command.
+
<source lang="shell">  
<source lang="shell"> python3 demo.py </source>
+
git clone https://github.com/sbcshop/Air-Monitoring-HAT.git
* You can also run "LcdDemo_Joystick.py" file to display the image and change the color of the arc using the attached 5 input joystick.
+
cd Air-Monitoring-HAT
<source lang="shell"> python3 LcdDemo_Joystick.py </source>
+
</source>
 +
* Now run GUI of Air monitoring HAT by running the below command on terminal.
 +
<source lang="shell">  
 +
python3 Air_Monitoring_GUI.py
 +
</source>
 +
* Select COM port from above GUI ("/dev/ttyS0" in case of default connection), and click on the start button to start Real-Time data from the sensor.
 +
 
 +
* You can also use these two examples and modify them easily :
 +
** display_on_oled_example.py :- To print the sensor data on Oled Display.
 +
** read_example.py : To print the sensor data on Python shell or Terminal.
 +
 
 +
== API Usage ==
 +
<b> Guide to print data on python shell or terminal </b>
 +
* Import required dependancy by adding below lines.
 +
<source lang="python"> from pms_a003 import Sensor </source>
 +
 
 +
* Now create a sensor class object.
 +
<source lang="python"> air_mon = Sensor() </source>
 +
 
 +
* Now initialize serial connection.
 +
<source lang="python"> air_mon.connect_hat(port="/dev/ttyS0", baudrate=9600) </source>
 +
* Read and print sensor data on python shell / terminal.
 +
<source lang="python"> air_mon = Sensor() </source>
 +
 
 +
* Read and print sensor data on python shell/terminal
 +
<source lang="python">
 +
values = air_mon.read()
 +
print("PMS 1 value is {}".format(values.pm10_cf1))
 +
print("PMS 2.5 value is {}".format(values.pm25_cf1))
 +
print("PMS 10 value is {}".format(values.pm100_cf1))
 +
</source>  
 +
 
 +
* To disconnect or drop serial connection, use the below function
 +
<source lang="python"> air_mon.disconnect_hat() </source>
 +
 
 +
<b> Guide to print data on Oled Display </b>
 +
 
 +
* Import required dependency by adding below lines.
 +
<source lang="python">
 +
from pms_a003 import Sensor
 +
from oled_091 import SSD1306
 +
from time import sleep
 +
</source>
 +
* Now create class object for oled and sensor
 +
<source lang="python">
 +
oled_display = SSD1306()
 +
air_mon = Sensor()
 +
</source>
 +
* Now initialize serial connection
 +
<source lang="python"> air_mon.connect_hat(port="/dev/ttyS0", baudrate=9600) </source>
 +
 
 +
* Read and print sensor data on Oled Display
 +
<source lang="python">
 +
values = air_mon.read()
 +
oled_display.PrintText("PM1.0= {:2d}".format(values.pm10_cf1),
 +
                              cords=(2, 2), FontSize=10)
 +
oled_display.PrintText("PM2.5= {:2d}".format(values.pm25_cf1),
 +
                              cords=(65, 2), FontSize=10)
 +
oled_display.PrintText("PM10= {:2d}".format(values.pm100_cf1),
 +
                              cords=(25, 20), FontSize=13)
 +
oled_display.ShowImage()
 +
sleep(1)
 +
</source>
 +
</br>
  
 
== Resources ==
 
== Resources ==
 +
 +
''' Github '''
 +
 +
* [https://github.com/sbcshop/Air-Monitoring-HAT Source Code]
 +
 +
''' Datasheet '''
 +
 +
* [https://cdn.shopify.com/s/files/1/1217/2104/files/PMSA003_datasheet.pdf PMSA003 Datasheet]

Latest revision as of 04:55, 23 June 2021

Air Monitoring HAT

Air Monitoring HAT is a powerful and hi-tech PMSA003 sensor that provides the information of suspended particulate matter (PM1.0, PM2.5, and PM10) in the air per unit volume via digital output with an operating voltage of 3.3 V. It communicates via UART (serial) with the standby current ≤200 Microampere (μA) of the sensor.

Features

  • Digital sensor
  • Operating Voltage 5V DC
  • PMSA003 Sensor
  • Standard 40 Pin GPIO
  • OLED Display 0.91”
  • Measuring range 0.3 to 10 Micron
  • UART (Serial) Interface

Specifications

  • Model - Air Monitoring HAT
  • Sensor Model number - PMSA003
  • Data Output - Digital Sensor(unit quality + number of units)
  • Type - Biosensor
  • Communication Interface - UART (Serial)
  • Display Type - OLED Display 0.91”
  • Board Dimension - 65 x 56 mm
  • Measuring range - 0.3 to 1.0, 1.0 to 2.5, 2.5 to 10 Micron (μm)
  • Counting efficiency - 50% @ 0.3 μm 98% @> = 0.5 um
  • Response time - ≤10 s
  • DC supply voltage - 5.0 V
  • Maximum Operating Current - 100 Milliamp (mA)
  • Standby current - ≤200 Microamp (μA)
  • Data interface level - L <0.8 @3.3, H >2.7@3.3 Volt(V)
  • Operating Temperature range - -10 to +60 Celsius (℃)
  • Operating Humidity range - 0 - 99%
  • Mean time between failures - ≥3 Year(Y)


Air Monitoring HAT
Buy it From : Click Here

Pinout

Board Pins Raspberry Pi
5V 5V
GND GND
PMS RX GPIO 14
PMS TX GPIO 15
PMS SET GPIO 27
PMS RESET GPIO 17
OLED SDA GPIO 2
OLED SCL GPIO 3

Installation

Python

Required Hardware
  • Raspberry Pi x 1
  • Air Monitoring HAT x 1
Enable I2C and Serial Interface
  • Open a terminal and run the following commands to enable I2C:
sudo raspi-config

Choose Interfacing Options -> I2C ->yes

  • Again run below command to enable Serial
sudo raspi-config

Choose Interfacing Options -> Serial -> No -> Yes

  • You can also enable Serial and I2C using Graphical method, Open Menu by clicking on Raspberry Pi icon >> Preferences >> Raspberry Pi Configurations >> Interfaces , and select below option.

Serial i2c en graphical.PNG

  • Now reboot your pi by running the below command :
sudo reboot
Board Test
  • Clone Github repository of Air monitoring HAT by running below command and enter its directory.
git clone https://github.com/sbcshop/Air-Monitoring-HAT.git
cd Air-Monitoring-HAT
  • Now run GUI of Air monitoring HAT by running the below command on terminal.
python3 Air_Monitoring_GUI.py
  • Select COM port from above GUI ("/dev/ttyS0" in case of default connection), and click on the start button to start Real-Time data from the sensor.
  • You can also use these two examples and modify them easily :
    • display_on_oled_example.py :- To print the sensor data on Oled Display.
    • read_example.py : To print the sensor data on Python shell or Terminal.

API Usage

Guide to print data on python shell or terminal

  • Import required dependancy by adding below lines.
from pms_a003 import Sensor
  • Now create a sensor class object.
air_mon = Sensor()
  • Now initialize serial connection.
air_mon.connect_hat(port="/dev/ttyS0", baudrate=9600)
  • Read and print sensor data on python shell / terminal.
air_mon = Sensor()
  • Read and print sensor data on python shell/terminal
values = air_mon.read()
print("PMS 1 value is {}".format(values.pm10_cf1))
print("PMS 2.5 value is {}".format(values.pm25_cf1))
print("PMS 10 value is {}".format(values.pm100_cf1))
  • To disconnect or drop serial connection, use the below function
air_mon.disconnect_hat()

Guide to print data on Oled Display

  • Import required dependency by adding below lines.
from pms_a003 import Sensor
from oled_091 import SSD1306
from time import sleep
  • Now create class object for oled and sensor
oled_display = SSD1306()
air_mon = Sensor()
  • Now initialize serial connection
air_mon.connect_hat(port="/dev/ttyS0", baudrate=9600)
  • Read and print sensor data on Oled Display
values = air_mon.read()
oled_display.PrintText("PM1.0= {:2d}".format(values.pm10_cf1),
                               cords=(2, 2), FontSize=10)
oled_display.PrintText("PM2.5= {:2d}".format(values.pm25_cf1),
                               cords=(65, 2), FontSize=10)
oled_display.PrintText("PM10= {:2d}".format(values.pm100_cf1),
                               cords=(25, 20), FontSize=13)
oled_display.ShowImage()
sleep(1)


Resources

Github

Datasheet