Environmental Sensing with the LoRaWAN RDK

Monitor the quality of the surrounding environment and provide stakeholders a dashboard to support decision making to improve quality of living.

This experiment shows how we can use a LoRa sensor device to monitor the quality of the surrounding environment. It measures air quality, noise level, temperature, humidity and pressure. In AllThingsTalk Maker the visualisation will provide stakeholders a dashboard to support decision making to improve quality of living.

Assemble the hardware

First step is to make sure that you have the following hardware components nearby:

  • Sodaq Mbili
  • LoRa™Bee radio module with antenna
  • TPH (temperature, pressure, humidity) sensor
  • Air quality sensor
  • Light sensor
  • Sound level sensor

 Afterwards assemble the hardware as detailed or depicted on the image below :

  • Attach LoRa™ module & antenna
  • Connect air quality sensor to A0/A1
  • Connect the light sensor to A2/A3
  • Connect noise sensor to A4/A5
  • Connect TPH sensor to SCL/SDA (I2C socket)
  • Connect Sodaq Mbili to your computer through USB
  • Turn power switch ON

schematic_lora_environmentalsensing

Loading and setting up the sketch

Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. In the following section we will program the hardware and send the collected sensor data to AllThingsTalk Maker:

  • Open Arduino IDE
  • Select environmental-sensing as example by clicking File > Examples > AllThingsTalk LoRaWAN SDK > Rapid Development Kit > environmental-sensing.
  • Open the keys.h tab. In this tab we have to provide some keys to ensure that the device is authenticated on the LoRaWAN network of choice but also on the AllThingsTalk Maker platform.
  • Enter your LoRaWAN keys. We tried to make it really simple.
    In the Maker application, and specific the LoRaWAN Rapid Development Kit you have previously created, go to Settings > Connectivity  (located in the upper right corner), scroll down and you will notice a section Keys file. Copy the code block and paste it in the Arduino IDE keys.h tab. 

Programming the hardware

We will now upload the sketch and keys to your LoRaWAN Rapid Development Kit, and when restarting the hardware data will be collected, and forwarded using the LoRaWAN network towards the AllThingsTalk platform.

  • Check again if your device is connected to your computer using the USB cable, and the Mbili board is switched on (SW2 in ON position)
  • Make sure the MBili is detected by the Arduino IDE application by verifying it is listed and selected in Tools > Port
  • Now simply click the upload button (highlighted in the image below). This will verify the sketch and libraries, compile and upload to the LoRaWAN Rapid Development Kit.

Arduino Upload button

  • When the uploading was done and successful, the collected data will be displayed in AllThingsTalk Maker

After uploading, you might need to flip the power switch on the Sodaq Mbili OFF and back ON to make sure the Mbili reboots and starts up our sketch.

 

Alternatively, you can also open the Tools > Serial monitor of the Arduino IDE. This can be very useful when debugging your own sketches.

  • Make sure you select the correct COM port to listen (under Tools > Port )
  • When the monitor is open, make sure the Baud rate is set to 57600

 

Visualise and use the incoming data

 

If all went well you should see data coming in...

Learn more how to visualise the data with Pinboards and make use of the data to automate your process or notify stakeholders using Rules.