|
NodeMCU-8266Ai-Thinker
|
x 1 | |
|
servomotor |
x 1 | |
|
power source 5vDC |
x 1 | |
|
jumpers wire |
x 1 |
|
MIT App InventorMIT
|
|
|
arduino IDEArduino
|
Node MCU based Wi Fi Servo Switch- DIY
About:
Regulations usually forbide to introduce pieces of equipment in the conecctions and wiring of the houses; this is in order to avoid undesirable fire's source, so I believe in this way I can use an IOT without tresppasing any rule.
This quick project consist in to use a MG995 servo connected to a nodemcu with Wifi Modules esp8266mod, and with a HMI from an App.
The servo push on and off the switch button, connceted to a 5VDC. You do not need any wiring at 120V or 220V AC levels
You can add all the modules you need making difference in the ip address of your home wifi network connection.
App can be downloaded from my app inventor site on this link:
https://gallery.appinventor.mit.edu/?galleryid=f40acb1c-4a83-44f7-b9f5-833f31e646d6
Esp8266 modules working as AP, and run on your wifi network. The commandsare not reachable from other places, receive data from pushbutton and voice recognition.
#include <GDBStub.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <Servo.h>
Servo servo;
/*
* This sketch demonstrates how to set up a simple HTTP-like server.
* The server will set a GPIO pin depending on the request
* http://server_ip/gpi2/0 will set the GPIO2 low,
* http://server_ip/gpi2/1 will set the GPIO2 high
* server_ip is the IP address of the ESP8266 module, will be
* printed to Serial when the module is connected.
*/
// Updated: APRIL-30-2023 - to be used with SEERVO+ APP Inventor 2
#include <ESP8266WiFi.h>
const char* ssid = "here you wifi name";
const char* password = "here you wifi pwd";
// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
servo.attach(2); // nodemcu D4 pin
servo.write(58); // move to 0•
delay(15);
servo.write(0); // move to 0•
delay(15);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
// Match the request
int val1;
if (req.indexOf("/gpio2/0") != -1)
{val1 = 0;
//digitalWrite(0, val1); // Set GPIO2 according to the request
servo.write(val1); // move servo to 0•
delay(150);
Serial.println(val1);
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r GREEN SERVO on GPIO2 is now ";
s += (val1)?"high":"low";
// Send the response to the client
client.print(s);
delay(300);
client.flush();
Serial.println("Client disconnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
}
if (req.indexOf("/gpio2/1") != -1)
{val1 = 58;
servo.write(val1);// move servo to 58•
delay(150);
Serial.println(val1);
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\n GREEN SERVO on GPIO2 is now ";
s += (val1)?"high":"low";
// Send the response to the client
client.print(s);
delay(300);
client.flush();
Serial.println("Client disconnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
}
else {
Serial.println("invalid request");
client.stop();
return;
}
}
Node MCU based Wi Fi Servo Switch- DIY
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Bolaños Hernando
- How to built a Hybrid Bike Computer Hybrid Bike ComputerThis PCB is a Cheap solution to track your training preformanceBased o esp32 , r...
- PCB DESIGN FOR BIKE COMPUTER DIY PCB DESIGN FOR A BIKE COMPUTER DIY - QBIKOThis PCB was designed to run a BIke computer based on ESP3...
- How to build a Mecanum Wheels Robot with an Arduino Mega and a PCB StoryOnce I finished my first version of this robot I found it interesting to develop a PCB, mount a...
- How to build a Bike computer DIY-Heart Rate sensor comparison and selection This project is about a tutorial to evaluate 3 hear rate Sensor. In this way I will choose the bette...
- How to build a Bike computer with a ESP32 -WROOM + 2 Reed Switches + 1 Cellular Phone(old with GPS and BTH) The complete tutorial explaining all the details for this project, can be watched in the next vide...
- How to build a Table Tennis Robot - V2 Story: Once I finished my first protoype for a TTR , I recognize and learnt about a lot of improveme...
- How to build a Mecanum Wheels Robot_V1 The storyHow to bulild a Robot usually is an assay and error process, you can see my first prototype...
- How to use AI to program a 2DOF ROBOT- Arduino+ pyhton+opencv+chatgp+ps3eyecam The challenge was to obtanin a mix of code generated by chatgpt for pyhton, opencv, and arduino and ...
- Node MCU based Wi Fi Servo Switch- DIY About:Regulations usually forbide to introduce pieces of equipment in the conecctions and wiring of ...
- CNC_DIY_LASER_PLOTTER_VYNIL CUTTER ABOUT THIS PROJECTSummaryTo develop a CNC need you to learn about code, IT, electricity, electronics...
- Arduino Based Table Tennis Robot V1 DIY AboutThis project is about a TTR(Table Tennis Robot) made at home with cardboard and wood, using som...
- Robot Arm to implement CV projects StoryFour years ago I was looking for a good robot arm, this year I have time and decided to replica...
- MINI ROBOT ARM MINI ROBOT ARM - YouTubeIdea based on Tutorials shared by Mr. Pinaut for :software -schematics -inst...
- Bluetooth Controlled LEGO Toy Car MotivationMy motivation was my kids. I want to share time and have fun with them teaching them some ...
- Integrated HOME Irrigation System Motivation:Since I left the university, 24 years ago, I haven't had the chance to update my knowledg...
- Rubik's Cube Solver Robot DIY - V.3.0 Scope of the projectThe idea was to build a Rubik's cube solver robot, as simple as possible, easy t...
- Rubik's Cube Solver Robot v1 The drivers to develop my project were:Rubik′s cube is a "best seller" category toy, more than 350 m...
- WiFi ESP8266 and DHT22 Sensor I wanted to design a small weather station and use it for tracking for long periods of time the outd...
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
122 0 0 -
DIY Laser Power Meter with Arduino
172 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
162 0 2 -