PMS5003 Particulate Matter Sensor
Introduction
Honeywell HPMA115SO-XXX and the Plantower PMS1003/5003 particulate matter sensors are nearly identical products. The underlying principal of operation is laser light scattering and its analysis. An internal fan sucks air into a chamber where the analysis takes place. Numerical results of particulate matter are communicated using a UART protocol and units of micrograms per cubic meter. The PMS5003 is a more compact unit. A complete prototype product was developed around an Espressif ESP32 device using the ESP32 library. Results are sent out both via a http server and an MQTT publisher to a broker account in the cloud.
The software was built using the esp-idf-v4.3.2 library and components such as esp32-wifi-manager as well as mqtt and uart libraries.
The following describes this prototype product and its operation.
Hardware
To repeat, this sensor utilizes the Plantower compact PMS5003 particulate matter sensor together with an Espressif ESP32 System-on-Module (ESP32-WROOM) and utilizes the integrated 2.5 GHz WiFi radio. Power is supplied with a 5 volt, 1 ampere wall charger. The enclosure material is ABS. Power jack is 5.5 mm barrel and 2.0 mm center pin.
The unit can be wall mounted, if desired. The intake and output ports need to remain clear and not blocked in any way. If used outdoors, the user must make provisions to shield these ports from ingress of rain or snow. Additionally the power plug/jack assembly is not water-proof, so provisions must be made to protect this connection.
The bottom label contains essential information that is needed during commissioning, that is, the first time set up of the unit.
Setting Up the Unit
Commissioning the unit is what the component esp32-wifi-manager does. First time set up requires providing the user’s WIRELESS LAN SSID and password to a server that the unit spawns upon first time power up. A user needs to do the following:
- Apply power to the unit.
- Use any client (laptop, desktop, cellphone) and go to network/internet settings.
- In the list of networks find the one with SSID “esp32” as shown on the left in the image below and select it.
- After selecting it sign into it with password: esp32pwd. The sensor is now an access point with IP address: 10.10.0.1. On the client open a browser and go to: http://10.10.01 and the screen shot shown in the image second from left will appear with a listing of network SSIDs.
- After selecting the user’s WIRELESS LAN SSID, the screenshot third from the left appears. Enter the WIRELESS LAN’s password
- If the sensor connection to the WIRELESS LAN is successful the last screenshot will appear. At this point the sensor has stored in non-volatile storage the user’s network information, the sensor’s access point stops operating, and subsequently the sensor will automatically connect to this network as a client whenever powered up.
Operation
After commissioning. The sensor continuously measures particulate matter data and provides two ways to get the data. The sensor operates an HTTP server on the user’s WIRELESS LAN and the user can use any browser on the WIRELESS LAN to obtain a current reading. The sensor also operates an MQTT publisher and sends data to an MQTT broker account at AWS. The sensor updates every 25 seconds. (“MQTT is a lightweight client-server publish/subscribe messaging protocol, optimized for high-latency or unreliable networks. This protocol is a good choice for Internet of Things applications, Telemetry, Sensor Networks, Smart Metering, Home Automation, Messaging and Notification Services.”)
HTTP server
To get data in the client browser one must use the following URL: http:///getdata. The sensor IP can be obtained by looking at the wireless client list in the user’s router. The sensor will be “espressif” with MAC address that is found on the bottom of the sensor enclosure. It is recommended to make this IP address static by using the Address Reservation feature of the router. The following screenshot shows a result.
MQTT Subscriber
An MQTT subscriber is needed in order to receive continuous data from the sensor. The use of a subscriber permits one to log the results to a file for later analysis. For Android phones there are many free MQTT clients to choose from, but many do not work and/or are very difficult to use. One wants a simple MQTT client subscriber that outputs text messages and connects to HOST= m11.cloudmqtt.com, PORT= 12850, TOPIC= PMS5003, USER= frank, PASSWORD= testpasswd. Screenshot below is an example on a Pixel 6:
An example of an MQTT subscriber running on a desktop under Ubuntu 16.04 is shown below. For visibility purposes the image is truncated.
One can choose that the subscriber downloads results over SSL(port 22850), but one must know how to obtain and where to place the broker’s CA certificate on the subscriber client’s host machine; however, it is likely to already exist. On Debian machines it may already exist in the file /etc/ssl/certs/ca-certificates.crt.