1. Learning Centre
  2. Get Started
  3. 4️⃣ Ready to use experiments

Count visits with the LoRaWAN RDK

Facility management can be improved, taking into account actual usage and based on real-time measurements.

This experiment shows how a LoRa sensor device can count visits to optimise cleaning based on usage rather than rigid schedules.

In AllThingsTalk Maker the visualisation and rules will offer stakeholders to optimise and act when notified .

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
  • USB cable
  • Screw terminal
  • Magnetic door switch
  • Push button

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

  • Attach LoRa™ module & antenna
  • Connect magnetic door switch to screw terminal and the door switch to GROUND and D1 on the terminal
  • Connect screw terminal to D20/21
  • Connect button to D4/D5
  • Connect Sodaq Mbili to your computer through USB
  • Turn power switch ON


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 count-visits 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


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.

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


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.