In some places, authorities write illegal speeding tickets to increase revenue. With NodeMCU, a servo motor and your smartphone, you can fight back, Knight Rider style.
From the outside, nothing suspicious but a leave.
A closer inspection reveals SG90 servo motor
Inside the box: NodeMCU, a battery and battery charger
2 includes are required, ESP8266 for remote connection through Smartphone and servo motor
#include <ESP8266WiFi.h>
#include <Servo.h>
Setup
servo.attach(ServoMotorpin);
Serial.begin(115200);
pinMode(LED1, OUTPUT);
digitalWrite(LED1, LOW);
WiFi.softAP(ssid, password);
Serial.println();
Serial.print("Server IP address: ");
Serial.println(WiFi.softAPIP());
server.begin();
Code to move servo motor
if (header.indexOf("GET /LED1/on") >= 0) {
Serial.println("LED1 on");
LED1State = "on";
digitalWrite(LED1, HIGH);
} else if (header.indexOf("GET /LED1/off") >= 0) {
Serial.println("LED1 off");
LED1State = "off";
digitalWrite(LED1, LOW);
}
// Display the HTML web page
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
client.println("<style>html { font-family: Cairo; display: inline; margin: 0px auto; text-align: center; background-color: #AAAAAA;}");
client.println(".button { background-color: #CCCCCC; border: none; color: white; padding: 16px 40px;");
client.println("text-decoration: none; font-size: 35px; margin: 2px; cursor: pointer;}");
client.println(".button2 {background-color: #555555;}</style></head>");
//client.println("<svg width=\"300\" height=\"80\"><text fill=\"#00bfbf\" font-family=\"serif\" font-size=\"24\" id=\"svg_1\" stroke=\"#000000\" text-anchor=\"middle\" transform=\"matrix(1.35388 0 0 1.42308 -6.66283 -8.67308)\" x=\"86.5\" xml:space=\"preserve\" y=\"41.5\">Tapa Patente</text></svg>");
// Web Page Heading
client.println("<body><h1>Tapa Patente</h1>");
client.println("<p>Cubierto: " + LED1State + "</p>");
// If the LED1State is off, it displays the ON button
if (LED1State=="off") {
client.println("<p><a href=\"/LED1/on\"><button class=\"button\">ON</button></a></p>");
servo.write(0); //Moving servo to 0 degree
} else {
client.println("<p><a href=\"/LED1/off\"><button class=\"button button2\">OFF</button></a></p>");
servo.write(90);
}
How to connect with the SmartphoneAfter connecting to the NodeMCU WiFi Access Point, you can use a free App like IpScanner to check the IP assigned. Then you just load that IP with the phone browser and you will be able to manage the license plate cover. Here is 192.168.4.1
Complete.ino code can be downloaded for free with Kindle Unlimited: Fun Projects with Arduino #2
Comments