Check out my two YouTube channels for more content:
- Mrzaizai2k - AI (NEW)
- Mrzaizai2k (Old)
This project demonstrates controlling an LED using an Android app via Wi-Fi, connecting a NodeMCU and Arduino Uno, and sending data back to the app. Watch the video below for a detailed explanation:
- References:
- How to Build a Custom Android App for Your Arduino Project Using MIT App Inventor
- MIT App Inventor
- SoftwareSerial Communication Between Arduino Uno and NodeMCU
- Remote-Controlled Car Project via Internet with iNut Sensor
- MIT App Inventor 2 - NodeMCU Wi-Fi Car Control App
- NodeMCU Server | Control via Web Browser | RoboShala Hindi
- Ledon_Uno
1.1 Overview
1.2 How It Works - Ledonwifi
2.1 Overview
2.2 How It Works
The Ledon_Uno
Arduino sketch integrates an ultrasonic sensor (HC-SR04) and an LED controlled by an Arduino Uno. It communicates with a NodeMCU (ESP8266) via SoftwareSerial. The ultrasonic sensor measures distance, and the LED is controlled based on commands received from the Ledonwifi
sketch.
-
Setup:
- The HC-SR04 ultrasonic sensor is connected to pins 8 (trig) and 7 (echo).
- An LED is connected to pin 12.
- SoftwareSerial communication is established between Arduino Uno and NodeMCU on pins 3 (RX) and 2 (TX).
- OpenAI API credentials are configured (if applicable).
-
Distance Measurement:
- The
distance()
function uses the HC-SR04 sensor to measure the distance in centimeters.
- The
-
Communication with NodeMCU:
- The Arduino Uno sends distance data to the NodeMCU via SoftwareSerial.
- The NodeMCU processes this data and sends LED control commands back.
-
Data Transmission:
- The Arduino Uno continuously measures and transmits distance data to the NodeMCU.
- The NodeMCU toggles the LED on or off based on commands from
Ledonwifi
.
The Ledonwifi
sketch runs on a NodeMCU (ESP8266) and acts as a web server. It receives HTTP requests to control the LED on Ledon_Uno
and retrieves distance information from the Arduino Uno.
-
Setup:
- The NodeMCU connects to a Wi-Fi network.
- A web server is initialized on the NodeMCU.
-
LED Control:
- HTTP requests like "LEDon" and "LEDoff" trigger the
LEDon()
andLEDoff()
functions. - These commands are sent to
Ledon_Uno
to control the LED.
- HTTP requests like "LEDon" and "LEDoff" trigger the
-
Distance Information:
- The "distance" command retrieves distance data from
Ledon_Uno
. - The data is returned to the client (e.g., a browser or app) making the HTTP request.
- The "distance" command retrieves distance data from
-
HTTP Server Handling:
- The server listens for client connections and responds to incoming requests.
Note: Ensure Wi-Fi credentials in Ledonwifi
match your network settings. Keep the OpenAI API key in Ledon_Uno
secure and avoid sharing it publicly.