Yarana Iot Guru
Published © MIT

Introducing Arduino Nano ESP32 With WiFi & Bluetooth

The Arduino Nano ESP32 is a miniature, powerful microcontroller with built-in Wi-Fi and Bluetooth, ideal for IoT, home automation, and wirel

BeginnerFull instructions provided8 hours748
Introducing Arduino Nano ESP32 With WiFi & Bluetooth

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

💻 Example Project — Control LED via Wi-Fi

C/C++
#include <WiFi.h>

const char* ssid = "YourWiFi";
const char* password = "YourPassword";

WiFiServer server(80);
const int ledPin = 2;

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

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

  Serial.println("\nConnected to WiFi!");
  Serial.println(WiFi.localIP());
  server.begin();
}

void loop() {
  WiFiClient client = server.available();
  if (!client) return;

  String request = client.readStringUntil('\r');
  client.flush();

  if (request.indexOf("/LED=ON") != -1) digitalWrite(ledPin, HIGH);
  if (request.indexOf("/LED=OFF") != -1) digitalWrite(ledPin, LOW);

  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println();
  client.println("<h1>Arduino Nano ESP32 Wi-Fi Control</h1>");
  client.println("<a href=\"/LED=ON\">Turn ON</a><br>");
  client.println("<a href=\"/LED=OFF\">Turn OFF</a>");
  client.println();
}

Credits

Yarana Iot Guru
35 projects • 0 followers
Yarana Iot Guru Yarana IoT Guru: Arduino, ESP32, GSM, NodeMCU & more. Projects, Tutorials & App Development. Innovate with us!
Thanks to YaranaIoT Guru.

Comments