Skip to content

Wi-Fi Documentation

Introduction

Wi-Fi is a wireless networking technology that allows devices to connect to a local area network (LAN) and the internet. In embedded systems, Wi-Fi enables microcontrollers to send and receive data over TCP/IP or UDP, communicate with other devices, and connect to cloud services.

Wi-Fi is commonly used for telemetry, remote control, and IoT applications.

How It Works

  • Radio waves: Wi-Fi operates in 2.4 GHz and 5 GHz bands.
  • Network types: Infrastructure mode (connects to router) or SoftAP/Peer-to-Peer mode.
  • Protocols: TCP/IP and UDP for communication; HTTP, MQTT, and WebSockets for higher-level protocols.
  • Security: WPA/WPA2 encryption ensures secure communication.

Diagram – Basic Wi-Fi Communication

[ESP32 / STM32] <--Wi-Fi--> [Router / PC / Cloud]

Use Cases

  • Telemetry from drones or robots to ground stations
  • Remote control of devices via smartphone or web app
  • IoT applications sending sensor data to cloud
  • Communication between multiple embedded devices over a LAN

Common Pitfalls / Gotchas

  • Signal range: Wi-Fi range is limited; walls and interference reduce coverage.
  • Network congestion: Too many devices can affect throughput.
  • IP addressing: Conflicts or DHCP issues can prevent connections.
  • Power consumption: Wi-Fi can be high power; manage sleep modes in battery-powered devices.

Tools to Debug

  • Wi-Fi scanning apps to check signal strength
  • Serial monitor for debugging connection attempts
  • Network analyzers like Wireshark for packet inspection

References

Onboarding Tutorial (ESP32)

Goal: Connect an ESP32 to a Wi-Fi network and send a simple HTTP request.

Materials

  • ESP32 development board
  • Wi-Fi network credentials
  • Arduino IDE or PlatformIO

Steps

  1. Connect the ESP32 to your PC and open Arduino IDE.
  2. Flash the ESP32 with the following example code.
  3. Monitor the serial output to confirm Wi-Fi connection and server response.
#include <WiFi.h>
#include <HTTPClient.h>

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

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nConnected to Wi-Fi");
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    http.begin("http://example.com");
    int httpCode = http.GET();
    if (httpCode > 0) {
      String payload = http.getString();
      Serial.println(payload);
    }
    http.end();
  }
  delay(5000);
}

Mini Challenges

  • Connect the ESP32 to a different Wi-Fi network dynamically.
  • Send sensor data to a cloud service (e.g., ThingSpeak, Adafruit IO).
  • Implement a simple web server on the ESP32 that displays real-time sensor readings.