In this example I integrate a Particle Photon device with an IR motion sensor and a temperature sensor. Whenever a motion (e.g. an intruder) is detected it sends an alert to a SIGNL4 team.
This is a prototype and you can adapt is to meet various other use cases. For example if you have distributed sensors in the field you can inform service workers or farmers about temperature changes, humidity, rain, etc.
Here is how it goes.
1. Assemble the DeviceIn our case we use the Particle Maker Kit with a Photon device to connect an IR motion sensor ans a temperature sensor. We also use an LED to indicate the motion detection directly on the device.
You can see the assembled device on the image above. You can find a good description on how to connect the sensors here: https://docs.particle.io/tutorials/hardware-projects/maker-kit.
2. Connect the DeviceNow you can connect your device to the Particle IoT platform. This is easily done by using the Particle app. You can find a full description here: https://docs.particle.io/quickstart/photon.
Now you can see your new device in the Particle Console under Devices: https://console.particle.io/devices.
In the Particle Console under Integrations (https://console.particle.io/integrations) you can now create a new Webhook in order to send alerts to SIGNL4.
You can create a new Webhook and then use the SIGNL4 webhook URL.
The {team-secret} ist your SIGNL4 team secret.
Under Custom Template you can insert your JSON data template as to be sent to SIGNL4.
{“event”: “photon-motion”,“deviceID”: “37002a000847373336323230”,“url”: “https://connect.signl4.com/webhook/96sbq38s”,“requestType”: “POST”,“noDefaults”: true,“rejectUnauthorized”: true,“json”: {“subject”: “{{{subject}}}”,“temperature”: “{{{temperature}}}”}}
You can now go to the Web IDE at https://build.particle.io/build to deploy the code to your device(s).
The two main lines to send the SIGNL4 alert are the following.
String data = “{ “subject”: “Motion detected.”, “temperature”: “” + temperature() + “” }”;
Particle.publish(“photon-motion”, data, 60, PUBLIC);
First, we assemble the date to become part of the webhook JSON data. And second, we send the date to the “photon-motion” Webhook we have created above.
5. Test ItThis is it. You can now test your IoT scenario by simulating a motion. You will then receive an alert in your SIGNL4 app.
You can find a sample in GitHub:https://github.com/signl4/signl4-integration-particle
Comments
Please log in or sign up to comment.