I have an Arduino MKRFOX1200 board (check my previouse article on http://www.valeriovaccaro.it/wordpress/2017/05/mkrfox1200/) working with the testing firmware, so I can publish some messages on the net using SigFox protocol, now it’s time to check how to use this messages in an automatic way.
First idea is to have a Twitter account with all data from my sensors (useful for public data) in order to receive messages on mobile phone.
SigFox callback
Every time a message is received from the SigFox network one or more callbacks can be triggered in order to send an email or move some data performing a GET or a POST or a PUT request on specified URL.
You can easily add a callback on the SigFox developer website, on the Device Type tab.
Just configure the callback in this way:
- Channel – URL
- Url pattern – http://wpc.uk.to:1880/sigfox
- Use HTTP method – PUT
- Content type – application/json
- Body like in the following box.
1 2 3 4 5 6 7 8 9 |
{ "t" : "{time}", "d" : "{device}", "r" : "{rssi}", "s" : "{station}", "la" : "{lat}", "lo" : "{lng}", "p" : "{data}" } |
Confirm this configuration and you will have a callback for each received message.
Node-RED
How to receive the callback messages? The idea is to use Node-RED to receive the message, format it and write automatically on Twitter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
[{ "id": "ceca1859.0e9698", "type": "http in", "z": "b85defad.cad6b", "name": "", "url": "/sigfox", "method": "put", "swaggerDoc": "", "x": 1110, "y": 260, "wires": [ ["f86d97b6.b3b398", "9d0564f1.cfcf78"] ] }, { "id": "d68d8224.569bd", "type": "debug", "z": "b85defad.cad6b", "name": "", "active": true, "console": "false", "complete": "payload", "x": 1430, "y": 220, "wires": [] }, { "id": "f86d97b6.b3b398", "type": "http response", "z": "b85defad.cad6b", "name": "", "x": 1270, "y": 220, "wires": [] }, { "id": "74215902.4f85b8", "type": "twitter out", "z": "b85defad.cad6b", "twitter": "", "name": "Tweet", "x": 1410, "y": 260, "wires": [] }, { "id": "ca813ee.2ac84c", "type": "comment", "z": "b85defad.cad6b", "name": "SigFoxBot", "info": "http://wpc.uk.to:1880/sigfox\n\nPOST\n\n{\n“t” : “{time}”,\n“d” : “{device}”,\n“r” : “{rssi}”,,\n“s” : “{station}”,\n“la” : “{lat}”,\n“lo” : “{lng}”,\n“p” : “{data}”\n}", "x": 1100, "y": 220, "wires": [] }, { "id": "9d0564f1.cfcf78", "type": "json", "z": "b85defad.cad6b", "name": "", "x": 1270, "y": 260, "wires": [ ["74215902.4f85b8", "d68d8224.569bd"] ] }] |
Remember to configure the Twitter node and deploy.
The tweets can be red on the page of the box https://twitter.com/SigFoxBot.
You can try to send messages following this tutorial using my server for a fast test or proof of concept, please don’t abuse about it!