In this tutorial we will create device that will send actual status of a parking space to Twitter. Simply, if the parking space is in use, the device will inform you about this via Sigfox on Twitter. If the parking space is free, the device will inform you about this status as well. This device is suitable for indoor garages, e.g. underground parking spaces, due to use of LDR (indoor light stays the same).
2. Microcontroller, IoT Network, and Platforms UsedWe will use Arduino MKR FOX 1200 microcontroller. It has the Sigfox (IoT network) connectivity. Briefly, Sigfox is LPWAN network that allows you to connect anything to the Internet. The network works ins ISM band 868 MHz (in Europe) and allows us to send 140 messages (12 bytes of payload each) daily uplink.
ThingSpeak:
ThingSpeak is an IoT platform for the user-friendly display of data. We use this as a callback destination, that allows send us message directly to Twitter.
Twitter:
I do not think I need to explain what Twitter is. :-)
3. Practical Stuff- Connect all listed parts as shown in the wiring diagram. In case anything is unclear, feel free to ask.
- Arduino Code. You can find the Code attached on the bottom of this page.
- Create ThingSpeak Channel. Register on https://thingspeak.com/ and create channel by giving it name, description and Field 1 - Occupied.
- Link Twitter Account. Go to Apps/All apps/Actions/ThingTweet and click on Link Twitter Account. (Note,you need to be signed in to a Twitter).
- Create React App. Under Actions go to React - New React and create React 1 as on Fig. React 1. Click Save React and create React 2 as on Fig. React 2. We need these React apps to tak an action as soon as data comes to ThingSpeak from Sigfox backend. You can see that tweet obtains %%datetime%%. It is used for attaching timestamp - so we can see what time was/was not there a free parking space. It is also used to tweet multiple times same tweet - Twitter would not allow us to tweet these same two tweets multiple times, but because the time raises up, the tweet is always different.
- Create Sigfox Callback. Go to https://backend.sigfox.com/ Now head to callbacks section and create one as following:
- TYPE: DATA UPLINK
- CHANNEL: URL
- CUSTOM PAYLOAD CONFIG: status::uint:8:little-endian
- URL PATTERN:
https://api.thingspeak.com/update?api_key=
EXPLAINED1
&field1={customData#status}
- USE HTTP METHOD: GET
*EXPLAINED1- replace this with Channel ThingSpeak WriteApiKey
4. Device SetupNow that everything is almost done, you are just one step from the finish line. Power your device, e.g. with USB power bank. Double press the device button to start calibration. In case there is a free parking space, turn the potentiometer to light up LED. Try to cover LDR - the LED should not light. This means you succesfully calibrated the device. Now press the button one more time and you can already see your first message on Twitter. The device now works properly.
To see the actual parking space status, head to your Twitter account. You will see either message on Fig. Tweet 1 or Fig. Tweet 2.
Comments