ESP8266 Course

Build WiFi, IoT, and web server projects using NodeMCU or Wemos D1 Mini.

Lesson 1: ESP8266 Basics

ESP8266 is a WiFi microcontroller. It is perfect for IoT projects like smart home control, web dashboards, weather stations, and sensor alerts.

Lesson 2: Board Setup

  1. Install Arduino IDE.
  2. Add ESP8266 board package URL in preferences.
  3. Install ESP8266 boards from Boards Manager.
  4. Select NodeMCU 1.0 or your exact board.
If upload fails, hold FLASH while upload starts, check cable, and select the correct COM port.

Lesson 3: Connect To WiFi

#include <ESP8266WiFi.h>

const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";

void setup() {
 Serial.begin(115200);
 WiFi.begin(ssid, password);

 while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
 }

 Serial.println();
 Serial.print("IP Address: ");
 Serial.println(WiFi.localIP());
}

void loop() {
}

WiFi Problem Checklist

Lesson 4: Web Server LED Control

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);
const int ledPin = D4;

void handleRoot() {
 server.send(200, "text/html",
  "<h1>ESP8266 LED</h1><a href='/on'>ON</a> <a href='/off'>OFF</a>");
}

void setup() {
 pinMode(ledPin, OUTPUT);
 WiFi.begin("YOUR_WIFI_NAME", "YOUR_WIFI_PASSWORD");
 while (WiFi.status() != WL_CONNECTED) delay(500);

 server.on("/", handleRoot);
 server.on("/on", [](){ digitalWrite(ledPin, LOW); server.send(200, "text/plain", "LED ON"); });
 server.on("/off", [](){ digitalWrite(ledPin, HIGH); server.send(200, "text/plain", "LED OFF"); });
 server.begin();
}

void loop() {
 server.handleClient();
}

Lesson 5: Sensor Dashboard

Connect a DHT11/DHT22 or analog sensor and display values on a web page. Start by printing sensor values in Serial Monitor, then add WiFi.

Final Project: IoT Room Monitor

Create a room monitor that shows temperature, humidity, or gas sensor status on a local web page.