Improve facility management by taking into account actual usage based on real time measurements.
This experiment shows how a LoRa™ sensor can count visits to optimise cleaning based on usage rather than rigid fixed schedules.
For the prerequisites below, please check the quick start page!
Each time the door opens a counter is incremented locally on your LoRa device.
Every 30 seconds, if the count has changed, it will be sent to your AllThingsTalk account.
As soon as a count of 20 is reached, a notification is sent out to remind you that cleaning is in order.
A pushbutton on the device allows you to reset the count when cleaning is done.
This can also be seen as validation that the cleaning crew has actually visited the facility.
Basic knowledge about how to work with a SODAQ Mbili is a must, if you’ve never used one before we suggest you take a look at the quick start page first!
Before we can hook up the screw terminal with the magnetic door switch, we need to add a resistor. This is to prevent the values to jitter
when the door is open. In electronics this is know as a pull down resistor. The image below shows us how to connect the door switch.
For more information on the Sodaq Mbili and connector pin numbers, please check this page.
Now it’s time to upload the sketch to our device. Open the Arduino IDE.
countVisits.ino
file from the /ATT_LoRa_IOT/examples/experiments/countVisits
folder. This should open the countVisits.ino
sketch as well as an empty keys.h
fileuint8_t DEV_ADDR[4] = {};
uint8_t APPSKEY[16] = {};
uint8_t NWKSKEY[16] = {};
Next we will add our device keys to this keys.h
file.
Get your device keys from AllThingsTalk
Add these keys to the keys.h
file of your sketch.
These keys however are unique for your device, meaning the
keys.h
file will be the same for all projects. You can copy it to your harddisk once and copy it from there to your project folder each time.
When your keys are set, it’s time to test.
You can now watch the values change in AllThingsTalk Maker
Alternatively, you can open the Tools > Serial monitor of the Arduino IDE.
- 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
We want to get notified with the visit count:
For a simple rule like this, we can use the rules wizard.
Time to create our rule!
The name of your device upon creation is LoRa prototype.
That’s it! When your asset receives a count above 20, you now will get notified!
The count only resets when the button is pushed, meaning cleaning is done.
To visualise our date, we will create a pinboard. For more information on pinboards, please check how to use pinboards.
Now we will pin a control (visual representation) for our Integer Sensor asset to visualise the amount of visits.
You can pin the same asset multiple times. Pinning the asset to visualise it both as a historical chart and a label may give you an even better look!