Do you want to get notified when someone is moving things precious to you? This example shows how a LoRa™ device can be used to detect unexpected movement of an object and send out notifications to its owner.
Furthermore, it shows how you can track the object using its GEO location.
Make sure you have good GPS coverage. Indoors can be a problem in certain cases.
If you did the basic example on the previous page, your device is already created and ready for use.
If not, please check the create a device section.
guard-your-stuff
example sketchguard-your-stuff
example sketchlorawan-rdk-payload-definition.json
in the textarea. You find this file in the examples/binary-payload folder of the arduino-lorawan-rdkEnter your device keys similar to how we did in our basic example.
Simply hit the upload icon in the Arduino IDE. This will save the sketch, compile it and upload it to your Arduino.
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.
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 when we have the lock turned on and our device is moving. Our rule will have to look like this:
For our specific experiment and assets
We will use the json editor to write this complex rule
To set up a complex rule, we need to enter the json rule editor.
A skeleton for a basic When-then rule is set by default. You will see each part (equation) contains 3 fields:
left
the lefthand side of the equation containing the asset detailsop
the operator usedright
the righthand side of the equation containing a certain valueThe first condition of our rule does not need a left, op and right part in our json as it triggers on any change. The second condition should only trigger when the lock is set to true so we do need to specify this condition.
For our rule, start by replacing the entire JSON RULE DEFINITION with the one below.
[
{
"when": [
{
"device": "LoRa_Device_id",
"service": "asset",
"sensor": "LoRa_Binary_Asset_id"
},
{
"and": {
"left": {
"device": "LoRa_Device_id",
"service": "asset",
"sensor": "Virtual_lock_Asset"
},
"op": "==",
"right": true
}
}
]
},
{
"then": [
{
"left": {
"service": "notify",
"actuator": "user//push,web"
},
"op": "=",
"right": "Someone is tampering with your lock"
}
]
}
]
Don’t forget to give your rule a name on top!
Fill in the device id
and asset id
for both the Binary Asset and Virtual lock Asset.
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 each of our assets (Binary Sensor, GPS and our virtual lock).
On-Off
for the Binary Sensor assetLock/Unlock
for the virtual lock assetmap
for the GPS assetRepeat this for each of our assets. You can also edit the size of your controls and set some other options, for example the default zoomlevel of the map.