Environmental Sensor

The particulate sensor (Nova PM Sensor SDS011) is able to measure the particulate concentration in the air. In this case, we measure per one cubic meter of air, the number of particles sized 10 µm and 2.5 µm, which are defined as a measurement guideline. The subject is extremely topical, the sensor allows your own independent measurements, to find out the particulate concentration in your environment.

The problem that now arises is that one wishes to install the sensor at a suitable place, e.g. on a street light. Here, a battery-powered wireless solution comes into play. The LongRa board can also supply the required voltage (5 V) for the sensor.

PIN scheme

Arduino ZeroSensorDescription
D0 (RX)7 (TX)Serial data from the sensor to Arduino
D1 (TX)6 (RX)Serial data from Arduino to the sensor
GND5 (GND)Ground
5V0 (5 V)3 (5 V)Power supply 5 V

Since the sensor is fitted with a fan, which results in a higher start-up current, it is recommended to use powerful batteries or an external power source for the electrical supply.

The software

We have developed our own example solution, which drives the sensor, and transmits the measurement data via RadioShuttle protocol to a second station. For this the app ID is 10. This app ID defines the message to be transmitted and makes it publicly available. Find more information on this subject at The Apps Strategy.

The measurement takes place in the defined interval, e.g. every 30 minutes. First we apply the operating voltage (5 V), read measurment data for 20 seconds in order to get stable values, and transmit the data from the node to a second station. Then, we disconnect the 5 V power supply and put the board via the deepsleep function to sleep, to save energy, until the whole cycle starts in 30 minutes all over again with the next particulate measurement.

For the sensor wireless solution, reading the RadioTest example documentation is advised to obtain basic understanding, and to configure the node and station IDs.

The PM Sensor protocol data (app ID 10)

struct sensor {
 uint8_t version;
 uint8_t padding;
 uint16_t pm25;
 uint16_t pm10;
 uint16_t id;
} PMAppData;

The protocol data is very simply defined. There is a protocol version (currently 1). In addition, the measured values coming from the sensor are 10 times larger and must be divided by 10. “id” is the sensor serial number. A checksum or so is not required because, per LoRa, the used RadioShuttle protocol already contains a 16-bit CRC checksum.

Saving energy as node offline (measuring sensor)

Since the node usually waits for the next measuring period, and we want to save energy due to the battery-powered supply, the node is operated as an offline device. This means that, if there is nothing to do, RadioShuttle switches the LoRa wireless modem off and goes into MCU suspend mode. However, the RTC clock continues to run, awakening the board every 5 seconds for a moment, to check if there is work to be done.

rs->Startup(RadioShuttle::RS_Node_Offline);

Initializing the node as RadioShuttle::RS_Node_Offline switches the wireless modem off, provided that the Serial Monitor (USB) is not active. Being in the sleep mode, receiving data is not possible, also pushing and holding button “A” will only be recognized after 5 seconds.

If an external power supply is provided, or if it is desired to permanently keep an eye on the protocols via USB “Serial Monitor”, the node can be defined as RadioShuttle::RS_Node_Online. However, this consumes more energy than in the node-offline mode.

Approximate power consumption:

  • Nodes offline (deepsleep): 150 µA
  • Nodes online (sleep): 15 mA
  • Measuring time: 20 seconds (110 mA)

LED status indicator

The TX and RX LEDs flash quickly each time they send or receive RadioShuttle messages that were sent to the “Serial Monitor”.

In the node-offline mode, LED 13 is generally switched off, only flashing in the 20 second measuring period. In node-online mode, or with USB “Serial Monitor” active, it lights up continuously because the USB protocol is active 100 times per second.

Switching 5 V on / off

The LongRa Arduino Zero compatible solution has an integrated voltage converter which transforms the voltage provided by 2 x AA cells (standard batteries or rechargeable cells) to 5 V (max. 150 mA).

boost50 = 1;

This converter provides either 3.3 V or 5 V from the battery voltage. In order to prevent it from running continuously, it can be switched on and off by use of “boost50 = 1” or “boost50 = 0”, repectively. A MOSFET technology switches the power and off, so no power is consumed when being switched off. Alternatively, this can be done via the Arduino “digitalOut”. The corresponding pin is defined in “PinMap.h”.

The receiver (station)

#define RADIO_SERVER 1

This defines the solution as a RadioShuttle station (receiver). The station receives the sensor data and issues them in the USB “Serial Monitor”.

ParticalData: PM10: 5.3 (µg/m3) PM2.5: 4.1 (µg/m3) ID: 10229

The data is issued in a simple way but can also be used arbitrarily since the complete protocol data was transmitted.

Source code of PMSensorRadio

After the installation of the RadioShuttle software, the source code is completely available under the “RadioShuttle > PMSensorRadio” examples.

Sample installation of a particulate sensor

More Information