IOT based Car Parking System application designing and nodemcu esp8266 programming
Description:
IOT based Car Parking-In this tutorial, you will learn how to use the Arduino, Nodemcu esp8266 wifi module and Blynk software to build an IOT-based Car Parking Slots monitoring system. The parking slots can be tracked from anywhere in the world using the Nodemcu esp8266 wifi module and Blynk software. In this task, in the Blynk program, we will also learn how to use the tabs and led widgets.
The parking space is split into two parking spaces.
- Parking 1
- Parking 2
Each parking space is equipped with 3 slots and each slot has one detector. So we have 6 infrared sensors in all. The presence of the car in the slot is detected by each infrared sensor. These sensors are mounted to the Arduino.So when a car is parked in the slot, the infrared sensor is triggered and the command is sent to the wifi module nodemcu esp8226, Nodemcu sends the command to the Blynk request.
The Amazon Purchase links :
Super Starter kit for Beginners:Â
DISCLAIMER:
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
About the IR sensor Module:
I use this IR detector for car detection. As you can see, the VCC, GND, and OUT are clearly labelled with the three male headers. The 5 volt pin of Arduino is attached to the Vcc. The field is connected to the ground of Arduino. While the OUT pin is connected to the IO pins of Arduino. What I’m going to explain in the diagram. In IR there are two black and white LEDs, one for tx and the other for RX.
About the Nodemcu ESP8266 WIFI Module:
Nodemcu ESP8266 wifi unit, we can track the parking slots from anywhere in the world from this module. As you can see from the pic above, all the pins are clearly labeled. Never use 5 volts of the Arduino to power the Nodemcu esp8266 wifi module. If you use the 5 volt Arduino to power up this module, we will continue to reset this wifi device. To solve this problem, you can use the LM7805 voltage regulator to design a separate power supply for this module.
Circuit Diagram:
Six infrared sensors are used as you can see all Arduino pins 4 to 9 attached sensors. The VCC pins of the infrared sensor are attached to the 5v of the Arduino. Grounds are attached to the ground of the Arduino while pin 4 to 9 connects the out pins of all the infrared sensors.
The tx and Rx pins of the Nodemcu module are connected to Arduino’s pin2 and pin3. The voltage controller output is connected to the 5v nodemcu Vin pin power supply based on the lm7805 voltage controller and tw0 470uf capacitors are attached to the controller output and input. In series, a 330ohm resistor is connected to a 2.5v led. This is a resistor that is currently limited. Although J1 is a female dc socket,
you can attach a 12v adapter or battery to the nodemcu module for power-up with your laptop or USB device I’m going to use two USB cables, I’m going to use the cable to power the Arduino, and the other USB cable to power the nodemcu.
IoT based Car Parking Blynk Application:
You will need to download the Blynk software from the App Store for the development of the android or apple cell phone app. Upon installing the Blynk software, you will need to use Facebook or any other email ID to register for free.
IoT based Car Parking Programming:
Two programs are used in this tutorial for the Arduino and another for the wifi unit Nodemcu esp8266.
Arduino Programming:
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#include <SoftwareSerial.h> SoftwareSerial nodemcu(2,3); int parking1_slot1_ir_s = 4; // parking slot1 infrared sensor connected with pin number 4 of arduino int parking1_slot2_ir_s = 5; int parking1_slot3_ir_s = 6; int parking2_slot1_ir_s = 7; int parking2_slot2_ir_s = 8; int parking2_slot3_ir_s = 9; String sensor1; String sensor2; String sensor3; String sensor4; String sensor5; String sensor6; String cdata =""; // complete data, consisting of sensors values void setup() { Serial.begin(9600); nodemcu.begin(9600); pinMode(parking1_slot1_ir_s, INPUT); pinMode(parking1_slot2_ir_s, INPUT); pinMode(parking1_slot3_ir_s, INPUT); pinMode(parking2_slot1_ir_s, INPUT); pinMode(parking2_slot2_ir_s, INPUT); pinMode(parking2_slot3_ir_s, INPUT); } void loop() { p1slot1(); p1slot2(); p1slot3(); p2slot1(); p2slot2(); p2slot3(); cdata = cdata + sensor1 +"," + sensor2 + ","+ sensor3 +","+ sensor4 + "," + sensor5 + "," + sensor6 +","; // comma will be used a delimeter Serial.println(cdata); nodemcu.println(cdata); delay(6000); // 100 milli seconds cdata = ""; digitalWrite(parking1_slot1_ir_s, HIGH); digitalWrite(parking1_slot2_ir_s, HIGH); digitalWrite(parking1_slot3_ir_s, HIGH); digitalWrite(parking2_slot1_ir_s, HIGH); digitalWrite(parking2_slot2_ir_s, HIGH); digitalWrite(parking2_slot3_ir_s, HIGH); } void p1slot1() // parkng 1 slot1 { if( digitalRead(parking1_slot1_ir_s) == LOW) { sensor1 = "255"; delay(200); } if( digitalRead(parking1_slot1_ir_s) == HIGH) { sensor1 = "0"; delay(200); } } void p1slot2() // parking 1 slot2 { if( digitalRead(parking1_slot2_ir_s) == LOW) { sensor2 = "255"; delay(200); } if( digitalRead(parking1_slot2_ir_s) == HIGH) { sensor2 = "0"; delay(200); } } void p1slot3() // parking 1 slot3 { if( digitalRead(parking1_slot3_ir_s) == LOW) { sensor3 = "255"; delay(200); } if( digitalRead(parking1_slot3_ir_s) == HIGH) { sensor3 = "0"; delay(200); } } // now for parking 2 void p2slot1() // parking 1 slot3 { if( digitalRead(parking2_slot1_ir_s) == LOW) { sensor4 = "255"; delay(200); } if( digitalRead(parking2_slot1_ir_s) == HIGH) { sensor4 = "0"; delay(200); } } void p2slot2() // parking 1 slot3 { if( digitalRead(parking2_slot2_ir_s) == LOW) { sensor5 = "255"; delay(200); } if( digitalRead(parking2_slot2_ir_s) == HIGH) { sensor5 = "0"; delay(200); } } void p2slot3() // parking 1 slot3 { if( digitalRead(parking2_slot3_ir_s) == LOW) { sensor6 = "255"; delay(200); } if( digitalRead(parking2_slot3_ir_s) == HIGH) { sensor6 = "0"; delay(200); } } |
IoT based Car Parking Nodemcu esp8266 wifi module Programming:
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <SoftwareSerial.h> #include <SimpleTimer.h> char auth[] = "ac173b0527c94a91a6cde0dcdfe6bdef"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "ZONG MBB-E8231-6E63"; char pass[] = "08659650"; SimpleTimer timer; String myString; // complete message from arduino, which consistors of snesors data char rdata; // received charactors int firstVal, secondVal,thirdVal; // sensors int led1,led2,led3,led4,led5,led6; // This function sends Arduino's up time every second to Virtual Pin (1). // In the app, Widget's reading frequency should be set to PUSH. This means // that you define how often to send data to Blynk App. void myTimerEvent() { // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V1, millis() / 1000); } void setup() { // Debug console Serial.begin(9600); Blynk.begin(auth, ssid, pass); timer.setInterval(1000L,sensorvalue1); timer.setInterval(1000L,sensorvalue2); timer.setInterval(1000L,sensorvalue3); timer.setInterval(1000L,sensorvalue4); timer.setInterval(1000L,sensorvalue5); timer.setInterval(1000L,sensorvalue6); } void loop() { if (Serial.available() == 0 ) { Blynk.run(); timer.run(); // Initiates BlynkTimer } if (Serial.available() > 0 ) { rdata = Serial.read(); myString = myString+ rdata; // Serial.print(rdata); if( rdata == '\n') { Serial.println(myString); // Serial.println("fahad"); // new code String l = getValue(myString, ',', 0); String m = getValue(myString, ',', 1); String n = getValue(myString, ',', 2); String o = getValue(myString, ',', 3); String p = getValue(myString, ',', 4); String q = getValue(myString, ',', 5); // these leds represents the leds used in Blynk application led1 = l.toInt(); led2 = m.toInt(); led3 = n.toInt(); led4 = o.toInt(); led5 = p.toInt(); led6 = q.toInt(); myString = ""; // end new code } } } void sensorvalue1() { int sdata = led1; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V10, sdata); } void sensorvalue2() { int sdata = led2; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V11, sdata); } void sensorvalue3() { int sdata = led3; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V12, sdata); } void sensorvalue4() { int sdata = led4; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V13, sdata); } void sensorvalue5() { int sdata = led5; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V14, sdata); } void sensorvalue6() { int sdata = led6; // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V15, sdata); } String getValue(String data, char separator, int index) { int found = 0; int strIndex[] = { 0, -1 }; int maxIndex = data.length() - 1; for (int i = 0; i <= maxIndex && found <= index; i++) { if (data.charAt(i) == separator || i == maxIndex) { found++; strIndex[0] = strIndex[1] + 1; strIndex[1] = (i == maxIndex) ? i+1 : i; } } return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; } |
Watch Video Tutorial
Hello Sir Can you please add to the circuit an entry gate and exit gate (using IR sensors and servo motor) it is very helpful thank you. if you added i would really appreciate it