wifi module working
wifi module working
This project requires an Arduino (Uno/Nano/ESP8266/ESP32) to communicate with a web page via Wi-
Fi and control 3 output pins based on the selection made on the web interface.
📜 Project Overview
1. ESP8266/ESP32 is used as a Wi-Fi module to host a web server.
2. The web page displays a menu with options: Tea, Potato, Capsicum, Tomato.
3. When a user selects an option on the webpage, the Arduino sets 3 output pins accordingly.
4. The ESP8266/ESP32 receives the selection and controls the Arduino's output pins.
📡 Required Components
Component Quantity
ESP8266/ESP32 1
Arduino Uno/Nano 1
3 Resistors (220Ω) 3
🔌 Circuit Connections
1. Connecting ESP8266 to Arduino
VCC 3.3V
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 1/10
3/26/25, 2:38 AM Code Debugging and Fixes
GND GND
RX TX
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 2/10
3/26/25, 2:38 AM Code Debugging and Fixes
OUTPUT); digitalWrite(OUT1, LOW); digitalWrite(OUT2, LOW); digitalWrite(OUT3, LOW); //
Define the web page server.on("/", HTTP_GET, []() { server.send(200, "text/html", "
<h2>Choose an Option:</h2>" "<a href='/tea'><button>Tea</button></a> " "<a href='/potato'>
<button>Potato</button></a> " "<a href='/capsicum'><button>Capsicum</button></a> " "<a
href='/tomato'><button>Tomato</button></a> " ); }); // Define different button responses
server.on("/tea", HTTP_GET, []() { digitalWrite(OUT1, LOW); digitalWrite(OUT2, LOW);
digitalWrite(OUT3, HIGH); server.send(200, "text/html", "Tea selected. <a
href='/'>Back</a>"); }); server.on("/potato", HTTP_GET, []() { digitalWrite(OUT1, LOW);
digitalWrite(OUT2, HIGH); digitalWrite(OUT3, LOW); server.send(200, "text/html", "Potato
selected. <a href='/'>Back</a>"); }); server.on("/capsicum", HTTP_GET, []() {
digitalWrite(OUT1, LOW); digitalWrite(OUT2, HIGH); digitalWrite(OUT3, HIGH);
server.send(200, "text/html", "Capsicum selected. <a href='/'>Back</a>"); });
server.on("/tomato", HTTP_GET, []() { digitalWrite(OUT1, HIGH); digitalWrite(OUT2, LOW);
digitalWrite(OUT3, LOW); server.send(200, "text/html", "Tomato selected. <a
href='/'>Back</a>"); }); server.begin(); Serial.println("Web Server started..."); } void
loop() { server.handleClient(); }
📌 Explanation of Code
1. ESP8266 connects to Wi-Fi and starts a web server.
2. The web page displays buttons for Tea, Potato, Capsicum, Tomato.
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 3/10
3/26/25, 2:38 AM Code Debugging and Fixes
http://<ESP8266_IP>
🎯 Expected Output
Option Selected Output Pin 4 Output Pin 5 Output Pin 6
Tea 0 0 1
Potato 0 1 0
Capsicum 0 1 1
Tomato 1 0 0
📌 Additional Features
Control appliances (relay module) instead of LEDs.
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 4/10
3/26/25, 2:38 AM Code Debugging and Fixes
✅ Final Notes
✔ ESP8266/ESP32 hosts a web server.
✔ Arduino controls 3 output pins based on user selection.
✔ Works via any phone or computer browser.
✔ Scalable for IoT applications.
🚀 Now, build your own Wi-Fi-controlled automation system!
Let me know if you need any modifications. 😊
🛠 Required Components
1. ESP8266 Wi-Fi Module
2. Arduino Uno/Nano/Mega
4. Jumper Wires
5. Breadboard
🔌 Connection Diagram
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 5/10
3/26/25, 2:38 AM Code Debugging and Fixes
TX (GPIO1) Arduino RX (Pin 2 via 1KΩ/2KΩ divider) Serial communication (ESP8266 TX → Arduino RX)
GPIO0 Not connected Used for programming (set LOW for flashing)
⚠️ Important Notes:
Do not connect ESP8266 RX directly to Arduino TX (5V) → Use a voltage divider (1KΩ/2KΩ
resistors).
const char* ssid = "Your_SSID"; // Your Wi-Fi Name (e.g., "Home_WiFi") const char* password
= "Your_PASSWORD"; // Your Wi-Fi Password (e.g., "12345678")
Example:
const char* ssid = "MyHomeWiFi"; // Example Wi-Fi name const char* password =
"MySecret123"; // Example Wi-Fi password
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 6/10
3/26/25, 2:38 AM Code Debugging and Fixes
Connecting to MyHomeWiFi...
Connected to WiFi!
IP Address: 192.168.1.100
Find Connected Devices → Look for "ESP8266" or the MAC Address of your module.
Type:
ping 192.168.1.100
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 7/10
3/26/25, 2:38 AM Code Debugging and Fixes
✅ Summary
✔ ESP8266 connects to Arduino via TX/RX with voltage divider.
✔ your_SSID = Wi-Fi name, your_PASSWORD = Wi-Fi password.
✔ ESP8266 IP is shown in Serial Monitor after connection.
🚀 Now, you can access ESP8266's web server by typing its IP address in your phone or PC browser.
Let me know if you need further assistance! 😊
To open the Serial Monitor at 115200 baud rate in the Arduino IDE, follow these steps:
Click the Upload (→) button to load the code onto the Arduino.
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 8/10
3/26/25, 2:38 AM Code Debugging and Fixes
Connecting to MyHomeWiFi...
Connected to WiFi!
ESP8266 IP Address: 192.168.1.100
Now, copy the IP address and enter it in a web browser to access the ESP8266 web interface.
⚠️ Troubleshooting
❌ No Output in Serial Monitor?
1. Wrong Port Selected?
Ensure the Serial Monitor baud rate is set to 115200 (not 9600).
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 9/10
3/26/25, 2:38 AM Code Debugging and Fixes
✅ Summary
✔ Connect Arduino to PC
✔ Open Arduino IDE > Tools > Serial Monitor
✔ Set Baud Rate = 115200
✔ Check for Wi-Fi connection and IP address
Now, you can monitor ESP8266 activity and debug easily! 🚀😊
Let me know if you need further help!
https://chatgpt.com/c/67dfe9a0-6f2c-8002-b58e-0ad1829d0ea3 10/10