Project tutorial
Sigfox-Enabled Parking Lot

Sigfox-Enabled Parking Lot © GPL3+

Driving around the town, looking for free parking space, leaving carbon footprint? No longer an issue, simply check Twitter for a spot!

  • 1,296 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

1. Device Purpose

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 Used

We 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.

  • 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 Setup

Now 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.

5. Final Output

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.

Code

Sigfox enabled Parking LotArduino
This is .ino code for connecting your parking space to internet.
#include <SigFox.h>



int led = 5;
int ldr = A5;
int sread = 0;
uint8_t carstate = 1;
boolean changestate = true;
int BTN = 12;
int BTN_state = 0;
int BTN_prev = 0;
int BTN_NR_OF_PRESS = 0;

void setup() {
  SigFox.debug();
  Serial.begin(9600);
  pinMode(5, OUTPUT);
  pinMode(A5, INPUT);
  if (!SigFox.begin()) {
    Serial.println("Sigfox module unavailable.");
  }

}

void loop() {
  sread = analogRead(ldr);
  Serial.println(sread);

  BTN_state = digitalRead(BTN);

  if (BTN_state != BTN_prev) {
    if (BTN_state == HIGH) {
      BTN_NR_OF_PRESS++;
    }
  }

  BTN_prev = BTN_state;

  if (BTN_NR_OF_PRESS % 3 == 0) {

    if (sread > 900 && sread < 1023) {
      digitalWrite(led, HIGH);
    }
    else {
      digitalWrite(led, LOW);
    }
  }

  if (BTN_NR_OF_PRESS % 4 == 0) {
    digitalWrite(led, LOW);
  }

  if (sread > 900 && changestate == true && BTN_NR_OF_PRESS % 4 == 0)
  {
    // digitalWrite(5, HIGH);
    carstate = 1;

    SigFox.beginPacket();
    SigFox.write(carstate);
    SigFox.endPacket();

    changestate = false;
  }
  else if (sread < 900 && changestate == false && BTN_NR_OF_PRESS % 4 == 0) {
    //   digitalWrite(5, LOW);
    carstate = 2;

    SigFox.beginPacket();
    SigFox.write(carstate);
    SigFox.endPacket();

    changestate = true;

  }

  delay(100);

}

Schematics

Sigfox enabled Parking Lot
Schematic for connection.
Hackster schem erxq84hyes

Comments

Similar projects you might like

Sigfox kWh Meter

Project tutorial by jassak

  • 6,652 views
  • 8 comments
  • 15 respects

Fox Advisor

Project tutorial by Celia Garrido Hidalgo

  • 3,166 views
  • 2 comments
  • 12 respects

Squirrel Feeder Tweet

Project tutorial by 3magku

  • 1,204 views
  • 1 comment
  • 4 respects

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 49,024 views
  • 63 comments
  • 145 respects

How to Use Modbus with Arduino

Project tutorial by hwhardsoft

  • 5,345 views
  • 2 comments
  • 14 respects

The Welcome Gadget

Project tutorial by Kutluhan Aktar

  • 3,219 views
  • 1 comment
  • 10 respects
Add projectSign up / Login