Mecanum Wheel Robot Car Build: Omni-Directional Drive

Mecanum wheel robot car chassis with four omni wheels

Mecanum Wheel Robot Car Build: Omni-Directional Drive

Build a mecanum wheel robot car that drives forward, sideways, and diagonally without turning. Each wheel carries rollers set at 45 degrees, and the four wheels spin in matched patterns to strafe. The build uses two L298N drivers, one per wheel pair, because one L298N drives only two motors and a mecanum car has four.

Quick facts

Item Value
Chassis Mecanum 4WD chassis, aluminum alloy, 0.20 feet omni wheels
Drivers 2 x L298N, one per wheel pair
Motors 4 x TT gear motors, 3 to 6 V
Controller ESP32 DevKit V1, 3.3 V logic
Roller angle 45 degrees on each wheel
Moves Forward, back, strafe left, strafe right, rotate, diagonal

Mecanum wheel robot car: how does a wheel move sideways?

A mecanum wheel has small rollers around its rim, each set at 45 degrees to the wheel axle. When the wheel spins, the roller pushes the car partly forward and partly sideways. One wheel alone would slide diagonally, but four wheels in the right pattern cancel the unwanted parts.

For a strafe left, the front left and rear right wheels spin one way while the front right and rear left spin the other way. The forward parts cancel and the sideways parts add. The car slides left without turning. Reverse the pattern and it strafes right. That is the move a normal car cannot make.

Wheel orientation matters. The rollers on the front left and rear right wheels must angle one way, and the rollers on the front right and rear left must angle the other way, forming an X pattern when viewed from above. If one wheel is fitted backward, the car will crab and spin instead of strafing. Check the X before you wire anything.

Why does this build need two L298N drivers?

One L298N drives two DC motors. A mecanum car has four motors, so it needs two L298N modules. Each module drives one diagonal pair: the first drives the front left and rear right wheels, and the second drives the front right and rear left wheels. That pairing matches the strafe pattern and keeps the wiring tidy. Buy the 4WD Kit variant of the chassis kit: it ships with 4 TT gear motors and one L298N, so buy one more L298N for the second pair. The Plate Set variants ship with plates and wheels only, no motors or electronics. The 4WD Kit also includes a UNO R3 board and sensor shield; this build uses an ESP32 DevKit V1 in its place.

Each L298N needs its own enable and direction pins, so the build uses 12 control pins on the ESP32. The ESP32 DevKit V1 has enough GPIO pins for that, but a small board such as a SuperMini would not. Check the pinout post for your exact board before you substitute it.

Both L298N modules share one motor battery. Join the battery positive to both 12 V terminals and the battery negative to both grounds and to the ESP32 ground. Keep the 5 V jumper on at 6 V, and remove it above 12 V, on both modules.

How does the drive mix work?

The drive mix takes three inputs: forward speed, strafe speed, and rotation speed. Each wheel speed is a sum of those three with signs that depend on the wheel position. Front left equals forward plus strafe plus rotation. Front right equals forward minus strafe minus rotation. Rear left equals forward minus strafe plus rotation. Rear right equals forward plus strafe minus rotation.

The sketch below implements that mix for serial control. Type f for forward, s for strafe left, d for strafe right, l to rotate left, r to rotate right, and x to stop. Each key sets the four wheel speeds from the mix, clamps them to -255 to 255, and writes them to the two L298N modules.

Test the mix with the car lifted. Strafe left should spin the front left and rear right wheels one way and the other two the opposite way. If one wheel spins the wrong way, swap its two motor wires at its L298N output. Do not fix wheel direction in code, because the wiring is the fault.

What are the limits of a mecanum car?

Mecanum wheels slip more than normal wheels, because the rollers are always partly sliding. The car will not climb as well, will not push as hard, and will drift on smooth floors. It also draws more current, because two wheels fight each other in every strafe. Expect shorter battery life than a normal 4WD car on the same pack.

The rollers also wear faster than a solid tire, and they pick up grit. Keep the floor clean and the rollers free. A stuck roller turns a mecanum wheel into a bad normal wheel, and the car will crab instead of strafing.

For all that, the strafe is worth it on a bench or a small course. A mecanum car can slide sideways into a gap a normal car cannot reach, and it can rotate in place without a turning circle. That is why warehouse robots and camera dollies use the same wheel.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
Battery box positive Both L298N 12 V terminals Motor supply, 6 V from 4 AA cells
Battery box negative Both L298N GND and ESP32 GND Common ground for both drivers and the logic
L298N A OUT1, OUT2 Front left TT motor First module, left channel
L298N A OUT3, OUT4 Rear right TT motor First module, right channel
L298N B OUT1, OUT2 Front right TT motor Second module, left channel
L298N B OUT3, OUT4 Rear left TT motor Second module, right channel
ESP32 GPIO 25, 27, 14 L298N A ENA, IN1, IN2 Front left motor: PWM, direction A, direction B
ESP32 GPIO 26, 12, 13 L298N A ENB, IN3, IN4 Rear right motor: PWM, direction A, direction B; GPIO 12 is a strapping pin, keep low at boot
ESP32 GPIO 32, 33, 15 L298N B ENA, IN1, IN2 Front right motor: PWM, direction A, direction B
ESP32 GPIO 18, 19, 21 L298N B ENB, IN3, IN4 Rear left motor: PWM, direction A, direction B; GPIO 21 is also I2C SDA, so do not add I2C parts to this build
Both L298N 5 V pins Leave unconnected Jumpers fitted at 6 V; do not feed 5 V in as well
USB 5 V ESP32 USB port Logic supply only; motor current never passes through USB

Power budget

Four TT motors draw more than two. At full load the four motors together draw about 2 to 4 A from the 6 V pack, split across two L298N modules at about 1 to 2 A per module. Each L298N drops about 2 V, so each motor sees about 4 V. The heatsinks on both modules will get warm, so give them airflow.

The ESP32 runs from USB 5 V and draws about 80 to 160 mA. Each L298N logic side draws only a few milliamps from its onboard regulator. The motor battery and the logic supply share only a ground wire. Never power the motors from the ESP32 5 V pin.

A 4 AA alkaline pack sags under a 4 A load, so the car will slow during a strafe. A 5-cell NiMH pack (6 V) holds voltage better than alkalines under load. Do not use a 2-cell lithium pack here: 7.4 V nominal is above the TT motor 3 to 6 V rating. Size the pack for the stall total, not the cruise current.

Build steps

  1. Assemble the mecanum chassis. Fit the four wheels in the X roller pattern: front left and rear right angle one way, front right and rear left the other way.
  2. Mount the two L298N modules and the ESP32 on the top plate. Label the modules A and B before you wire them.
  3. Wire the motors to the L298N outputs from the wiring table. Wire both modules to the same battery and to the ESP32 ground.
  4. Remove all four enable jumpers. Wire the 12 control pins from the wiring table.
  5. Upload the sketch below to the ESP32 DevKit V1. Lift the car off the floor for the first test.
  6. Type f, s, d, l, and r in the serial monitor and confirm each wheel spins the right way for each move.
  7. Set the car on the floor and strafe left and right. If it crabs instead of strafing, one wheel is fitted backward or wired in reverse.

Code

Libraries: none beyond the ESP32 Arduino core. Board: ESP32 DevKit V1. Control from the serial monitor: f forward, b back, s strafe left, d strafe right, l rotate left, r rotate right, x stop.

// Mecanum wheel robot car: 4 motors, 2 x L298N, ESP32
// Board: ESP32 DevKit V1. No extra libraries needed.
// Module A drives front-left (FL) and rear-right (RR).
// Module B drives front-right (FR) and rear-left (RL).
struct MotorPins { int pwm, inA, inB; };
MotorPins FL = {25, 27, 14};  // Module A, channel 1
MotorPins RR = {26, 12, 13};  // Module A, channel 2
MotorPins FR = {32, 33, 15};  // Module B, channel 1
MotorPins RL = {18, 19, 21};  // Module B, channel 2

const int SPEED = 200;  // 0 to 255; TT motors stall below about 80

void driveMotor(MotorPins m, int speed) {
  if (speed >= 0) {
    digitalWrite(m.inA, HIGH);
    digitalWrite(m.inB, LOW);
    analogWrite(m.pwm, speed);
  } else {
    digitalWrite(m.inA, LOW);
    digitalWrite(m.inB, HIGH);
    analogWrite(m.pwm, -speed);
  }
}

void stopAll() {
  driveMotor(FL, 0); driveMotor(FR, 0);
  driveMotor(RL, 0); driveMotor(RR, 0);
}

// Mix: forward, strafe (right is positive), rotation (right is positive).
void mix(int fwd, int strafe, int rot) {
  int fl = constrain(fwd + strafe + rot, -255, 255);
  int fr = constrain(fwd - strafe - rot, -255, 255);
  int rl = constrain(fwd - strafe + rot, -255, 255);
  int rr = constrain(fwd + strafe - rot, -255, 255);
  driveMotor(FL, fl); driveMotor(FR, fr);
  driveMotor(RL, rl); driveMotor(RR, rr);
}

void setup() {
  Serial.begin(115200);
  MotorPins all[4] = {FL, FR, RL, RR};
  for (int i = 0; i < 4; i++) {
    pinMode(all[i].pwm, OUTPUT);
    pinMode(all[i].inA, OUTPUT);
    pinMode(all[i].inB, OUTPUT);
  }
  stopAll();
  Serial.println("Keys: f forward, b back, s strafe left, d strafe right,");
  Serial.println("l rotate left, r rotate right, x stop.");
}

void loop() {
  if (Serial.available() > 0) {
    char c = Serial.read();
    if (c == 'f') mix(SPEED, 0, 0);
    else if (c == 'b') mix(-SPEED, 0, 0);
    else if (c == 's') mix(0, -SPEED, 0);  // Strafe left
    else if (c == 'd') mix(0, SPEED, 0);   // Strafe right
    else if (c == 'l') mix(0, 0, -SPEED);  // Rotate left
    else if (c == 'r') mix(0, 0, SPEED);   // Rotate right
    else if (c == 'x') stopAll();
  }
}

Test and tune it

Lift the car and type s for strafe left. The front left and rear right wheels should spin one way, and the front right and rear left the opposite way. If one wheel is wrong, swap its two motor wires at its L298N output.

Set the car on a hard floor and strafe left 1 foot. The car should slide sideways without turning. If it rotates while strafing, one wheel is fitted backward. Check the X roller pattern from above.

Drive forward 3 feet and mark the end point. Then strafe back to the start. A mecanum car drifts more than a normal car, so expect about 0.25 feet of error. That drift is normal roller slip, not a code fault.

FAQ

Why does my mecanum car need two L298N drivers?

One L298N drives two motors, and a mecanum car has four. Two modules drive one diagonal pair each, which matches the strafe pattern and keeps the wiring tidy.

Why does my mecanum car crab instead of strafing?

One wheel is fitted backward or wired in reverse. Check the X roller pattern from above, then check that each wheel spins the right way for a strafe while the car is lifted.

Why does the car drift sideways when driving forward?

Mecanum rollers always slip a little, and uneven floors make it worse. Small drift is normal. Large drift means one wheel is slower, usually from a loose motor wire or a low battery.

Can I use one driver board with four channels instead?

Yes, if it supplies four independent channels at the motor current. Two L298N modules are the stocked route in this build. A single four-channel MOSFET board is a later upgrade, not a first build change.

How fast can a mecanum car strafe?

Slower than it drives forward, because two wheels fight each other in every strafe and the rollers slip. Keep strafe speed at or below forward speed, and expect shorter battery life than a normal 4WD car.

Parts used

Build it with the Mecanum Wheel 4WD Robot Car Chassis Kit, Aluminum Alloy, 60mm Omni Wheels in the 4WD Kit variant (Single or Double Layer) and one more L298N Dual H-Bridge Motor Driver Module for Arduino (the kit already includes one L298N; one L298N drives two motors, so a four-motor car needs two) and the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32 as the controller. The two-motor version is L298N Robot Car: Wire and Drive Two DC Motors, and the wireless version is ESP-NOW Joystick Robot Car: Two ESP32 Boards, No Router. For the driver comparison, see L298N vs TB6612 vs DRV8833: Which Motor Driver for Your Robot.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

Bluetooth Robot Car with ESP32 BLE and a Phone

Phone showing a BLE control app next to an ESP32 robot car

Bluetooth Robot Car with ESP32 BLE and a Phone

Control this Bluetooth robot car from your phone with the ESP32 native Bluetooth Low Energy radio. No HC-05 or HC-06 module is needed, because the ESP32 DevKit V1 already has BLE built in. The car runs a BLE server with one writable characteristic, the phone writes drive commands to it, and the car stops by itself when the phone disconnects.

Quick facts

Item Value
Radio ESP32 native BLE 4.2, no extra module
Control app nRF Connect or any BLE scanner app, free
Service One custom service, one writable drive characteristic
Commands Single letters: F, B, L, R, S, plus speed digits 0 to 9
Driver L298N, 2 A per channel
Failsafe Car stops on BLE disconnect

Why use ESP32 native BLE instead of a Bluetooth module?

The ESP32 DevKit V1 has a Bluetooth radio on the chip. It supports Bluetooth Classic and Bluetooth Low Energy 4.2. A separate HC-05 module adds a second radio, a second serial port, and a second power draw for no benefit. This build uses the radio that is already on the board.

BLE is not a wireless serial port. It is a tree of named values. The car publishes a service with a characteristic, and the phone writes values to that characteristic. That sounds more complex than serial, but it gives you connection handling for free. The ESP32 knows when the phone connects and when it drops, and the sketch uses that event as the failsafe.

No HC-05 or HC-06 module is stocked for this build, so the design does not spec one. The phone app is a generic BLE scanner, not a custom app. That keeps the build to two parts: the car and the phone you already own.

Bluetooth robot car: how does BLE control work?

The car runs a BLE server. The server holds one service, identified by a UUID, and one characteristic inside it, identified by a second UUID. The characteristic accepts writes and sends notifications. The phone scans, finds the car by its advertised name, connects, and writes a short string to the characteristic.

The string is a drive command. F drives forward, B reverses, L turns left, R turns right, and S stops. A digit after the letter sets the speed from 0 to 9, so F8 means forward at speed 8. The sketch parses the letter and the digit, then drives the L298N the same way the wired car build does. Commands are two characters, far under the default 20-byte BLE payload, so no MTU change is needed.

The UUIDs in the code are examples from the standard BLE tutorial set. Generate your own UUIDs for a finished project, because reused UUIDs can confuse scanner apps when two devices advertise the same service. A free UUID generator online makes a fresh pair in seconds.

How do you drive it from a phone?

Install nRF Connect, a free BLE scanner app, on your phone. Power the car, open the app, and scan. The car advertises as ESP32-Robot-Car. Tap Connect, then open the service and the drive characteristic. Write F8 as text or bytes to drive forward at speed 8, and write S to stop.

nRF Connect is a test tool, not a joystick. Each command is a manual write, so the car holds the last command until you write a new one. That is fine for testing, but it is not smooth driving. A proper control app with buttons or a joystick sends commands continuously, and any app that writes to a BLE characteristic will work with this sketch.

Keep the phone within a few meters of the car for the first test. BLE range in open air is tens of meters, but walls and the metal chassis cut it. If commands lag, move closer before you blame the code.

What happens when the phone disconnects?

The sketch registers server callbacks for connect and disconnect. On disconnect it sets a flag, stops both motors, and restarts advertising so the phone can reconnect. That is the failsafe. A car that kept its last command after the phone died would drive until it hit a wall.

Test the failsafe on purpose. Drive forward, then switch the phone Bluetooth off or walk out of range. The car should stop within a second. If it keeps driving, the disconnect callback is not running, so check that the callbacks are set before the service starts.

The sketch also stops the car if no command arrives for 2 seconds while connected. That covers the case where the app is open but stops sending. Both timers together mean the car never runs away from a dead link.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
Battery box positive L298N 12 V terminal Motor supply, 6 V from 4 AA cells
Battery box negative L298N GND and ESP32 GND Common ground is required
L298N OUT1, OUT2 Left TT motor Swap these two wires to fix a reversed wheel
L298N OUT3, OUT4 Right TT motor Swap these two wires to fix a reversed wheel
ESP32 GPIO 25 L298N ENA Remove the ENA jumper; PWM speed, left motor
ESP32 GPIO 27 L298N IN1 Left motor direction A
ESP32 GPIO 14 L298N IN2 Left motor direction B
ESP32 GPIO 26 L298N ENB Remove the ENB jumper; PWM speed, right motor
ESP32 GPIO 12 L298N IN3 Right motor direction A; keep low at boot
ESP32 GPIO 13 L298N IN4 Right motor direction B
USB 5 V or battery 5 V ESP32 USB port Logic supply only; motor current never passes through USB

Power budget

The motors run from 4 AA cells at about 6 V into the L298N, which drops about 2 V, so each TT motor sees about 4 V. Two TT motors draw about 1 to 2 A together at full load. The ESP32 runs from USB 5 V or a separate 5 V supply and draws about 80 to 160 mA with BLE advertising and connected.

BLE uses less power than Wi-Fi, but the car still needs its motors on a separate supply. Never power the motors from the ESP32 5 V pin. The L298N logic draws only a few milliamps from its onboard regulator when the 5 V jumper is fitted at 6 V.

For outdoor driving, a USB power bank powers the ESP32 while the AA box powers the motors. Keep both supplies separate except for the shared ground between the battery negative, the L298N ground, and the ESP32 ground.

Build steps

  1. Assemble the chassis kit, fit the TT motors and wheels, and mount the L298N and the ESP32 on the top plate.
  2. Wire the L298N and the motors from the wiring table. Leave the 5 V jumper on for a 6 V pack.
  3. Remove the ENA and ENB jumpers. Wire the six control pins and join the battery negative to the ESP32 ground.
  4. Upload the sketch below to the ESP32 DevKit V1. No extra library is needed, because BLE ships with the core.
  5. Install nRF Connect on your phone. Power the car and scan for ESP32-Robot-Car.
  6. Connect, open the drive characteristic, and write S to confirm the link. Then write F5 and confirm both wheels spin forward.
  7. Lift the car first, then set it on the floor. Test the disconnect failsafe by switching the phone Bluetooth off while driving.

Code

Libraries: none beyond the ESP32 Arduino core (BLE ships with the core). Board: ESP32 DevKit V1. The sketch uses the core 4.0.0 BLE API (BLE.h handles, BLEProperty/BLEPermission) and will not compile on core 2.x/3.x, whose BLEDevice pointer API was removed in 4.0. The UUIDs below are the standard tutorial pair; generate your own for a finished project.

// Bluetooth robot car: ESP32 native BLE server + L298N
// Board: ESP32 DevKit V1. Library: BLE (ships with the core).
// Requires Arduino ESP32 core 4.0.0 or later (ESP-IDF 6.1.1).
// The core 2.x/3.x BLEDevice pointer API does not compile on 4.0.
#include 

static const BLEUUID SERVICE_UUID("4fafc201-1fb5-459e-8fcc-c5c9c331914b");
static const BLEUUID CHARACTERISTIC_UUID("beb5483e-36e1-4688-b7f5-ea07361b26a8");

const int ENA = 25;  // Left motor PWM (remove the ENA jumper)
const int IN1 = 27;
const int IN2 = 14;
const int ENB = 26;  // Right motor PWM (remove the ENB jumper)
const int IN3 = 12;
const int IN4 = 13;

bool deviceConnected = false;
unsigned long lastCommandMs = 0;
const unsigned long COMMAND_TIMEOUT_MS = 2000;  // Stop if silent for 2 s

void driveMotor(int pwmPin, int inA, int inB, int speed) {
  if (speed >= 0) {
    digitalWrite(inA, HIGH);
    digitalWrite(inB, LOW);
    analogWrite(pwmPin, speed);
  } else {
    digitalWrite(inA, LOW);
    digitalWrite(inB, HIGH);
    analogWrite(pwmPin, -speed);
  }
}

void drive(int left, int right) {
  driveMotor(ENA, IN1, IN2, left);
  driveMotor(ENB, IN3, IN4, right);
}

void stopCar() {
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

// Command format: letter plus speed digit 0 to 9.
// F8 = forward speed 8, L5 = left speed 5, S = stop.
void handleCommand(String cmd) {
  if (cmd.length() < 1) return;
  char dir = cmd.charAt(0);
  int level = 5;  // Default speed level
  if (cmd.length() > 1 && isDigit(cmd.charAt(1))) {
    level = cmd.charAt(1) - '0';
  }
  int speed = map(level, 0, 9, 0, 255);
  lastCommandMs = millis();
  if (dir == 'F') drive(speed, speed);
  else if (dir == 'B') drive(-speed, -speed);
  else if (dir == 'L') drive(-speed, speed);
  else if (dir == 'R') drive(speed, -speed);
  else if (dir == 'S') stopCar();
}

void setup() {
  Serial.begin(115200);
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  stopCar();
  BLE.begin("ESP32-Robot-Car");
  BLEServer server = BLE.createServer();
  server.onConnect([](BLEServer &s, const BLEConnInfo &conn) {
    deviceConnected = true;
    lastCommandMs = millis();
  });
  server.onDisconnect([](BLEServer &s, const BLEConnInfo &conn, uint8_t reason) {
    deviceConnected = false;
    stopCar();  // Failsafe: halt on disconnect
  });
  server.advertiseOnDisconnect(true);
  BLEService svc = server.createService(SERVICE_UUID);
  BLECharacteristic chr = svc.createCharacteristic(
    CHARACTERISTIC_UUID,
    BLEProperty::Read | BLEProperty::Write | BLEProperty::Notify,
    BLEPermission::ReadWriteOpen);
  // Notify auto-creates the CCCD on core 4.0; no BLE2902 descriptor needed.
  chr.onWrite([](BLECharacteristic &c, const BLEConnInfo &conn) {
    handleCommand(c.getStringValue());
  });
  server.start();
  BLE.getAdvertising().addServiceUUID(SERVICE_UUID);
  BLE.startAdvertising();
  Serial.println("BLE car advertising as ESP32-Robot-Car");
}

void loop() {
  // Stop if connected but silent for 2 seconds.
  if (deviceConnected && millis() - lastCommandMs > COMMAND_TIMEOUT_MS) {
    stopCar();
  }
  delay(50);
}

Test and tune it

Write F5 in nRF Connect and confirm both wheels spin forward while the car is lifted. Write S and confirm they stop. If nothing moves, check that the characteristic accepts writes and that the command letter is uppercase.

Write R5 and confirm the car turns right. If it turns left, swap the left and right motor wiring as a pair, or swap the L and R cases in handleCommand().

Switch the phone Bluetooth off while driving forward. The car should stop within a second. If it keeps driving, the disconnect callback is not registered, so check that onDisconnect is registered before server.start().

FAQ

Do I need an HC-05 module for Bluetooth on an ESP32?

No. The ESP32 DevKit V1 has Bluetooth Classic and BLE built in. This build uses native BLE, so no extra module is fitted and no second serial port is needed.

What phone app controls the car?

Any BLE scanner app that can write to a characteristic works. nRF Connect is free and shows the service, the characteristic, and the write box. A custom app with buttons is smoother, but it is not needed to test the build.

Why does the car stop when my phone locks?

Many phones drop BLE connections when the screen locks to save power. Keep the screen on while driving, or reconnect and write a new command after unlocking.

Can BLE and Wi-Fi run at the same time on an ESP32?

Yes, but they share the 2.4 GHz radio, so throughput drops when both are active. This build uses BLE only, so the radio is free for the car link.

How far can the phone control the car?

BLE range in open air is tens of meters, but walls and the metal chassis cut it. Test outdoors in open space, and keep the phone within a few meters for the first run.

Parts used

Build it with the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, the Smart Robot Car Chassis Kit with Speed Encoder and Battery Box for Arduino, 2WD / 4WD, and the L298N Dual H-Bridge Motor Driver Module for Arduino. The wired version is L298N Robot Car: Wire and Drive Two DC Motors, and the no-router radio version is ESP-NOW Joystick Robot Car: Two ESP32 Boards, No Router. For the chip radios behind the choice, see ESP32 vs ESP32-S3 vs ESP32-C3 vs ESP32-C6.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

ESP32 Sensor Data Logger: Flash Logging and WiFi Download

ESP32 data logger with BME280 sensor and a downloaded CSV log

ESP32 Sensor Data Logger: Flash Logging and WiFi Download

This ESP32 sensor data logger logs BME280 readings to onboard flash with LittleFS, then downloads the CSV file over Wi-Fi. No SD card module is needed, because the ESP32 DevKit V1 has megabytes of flash to spare. The logger records a timestamped row every minute, and a web page at the board IP address offers the file for download.

Quick facts

Item Value
Storage LittleFS on onboard flash, no SD card module
Sensor BME280, temperature, humidity, pressure
Log format CSV, one row per minute
Download Web page at the board IP address, /download
Display 0.96 inch SSD1306 OLED shows the latest reading
Flash wear LittleFS spreads writes; log once per minute, not once per second

ESP32 sensor data logger: why log to onboard flash instead of an SD card?

LittleFS replaced SPIFFS as the filesystem in the Arduino ESP32 core. SPIFFS was deprecated in core 2.x and removed in core 3.x, so new sketches use LittleFS throughout. The ESP32 DevKit V1 ships with 4 MB of flash, and the sketch uses only part of it. LittleFS carves a filesystem out of the spare flash, so the board can store weeks of one-per-minute readings with no extra hardware. A CSV row is about 40 bytes, so one day of minute readings is about 58 KB.

No SD card module is stocked for this build, so the design uses what the board already has. That also removes a failure point: no card socket, no card formatting, and no card to shake loose on a robot. The trade is capacity. Flash holds far less than a card, so this logger suits weeks of data, not years.

LittleFS also handles wear. Flash cells wear out after many writes, and LittleFS spreads writes across the filesystem instead of hammering one spot. Logging once per minute keeps the write count low. Logging once per second would wear the flash far faster for no benefit in a room weather log.

What does each log row hold?

Each row holds the uptime in seconds, the temperature in degrees C, the humidity in percent, and the pressure in hPa. The ESP32 has no real-time clock, so uptime is the timestamp. If you need wall-clock time, note the download time and count back, or add an NTP sync step when Wi-Fi connects.

The file is plain CSV with a header row: uptime_s,temperature_c,humidity_pct,pressure_hpa. Any spreadsheet opens it, and any script can parse it. Keep the format fixed. Changing column order between firmware versions breaks every script that reads the file.

The logger appends one row per minute. It opens the file, writes the row, and closes it. Closing after every write protects the data if power fails. An open file with unwritten data is lost on a reset, but a closed file survives.

How do you download the log over Wi-Fi?

The ESP32 runs a web server with three routes. The root route returns a small status page with the latest reading and a download link. The /data route returns the latest reading as JSON. The /download route streams the CSV file with a download header, so the browser saves it instead of showing it.

Connect the ESP32 to your Wi-Fi network, read its IP address from the serial monitor, and open it in a browser on the same network. The page shows the latest values and a link labeled Download log. Click it and the CSV lands in your downloads folder.

The download reads the file in chunks, so a large log does not need to fit in RAM. The file is closed between writes, so a download started between writes reads a complete file. A download that overlaps a write can catch a partial last row, so download between samples when the data must be exact. In practice the one-per-minute write takes milliseconds, so overlaps are rare.

How do you keep the log from filling the flash?

LittleFS on a 4 MB board gives roughly 1.5 MB of filesystem space, depending on the partition scheme. At 58 KB per day, that is about 26 days of minute readings. The sketch checks the file size on every write. When the file passes 1 MB, it renames the old file to log_old.csv and starts a fresh log.csv.

That rotation keeps one current file and one old file. Download both before they rotate again, or the oldest data is lost. If you need longer retention, lower the sample rate to once per 5 minutes, which stretches the same space to about 4 months.

Check the free space with LittleFS.totalBytes() and LittleFS.usedBytes() at startup and print both to the serial monitor. If used space grows faster than your estimate, a bug is writing too often. Fix the sample interval before the flash fills.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
BME280 VCC ESP32 3V3 3.3 V; bare chip maximum is 3.6 V
BME280 GND ESP32 GND Common ground
BME280 SDA ESP32 GPIO 21 Default I2C data pin
BME280 SCL ESP32 GPIO 22 Default I2C clock pin
BME280 SDO GND Sets I2C address 0x76; tie to 3V3 for 0x77
BME280 CSB 3V3 Tie high for I2C mode
OLED VCC ESP32 3V3 3.3 V logic
OLED GND ESP32 GND Common ground
OLED SDA ESP32 GPIO 21 Shared I2C bus with the BME280
OLED SCL ESP32 GPIO 22 Shared I2C bus with the BME280

Power budget

The ESP32 draws about 80 to 160 mA with Wi-Fi on, and peaks near 240 mA while transmitting. The BME280 draws only a few microamps between readings, and the OLED draws about 20 mA lit. A USB 5 V supply at 500 mA covers the build.

Flash writes add a short current spike, but the spike lasts milliseconds and the supply capacitor on the board absorbs it. The real power cost is Wi-Fi staying on so the download page is always available. If you need battery life, use the deep sleep node build instead, which wakes, logs, sends, and sleeps.

Do not power this logger from a laptop USB port that sleeps. When the laptop sleeps, the USB port may cut power and the log stops. Use a wall USB supply for any unattended logging run.

Build steps

  1. Install the Adafruit BME280 Library and Adafruit Unified Sensor, plus the Adafruit SSD1306 and GFX libraries.
  2. Wire the BME280 and the OLED to the ESP32 from the wiring table.
  3. Edit the Wi-Fi name and password in the sketch, then upload it to the ESP32 DevKit V1.
  4. Open the serial monitor at 115200 baud and confirm the BME280 is found and LittleFS mounts. Copy the IP address.
  5. Open the IP address in a browser. The status page should show the latest reading and a download link.
  6. Leave the logger running for an hour, then download the CSV. Open it in a spreadsheet and confirm one row per minute.
  7. Check the file size after a day. At 58 KB per day, the 1 MB rotation should not trigger for about 17 days.

Code

Libraries: Adafruit BME280 Library, Adafruit Unified Sensor, Adafruit SSD1306, Adafruit GFX Library. LittleFS and WebServer ship with the ESP32 Arduino core. Board: ESP32 DevKit V1.

// ESP32 sensor data logger: BME280 to LittleFS, CSV download over WiFi
// Board: ESP32 DevKit V1. No SD card module is used.
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

const char* WIFI_SSID = "YOUR_WIFI_NAME";      // Replace with your network
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";  // Replace with your password

Adafruit_BME280 bme;  // I2C, address 0x76 or 0x77
Adafruit_SSD1306 display(128, 64, &Wire, -1);
WebServer server(80);

const char* LOG_PATH = "/log.csv";
const char* OLD_PATH = "/log_old.csv";
const size_t MAX_LOG_BYTES = 1000000;  // Rotate at 1 MB
const unsigned long SAMPLE_MS = 60000; // One row per minute

void logReading() {
  float t = bme.readTemperature();
  float h = bme.readHumidity();
  float p = bme.readPressure() / 100.0F;
  File f = LittleFS.open(LOG_PATH, FILE_APPEND);
  if (!f) {
    Serial.println("Failed to open log file");
    return;
  }
  // Uptime seconds; the ESP32 has no real-time clock.
  f.printf("%lu,%.1f,%.1f,%.1f\n", millis() / 1000, t, h, p);
  // Read the size while the file is still open; size() after close() returns 0.
  size_t logSize = f.size();
  f.close();
  if (logSize > MAX_LOG_BYTES) {
    LittleFS.remove(OLD_PATH);
    LittleFS.rename(LOG_PATH, OLD_PATH);
  }
}

void handleRoot() {
  float t = bme.readTemperature();
  float h = bme.readHumidity();
  float p = bme.readPressure() / 100.0F;
  String html = ""
    "ESP32 Data Logger"
    "

ESP32 Data Logger

" "

Temperature: " + String(t, 1) + " C

" "

Humidity: " + String(h, 1) + " %

" "

Pressure: " + String(p, 1) + " hPa

" "

Download log.csv

" ""; server.send(200, "text/html", html); } void handleDownload() { File f = LittleFS.open(LOG_PATH, FILE_READ); if (!f) { server.send(404, "text/plain", "No log file yet"); return; } server.sendHeader("Content-Disposition", "attachment; filename=log.csv"); server.streamFile(f, "text/csv"); f.close(); } void setup() { Serial.begin(115200); Wire.begin(21, 22); if (!LittleFS.begin(true)) { Serial.println("LittleFS mount failed"); while (1) delay(100); } Serial.print("LittleFS free bytes: "); Serial.println(LittleFS.totalBytes() - LittleFS.usedBytes()); if (!bme.begin(0x76) && !bme.begin(0x77)) { Serial.println("BME280 not found. Check wiring and address."); while (1) delay(100); } if (!LittleFS.exists(LOG_PATH)) { File f = LittleFS.open(LOG_PATH, FILE_WRITE); f.println("uptime_s,temperature_c,humidity_pct,pressure_hpa"); f.close(); } display.begin(SSD1306_SWITCHCAPVCC, 0x3C); WiFi.begin(WIFI_SSID, WIFI_PASS); while (WiFi.status() != WL_CONNECTED) delay(500); Serial.print("Logger at http://"); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.on("/download", handleDownload); server.begin(); } void loop() { server.handleClient(); static unsigned long lastSample = 0; if (millis() - lastSample >= SAMPLE_MS) { lastSample = millis(); logReading(); display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.print("Logged: "); display.print(millis() / 1000); display.println(" s"); display.display(); } }

Test and tune it

Download the CSV after one hour and count the rows. You should see about 60 rows plus the header. Fewer rows means the sample timer is wrong or the board reset. Check the serial monitor for reboot messages.

Open the CSV in a spreadsheet and plot temperature against uptime. The line should be smooth. A jump of several degrees in one minute means the sensor moved, the sun hit it, or the board heat reached it.

If the download returns 404, the log file does not exist yet. Wait one minute for the first sample, then retry. If it still fails, check the LittleFS free space printed at startup.

FAQ

Does this logger need an SD card?

No. It logs to the ESP32 onboard flash with LittleFS. A CSV row is about 40 bytes, so one day of minute readings is about 58 KB, and the filesystem holds about 26 days before rotation.

How long will the log last before it rotates?

About 17 days at one row per minute before the 1 MB rotation renames the file. Lower the sample rate to once per 5 minutes to stretch the same space to about 4 months.

Why is the timestamp in uptime seconds?

The ESP32 has no real-time clock, so uptime is the only clock it has without network time. Note the download time and count back, or add an NTP sync step when Wi-Fi connects.

What happens if power fails during a write?

The sketch closes the file after every row, so at most one row is lost. Rows already written survive a reset because LittleFS commits them on close.

Can I log faster than once per minute?

Yes, but flash wear rises with write count. Once per minute is ample for room weather. Log faster only when the signal changes fast, and rotate the file sooner.

Parts used

Build it with the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, the BME280 Temperature, Humidity and Barometric Pressure Sensor Module, 5V, I2C and SPI, and the 0.96 Inch OLED Display Module, SSD1306, I2C, 128×64, for Arduino / ESP32 / ESP8266. The live dashboard version is ESP32 WiFi Sensor Telemetry: Live Dashboard with BME280, and the battery version is Battery-Powered ESP32 Sensor Node: Deep Sleep and Power Budget. For the protocol behind the wiring, see I2C vs SPI vs UART: Which Protocol for Your Sensor or Display.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

L298N Robot Car: Wire and Drive Two DC Motors

Phone showing a BLE control app next to an ESP32 robot car

L298N Robot Car: Wire and Drive Two DC Motors

Wire an L298N between your battery and two TT motors, then drive them from an ESP32 with PWM on the enable pins. The L298N handles up to 2 A per channel, drops about 2 V across the bridge, and needs its own motor supply. The ESP32 only sends low-current direction and speed signals, and the supplies share only a ground.

Quick facts

Item Value
Driver L298N dual H-bridge, 2 A per channel, 3 A peak non-repetitive for 100 ms
Motor supply 5 to 35 V on the module, up to 46 V on the bare chip
Logic supply 4.5 to 7 V; onboard 5 V regulator with jumper
Voltage drop 1.8 to 3.2 V at 1 A, up to 4.9 V at 2 A
Motors 2 x TT 130 gear motors, 3 to 6 V
Speed control PWM on ENA and ENB, 0 to 255

L298N robot car: what does the L298N do?

The L298N is a dual H-bridge driver built on the ST L298 chip. It lets a microcontroller run two DC motors in either direction, at variable speed, from a supply the microcontroller could never deliver itself. Each channel switches up to 2 A of continuous current, with a 3 A peak allowed only non-repetitively for 100 ms.

An H-bridge is four switches arranged so the motor current can flow either way. The IN1 and IN2 pins set the direction for the first motor, and IN3 and IN4 set it for the second. The ENA and ENB pins enable each channel, and a PWM signal on an enable pin sets the speed. With the enable jumpers fitted, each motor runs at full speed whenever the direction pins command movement.

The bridge is built from bipolar transistors, not MOSFETs, so it drops voltage. At 1 A the drop is 1.8 to 3.2 V, and at 2 A it reaches 4.9 V. That drop becomes heat in the chip, which is why the module carries a large heatsink. A 12 V supply gives the motor about 10 V. A 6 V supply gives the motor about 4 V.

When do you remove the 5 V jumper?

The module has an onboard 5 V regulator and a jumper that enables it. With the jumper fitted and a motor supply of 12 V or less, the regulator makes 5 V on the 5 V pin, and you can use that pin to power your logic. With a motor supply above 12 V, remove the jumper first, or the regulator overheats.

With the jumper removed, the 5 V pin becomes an input. You must feed 5 V into it yourself to power the chip logic. This build uses a 6 V motor pack, so the jumper stays on. The regulator then supplies the logic, and the ESP32 runs from its own USB supply.

Never connect two 5 V supplies to the same pin. If the jumper is fitted, leave the 5 V pin unconnected, or the regulator and your other supply will fight. If the jumper is removed, feed 5 V in and do not expect 5 V out.

How do you wire the L298N to an ESP32?

Connect the motor battery positive to the 12 V terminal and the battery negative to GND. Connect the two TT motors to OUT1 and OUT2 for the left motor, and OUT3 and OUT4 for the right motor. Connect ENA, IN1, IN2, ENB, IN3 and IN4 to the ESP32 pins in the wiring table.

The L298N inputs read high from 2.3 V, so the ESP32 3.3 V logic drives them directly. No level shifter is needed. Join the battery negative to the ESP32 ground. Without that common ground, the direction signals have no reference and the motors will not respond.

Remove the ENA and ENB jumpers before you connect PWM. With the jumpers fitted, the enable pins sit at 5 V and the motors run at full speed regardless of your code. With the jumpers removed, the ESP32 PWM signal on each enable pin sets the speed from 0 to 255.

How does PWM speed control work?

PWM switches the enable pin on and off about 1,000 times per second at the core 3.3.13 default of 1 kHz. The motor sees the average voltage, so a 50 percent duty cycle gives about half speed. The sketch below uses analogWrite() with values from 0 to 255. A value of 0 stops the motor, and 255 runs it at full speed for the supply voltage.

TT motors stall at low PWM values. Below about 80 out of 255, many TT motors do not turn at all, because the average voltage cannot overcome friction. Start your speed tests at 150 and work down. If the car creeps at low speed, that is normal for a geared TT motor on an L298N with a 2 V drop.

Direction and speed are separate. The IN pins set forward or reverse, and the enable PWM sets how fast. To stop, set the enable PWM to zero. To brake hard, set both IN pins the same way, but a simple stop is enough for a first build.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
Battery box positive L298N 12 V terminal Motor supply, 6 V from 4 AA cells
Battery box negative L298N GND and ESP32 GND Common ground is required
L298N OUT1, OUT2 Left TT motor Swap these two wires to fix a reversed wheel
L298N OUT3, OUT4 Right TT motor Swap these two wires to fix a reversed wheel
ESP32 GPIO 25 L298N ENA Remove the ENA jumper; PWM speed, left motor
ESP32 GPIO 27 L298N IN1 Left motor direction A
ESP32 GPIO 14 L298N IN2 Left motor direction B
ESP32 GPIO 26 L298N ENB Remove the ENB jumper; PWM speed, right motor
ESP32 GPIO 33 L298N IN3 Right motor direction A; GPIO 33 is used instead of GPIO 12, which is a flash-voltage strapping pin and must stay low at boot
ESP32 GPIO 13 L298N IN4 Right motor direction B
L298N 5 V pin Leave unconnected Jumper fitted at 6 V, so the regulator makes 5 V here; do not feed 5 V in as well
USB 5 V ESP32 USB port Logic supply only; motor current never passes through USB

Power budget

The motors run from 4 AA cells at about 6 V into the L298N. The bridge drops about 2 V, so each TT motor sees about 4 V. Two TT motors at full load draw about 1 to 2 A together, which the L298N handles with its heatsink. At 1 A per channel the chip dissipates about 2 W as heat, so give it airflow and do not cover the heatsink.

The ESP32 runs from USB 5 V and draws about 80 to 160 mA with the radio on. The L298N logic draws about 40 to 60 mA from the motor supply through its onboard regulator. The two supplies share only a ground wire. Never power the motors from the ESP32 5 V pin, and never power the ESP32 from the L298N 5 V pin while USB is also connected, because two 5 V sources will fight.

If you raise the motor supply above 12 V, remove the 5 V jumper first and feed 5 V into the 5 V pin yourself. Above 12 V the onboard regulator overheats. The TT motors in this build are rated 3 to 6 V, so a 6 V pack is the right match and the jumper stays on.

Build steps

  1. Assemble the chassis kit, fit the TT motors and wheels, and mount the L298N and the ESP32 on the top plate.
  2. Connect the motors to OUT1 and OUT2, and OUT3 and OUT4. Connect the battery box to the 12 V terminal and GND. Leave the 5 V jumper on for a 6 V pack.
  3. Remove the ENA and ENB jumpers. Wire the six control pins from the wiring table and join the battery negative to the ESP32 ground.
  4. Upload the sketch below to the ESP32 DevKit V1. Keep the car lifted off the floor for the first test.
  5. Open the serial monitor at 115200 baud and type f, b, l, r, or s, then press Enter. Each key drives the car forward, back, left, right, or stop.
  6. Set the car on the floor and drive it forward. If a wheel runs backward, swap that motor’s two wires at the L298N output.
  7. Test low speed. If the motors stall below a PWM value of about 80, raise your minimum drive speed in the sketch.

Code

Libraries: none beyond the ESP32 Arduino core. Board: ESP32 DevKit V1, Arduino core 3.3.13 (analogWrite arrived in core 3.0). Control the car from the serial monitor: type f, b, l, r, or s and press Enter.

// L298N robot car: two TT motors, PWM speed, serial control
// Board: ESP32 DevKit V1, Arduino core 3.3.13. No extra libraries needed.
const int ENA = 25;  // Left motor PWM (remove the ENA jumper)
const int IN1 = 27;  // Left motor direction A
const int IN2 = 14;  // Left motor direction B
const int ENB = 26;  // Right motor PWM (remove the ENB jumper)
const int IN3 = 33;  // Right motor direction A (GPIO 12 avoided: strapping pin)
const int IN4 = 13;  // Right motor direction B
const int SPEED = 200;  // 0 to 255; TT motors stall below about 80

void driveMotor(int pwmPin, int inA, int inB, int speed) {
  if (speed >= 0) {
    digitalWrite(inA, HIGH);
    digitalWrite(inB, LOW);
    analogWrite(pwmPin, speed);
  } else {
    digitalWrite(inA, LOW);
    digitalWrite(inB, HIGH);
    analogWrite(pwmPin, -speed);
  }
}

void drive(int left, int right) {
  driveMotor(ENA, IN1, IN2, left);
  driveMotor(ENB, IN3, IN4, right);
}

void stopCar() {
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
}

void setup() {
  Serial.begin(115200);
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  stopCar();
  Serial.println("Type f, b, l, r, or s, then Enter.");
}

void loop() {
  if (Serial.available() > 0) {
    char c = Serial.read();
    if (c == 'f') drive(SPEED, SPEED);        // Forward
    else if (c == 'b') drive(-SPEED, -SPEED); // Reverse
    else if (c == 'l') drive(-SPEED, SPEED);  // Turn left
    else if (c == 'r') drive(SPEED, -SPEED);  // Turn right
    else if (c == 's') stopCar();             // Stop
  }
}

Test and tune it

Lift the car and type f. Both wheels should spin forward at the same speed. If one wheel is slower, check that its motor wires are tight in the screw terminal and that its enable PWM pin is connected.

Type s and confirm both wheels stop within a second. A wheel that keeps spinning has a stuck enable jumper or a shorted IN pin. Remove power and recheck the wiring table.

Drive the car on a hard floor, then on carpet. The car will slow on carpet because the TT motors draw more current under load and the L298N drop grows. That is normal. A MOSFET driver such as the TB6612FNG loses less voltage and is the next step if battery life matters.

FAQ

Why does my L298N get hot?

The bipolar bridge drops about 2 V, and that drop becomes heat. At 1 A per channel the chip dissipates about 2 W. The heatsink is supposed to get warm. Give it airflow and keep the current under 2 A per channel.

Do I remove the 5V jumper on the L298N?

Remove it when the motor supply is above 12 V, because the onboard regulator overheats. Leave it on at 12 V or less. With the jumper removed, feed 5 V into the 5 V pin yourself.

Why do the motors run slow on a 6 V battery?

The L298N drops about 2 V, so a 6 V pack gives each motor about 4 V. That is normal for this driver. A higher supply is not an option here: the pack is already 6 V and the TT motors are rated 3 to 6 V. A MOSFET driver such as the TB6612FNG loses less voltage and gives more speed.

Can the ESP32 drive the L298N directly?

Yes. The L298N inputs read high from 2.3 V, so 3.3 V logic works with no level shifter. Join the battery negative to the ESP32 ground so the signals share a reference.

Why does one wheel spin backward?

That motor is wired in reverse. Swap its two wires at the L298N output terminals. Do not fix it in code, because the wiring is the fault.

Parts used

Build it with the L298N Dual H-Bridge Motor Driver Module for Arduino, the Smart Robot Car Chassis Kit with Speed Encoder and Battery Box for Arduino, 2WD / 4WD, and the TT Motor 130 Gear Motor + 65mm Wheel, 3-6V DC, for Arduino Smart Car Robot, plus the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32 as the controller. The wireless version is ESP-NOW Joystick Robot Car: Two ESP32 Boards, No Router, and the driver comparison is L298N vs TB6612 vs DRV8833: Which Motor Driver for Your Robot. For the driver behind the speed control, see How to Choose the Right Motor Drivers for Arduino Use.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

ESP32 WiFi Sensor Telemetry: Live Dashboard with BME280

ESP32 data logger with BME280 sensor and a downloaded CSV log

ESP32 WiFi Sensor Telemetry: Live Dashboard with BME280

This ESP32 WiFi sensor telemetry build uses an ESP32 DevKit V1 with a BME280 sensor to serve a live temperature, humidity and pressure dashboard on your local Wi-Fi network. The sensor connects over I2C on GPIO 21 and GPIO 22, the ESP32 runs a small web server, and any phone or laptop on the same network opens the page.

Quick facts

Item Value
Sensor BME280, temperature, humidity, pressure
Interface I2C, address 0x76 or 0x77
Supply 3.3 V from the ESP32; bare chip maximum is 3.6 V
Accuracy Temperature plus or minus 0.5 C, humidity plus or minus 3 percent, pressure plus or minus 1 hPa
Update rate Page refreshes every 5 seconds
Display 0.96 inch SSD1306 OLED mirrors the readings locally

ESP32 WiFi sensor telemetry: how does the dashboard work?

The BME280 measures temperature, relative humidity and barometric pressure in one chip. The ESP32 reads it over I2C, then serves the values as a web page and as a small JSON endpoint. Your browser fetches the JSON every 5 seconds and updates the numbers without reloading the page.

The dashboard runs on your local network only. The ESP32 joins your Wi-Fi as a station, prints its IP address to the serial monitor, and serves the page at that address. Anyone on the same network can open it. Nothing leaves your network, and no account is needed.

The OLED display mirrors the readings on the bench. It is optional, but it helps when the network is down. The OLED uses the same I2C bus as the BME280, with its own address, so no extra pins are needed.

What does the BME280 measure, and how accurate is it?

The BME280 measures temperature from -40 to +85 C, relative humidity from 0 to 100 percent, and pressure from 300 to 1100 hPa. Bosch rates temperature accuracy at plus or minus 0.5 C from 0 to 65 C, humidity at plus or minus 3 percent, and pressure at plus or minus 1 hPa. Those figures come from the Bosch BME280 datasheet, revision 1.24, February 2024 (BST-BME280-DS001-24).

Pressure also works as an altimeter, because pressure falls with altitude. The sensor relative accuracy is plus or minus 0.12 hPa from 700 to 900 hPa at 25 to 40 C, which is about 3 feet of altitude. Do not expect survey accuracy from a bench sensor, but it is ample for weather trends and room monitoring.

Keep the sensor away from heat sources. The ESP32 board warms the air around it, and a BME280 mounted tight against the board reads high. Mount it on short jumper wires away from the board and out of direct sun.

How do you wire the BME280 and the OLED?

Both parts use I2C. Connect the BME280 VCC to the ESP32 3V3 pin and its GND to ground. Connect SDA to GPIO 21 and SCL to GPIO 22, which are the default I2C pins on the ESP32 DevKit V1. Connect the OLED the same way, on the same two wires.

The bare BME280 chip runs on 1.71 to 3.6 V and is not 5 V tolerant, so power it from 3.3 V on an ESP32. The stocked module lists 5 V support, which means it carries a regulator, but 3.3 V is safe for every version of the board. The OLED module also runs on 3.3 V.

The BME280 I2C address is 0x76 or 0x77, set by the SDO pin. Most small breakout boards default to 0x76. The code below tries 0x76 first and falls back to 0x77, so either board works. If the sensor is not found, run an I2C scanner sketch and read the address it reports.

How do you read the sensor in code?

Install the Adafruit BME280 Library and the Adafruit Unified Sensor library from the Arduino Library Manager. The sketch creates an Adafruit_BME280 object, starts it with begin(0x76), and reads temperature, humidity and pressure with readTemperature(), readHumidity() and readPressure(). Pressure comes back in Pascals, so divide by 100 to get hPa.

The web server is the ESP32 WebServer library, which ships with the core. The root handler returns an HTML page. The /data handler returns JSON with the three readings. A small JavaScript timer in the page fetches /data every 5 seconds and writes the values into the page.

The OLED uses the Adafruit SSD1306 library. It draws the same three values on the 128 by 64 display. If you skip the OLED, delete the display code and the sketch still works.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
BME280 VCC ESP32 3V3 3.3 V; bare chip maximum is 3.6 V, never use 5 V on a bare chip
BME280 GND ESP32 GND Common ground
BME280 SDA ESP32 GPIO 21 Default I2C data pin
BME280 SCL ESP32 GPIO 22 Default I2C clock pin
BME280 SDO GND Sets I2C address 0x76; tie to 3V3 for 0x77
BME280 CSB 3V3 Tie high for I2C mode
OLED VCC ESP32 3V3 3.3 V logic
OLED GND ESP32 GND Common ground
OLED SDA ESP32 GPIO 21 Shared I2C bus with the BME280
OLED SCL ESP32 GPIO 22 Shared I2C bus with the BME280

Power budget

The ESP32 draws about 80 to 160 mA with Wi-Fi on, and peaks near 240 mA while transmitting. The BME280 draws only a few microamps between readings, and the OLED draws about 20 mA with the display lit. A USB 5 V supply at 500 mA covers the whole build with margin.

Do not run this build from a small battery and expect days of life. Wi-Fi on, all the time, is the expensive part. If you need battery life, read the deep sleep sensor node build in Battery-Powered ESP32 Sensor Node: Deep Sleep and Power Budget, which wakes, reads, sends, and sleeps again.

Keep the USB cable short and the supply stable. A weak cable drops voltage when Wi-Fi transmits, and the ESP32 resets. That reset looks like a code fault, but it is a power fault. The troubleshooting post on brownout resets covers the symptoms.

Build steps

  1. Install the Adafruit BME280 Library, Adafruit Unified Sensor, and Adafruit SSD1306 libraries from the Library Manager.
  2. Wire the BME280 and the OLED to the ESP32 from the wiring table. Keep the sensor away from the board heat.
  3. Edit the Wi-Fi name and password in the sketch, then upload it to the ESP32 DevKit V1.
  4. Open the serial monitor at 115200 baud and copy the IP address the board prints after it connects.
  5. Open that IP address in a browser on the same network. The dashboard should show live temperature, humidity and pressure.
  6. Check the OLED. It should mirror the same three values. If the OLED is blank, check its I2C address with a scanner sketch.
  7. Leave the board running for an hour and watch the readings. Temperature should track the room, and pressure should drift slowly with the weather.

Code

Libraries: Adafruit BME280 Library, Adafruit Unified Sensor, Adafruit SSD1306, Adafruit GFX Library (all from the Arduino Library Manager). Board: ESP32 DevKit V1. The sketch tries BME280 address 0x76 first, then 0x77.

// ESP32 WiFi sensor telemetry with BME280 + SSD1306 OLED
// Board: ESP32 DevKit V1. Libraries: Adafruit BME280, Adafruit SSD1306.
#include 
#include 
#include 
#include 
#include 
#include 
#include 

const char* WIFI_SSID = "YOUR_WIFI_NAME";      // Replace with your network
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";  // Replace with your password

Adafruit_BME280 bme;  // I2C, address 0x76 or 0x77
Adafruit_SSD1306 display(128, 64, &Wire, -1);
WebServer server(80);

float temperatureC = 0, humidityPct = 0, pressureHpa = 0;

void readSensor() {
  temperatureC = bme.readTemperature();       // Degrees C
  humidityPct = bme.readHumidity();           // Percent relative humidity
  pressureHpa = bme.readPressure() / 100.0F;  // Pascals to hPa
}

void handleRoot() {
  // Simple page; JavaScript fetches /data every 5 seconds.
  String html = ""
    "ESP32 Sensor Telemetry"
    "

ESP32 Sensor Telemetry

" "

Temperature: -- C

" "

Humidity: -- %

" "

Pressure: -- hPa

" ""; server.send(200, "text/html", html); } void handleData() { readSensor(); String json = "{\"t\":" + String(temperatureC, 1) + ",\"h\":" + String(humidityPct, 1) + ",\"p\":" + String(pressureHpa, 1) + "}"; server.send(200, "application/json", json); } void setup() { Serial.begin(115200); Wire.begin(21, 22); // SDA, SCL on ESP32 DevKit V1 if (!bme.begin(0x76)) { if (!bme.begin(0x77)) { Serial.println("BME280 not found. Check wiring and address."); while (1) delay(100); } } if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println("OLED not found. Check wiring and address."); } WiFi.begin(WIFI_SSID, WIFI_PASS); while (WiFi.status() != WL_CONNECTED) delay(500); Serial.print("Dashboard at http://"); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.on("/data", handleData); server.begin(); } void loop() { server.handleClient(); static unsigned long lastDisplay = 0; if (millis() - lastDisplay > 5000) { lastDisplay = millis(); readSensor(); display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0, 0); display.print("Temp: "); display.print(temperatureC, 1); display.println(" C"); display.print("Hum: "); display.print(humidityPct, 1); display.println(" %"); display.print("Pres: "); display.print(pressureHpa, 1); display.println(" hPa"); display.display(); } }

Test and tune it

Open the dashboard on two devices at once. Both should update every 5 seconds. If one stalls, the Wi-Fi signal at the board is weak. Move the board closer to the router or raise the antenna area clear of metal.

Compare the temperature against a room thermometer. A reading 2 to 3 C high usually means the sensor sits too close to the ESP32 board. Move it onto longer jumper wires and retest.

If the page loads but the numbers stay at dashes, open the /data address directly in the browser. It should return JSON such as {“t”:21.5,”h”:44.0,”p”:1013.2}. If it returns an error, the BME280 read failed, so check the I2C address with a scanner sketch.

FAQ

Why does the BME280 show 0x76 on one board and 0x77 on another?

The SDO pin sets the address. Tied to ground it is 0x76, tied to the supply it is 0x77. Different breakout boards ship with different defaults. The code tries 0x76 first, then 0x77.

Can I view the dashboard from outside my home?

Not as built. The ESP32 serves the page on your local network only. Remote access needs port forwarding or a cloud service, which adds security risk. Keep it local unless you know how to secure it.

How often should the sensor read?

Every 5 seconds is ample for room weather. The BME280 itself draws almost nothing, but the Wi-Fi radio dominates power. Faster reads do not improve accuracy.

Why is the temperature higher than the room thermometer?

The ESP32 board warms the air around it. Mount the BME280 away from the board on short wires, out of direct sun, and the reading will track the room.

What is the difference between this build and a weather station?

A weather station shows readings on a local display. This build adds Wi-Fi, so any device on the network sees live data. The local weather station post on this site covers the display-only version.

Parts used

Build it with the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, the BME280 Temperature, Humidity and Barometric Pressure Sensor Module, 5V, I2C and SPI, and the 0.96 Inch OLED Display Module, SSD1306, I2C, 128×64, for Arduino / ESP32 / ESP8266. For the protocol behind the wiring, see I2C vs SPI vs UART: Which Protocol for Your Sensor or Display, and for the battery version of this node see Battery-Powered ESP32 Sensor Node: Deep Sleep and Power Budget.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

ESP-NOW Joystick Robot Car: Two ESP32 Boards, No Router

Phone showing a BLE control app next to an ESP32 robot car

ESP-NOW Joystick Robot Car: Two ESP32 Boards, No Router

This ESP-NOW joystick robot car uses two ESP32 DevKit V1 boards. One board reads a PS2 joystick and sends drive commands with ESP-NOW. The other board receives them and drives two TT motors through an L298N. ESP-NOW needs no router, no Wi-Fi password, and no phone app, and the car stops by itself when the link drops.

Quick facts

Item Value
Boards 2 x ESP32 DevKit V1, 30-pin WROOM-32
Radio ESP-NOW, 2.4 GHz, up to 250 byte payloads in version 1
Motors 2 x TT 130 gear motors, 3 to 6 V
Driver L298N, 2 A per channel, 1.8 to 3.2 V drop at 1 A
Logic voltage 3.3 V on the ESP32; L298N inputs read high from 2.3 V
Failsafe Car stops if no packet arrives for 500 ms

ESP-NOW joystick robot car: what is ESP-NOW and why use it?

ESP-NOW is a connectionless protocol from Espressif that sends small packets directly from one ESP32 to another. It uses the 2.4 GHz radio, but it needs no access point, no router, and no IP address. The sender addresses the receiver by its MAC address, and the receiver answers with a callback when a packet lands.

A robot car is a good fit because the packets are small and the latency is low. A joystick sends two numbers, forward and turn, about 20 times per second. That fits in a packet of a few bytes. Wi-Fi with a web server also works, but it adds a router, a connection step, and a web page. Bluetooth also works, but it adds pairing and a phone app. ESP-NOW keeps the link between two boards you own.

The cost is range and pairing effort. ESP-NOW range in open air is similar to Wi-Fi range, and walls cut it fast. You must also copy the receiver MAC address into the sender sketch. That is a one-time step, and the build steps below show it.

How does the two-board layout work?

The remote board is an ESP32 DevKit V1 with a PS2 joystick module. It reads the joystick X and Y analog pins, maps them to speed and turn values, and sends one small struct with ESP-NOW. It sends 20 packets per second. It draws only the board current, about 80 mA on average and peaking near 240 mA while transmitting, from its USB supply or a small battery pack.

The car board is a second ESP32 DevKit V1 on the chassis. It receives the struct, converts speed and turn into left and right motor speeds, and writes PWM to the L298N enable pins. It also runs a watchdog timer. If 500 ms pass with no packet, it sets both motors to zero. That is the failsafe, and it matters when the car drives out of range or the remote battery dies.

Both boards must use the same Wi-Fi channel. ESP-NOW peers are registered on a channel, and the sender and receiver must agree. This build sets channel 1 on both boards. Keep the struct identical on both boards. If the sizes differ, the receiver reads garbage.

What parts do you need?

You need two ESP32 DevKit V1 boards, one robot car chassis kit, one L298N module, one PS2 joystick module, and jumper wires. The chassis kit in the parts list includes the frame, TT motors, wheels, a speed encoder, and a battery box. Use the battery box for the motors only, through the L298N, and power the car ESP32 from USB or a separate 5 V source during testing.

Do not power the motors from the ESP32 5 V pin. The TT motors draw far more current than a USB port or a board regulator can supply, and the voltage dips will reset the board. The L298N exists to keep motor current on its own supply. The wiring table below keeps the two supplies separate except for a shared ground.

How do you find the receiver MAC address?

Upload a short sketch to the car board that prints WiFi.macAddress() to the serial monitor at 115200 baud. Set WiFi.mode(WIFI_STA) first, because some cores print zeros before the mode is set. Copy the address from the monitor, for example A4:CF:12:34:56:78, and write it in the sender sketch as {0xA4, 0xCF, 0x12, 0x34, 0x56, 0x78}.

The sender registers that address as a peer with esp_now_add_peer(). The receiver needs no peer entry for a one-way link. It only registers a receive callback with esp_now_register_recv_cb(). The callback signature changed in Arduino core 3.0, so the code below uses a version guard for the receive callback. The sketch as a whole needs core 3.x (target 3.3.13, the stable 3.x release), because analogWrite does not exist in core 2.x. Core 4.0 is not verified for this sketch.

How does the joystick map to motor speed?

The joystick gives two analog readings, one for X and one for Y. Each reading runs 0 to 4095 on the ESP32 12-bit ADC. Center is near 2047. The sender subtracts the center, applies a dead zone of about 200 counts so a resting stick sends zero, and maps the result to a speed range of -255 to 255.

The car mixes speed and turn into left and right speeds. Left speed equals speed plus turn, and right speed equals speed minus turn. Each value is then clamped to -255 to 255. A positive value drives the motor forward, a negative value drives it in reverse, and zero stops it. The L298N direction pins set the direction, and the enable pin PWM sets the speed.

Test the mix on blocks before the car touches the floor. Lift the chassis, run the remote, and watch both wheels. Forward should spin both wheels forward. A right turn should slow or reverse the right wheel. If a wheel runs backward, swap its two motor wires at the L298N output, not in code.

Wiring

Wire the build with the power off. Check every connection in the table before you connect any battery or USB cable.

From To Notes
Joystick VCC Remote ESP32 3V3 3.3 V logic; the joystick module runs on 3.3 V or 5 V
Joystick GND Remote ESP32 GND Common ground
Joystick VRx Remote ESP32 GPIO 34 ADC1 pin; input only, safe with Wi-Fi running
Joystick VRy Remote ESP32 GPIO 35 ADC1 pin; input only, safe with Wi-Fi running
Joystick SW Remote ESP32 GPIO 32 Pushbutton; use INPUT_PULLUP and read LOW as pressed
Car ESP32 GPIO 25 L298N ENA PWM speed, left motor
Car ESP32 GPIO 26 L298N ENB PWM speed, right motor
Car ESP32 GPIO 27, 14 L298N IN1, IN2 Left motor direction, 3.3 V logic is enough; L298N reads high from 2.3 V
Car ESP32 GPIO 33, 13 L298N IN3, IN4 Right motor direction; GPIO 33 is used instead of GPIO 12, which is a flash-voltage strapping pin and must stay low at boot
L298N OUT1, OUT2 Left TT motor Motor wires; swap here to fix reversed direction
L298N OUT3, OUT4 Right TT motor Motor wires
Battery box positive L298N 12 V terminal Motor supply, 6 V from 4 AA cells; keep the 5 V jumper on at 12 V or less
Battery box negative L298N GND and car ESP32 GND Common ground is required; without it the L298N inputs float
USB 5 V Car ESP32 USB port Logic supply only; never route motor current through USB

Power budget

The car has two separate supplies. The motors run from 4 AA cells at about 6 V into the L298N. The L298N drops about 2 V, so each TT motor sees about 4 V. That is normal for this driver and is why a 6 V pack suits 3 to 6 V TT motors.

The car ESP32 runs from USB 5 V during testing. It draws about 80 to 160 mA with the radio on. The L298N logic draws about 40 to 60 mA from the motor supply through its own regulator when the 5 V jumper is fitted. Never feed the motors from the ESP32 5 V pin or from the same USB port that powers the board.

The remote ESP32 runs from USB 5 V. It draws about 80 mA on average, peaking near 240 mA while sending. A small USB power bank works for outdoor driving. Keep the remote and the car on the same ESP-NOW channel, channel 1 in the code below.

Build steps

  1. Assemble the chassis kit, fit the TT motors and wheels, and mount the L298N and the car ESP32 on the top plate.
  2. Wire the L298N outputs to the motors and the motor battery to the L298N 12 V terminal. Leave the 5 V jumper on for a 6 V pack.
  3. Wire the car ESP32 to the L298N control pins from the wiring table. Join the battery negative to the ESP32 ground.
  4. Upload the MAC print sketch to the car board, read its address from the serial monitor, and write it into the sender sketch.
  5. Upload the receiver sketch to the car board and the sender sketch to the remote board. Keep the struct identical in both files.
  6. Wire the joystick to the remote ESP32 from the wiring table. Power the remote from USB.
  7. Lift the car off the floor, push the stick forward, and confirm both wheels spin forward. Push right and confirm the right wheel slows.
  8. Set the car on the floor, drive it in a straight line, then walk away until it stops. The 500 ms failsafe should halt it when the link drops.

Code

Libraries: none beyond the ESP32 Arduino core (WiFi.h, esp_now.h and esp_wifi.h ship with the core). Board: ESP32 DevKit V1, Arduino core 3.3.13. analogWrite arrived in core 3.0, so core 2.x will not compile these sketches. Upload the receiver sketch to the car board first, then the sender sketch to the remote board.

// Receiver sketch: ESP-NOW robot car (car board)
// Board: ESP32 DevKit V1. Core: Arduino ESP32 3.x.
#include 
#include 
#include 

// Motor pins on the car board
const int ENA = 25;   // Left motor PWM
const int IN1 = 27;   // Left motor direction A
const int IN2 = 14;   // Left motor direction B
const int ENB = 26;   // Right motor PWM
const int IN3 = 33;   // Right motor direction A (GPIO 12 avoided: strapping pin)
const int IN4 = 13;   // Right motor direction B

// Must match the sender struct exactly, same order and types.
typedef struct {
  int16_t speed;  // -255 to 255, forward is positive
  int16_t turn;   // -255 to 255, right is positive
} DriveCommand;

DriveCommand cmd = {0, 0};
unsigned long lastPacketMs = 0;
const unsigned long FAILSAFE_MS = 500;  // Stop if no packet for 500 ms

void driveMotor(int pwmPin, int inA, int inB, int speed) {
  if (speed >= 0) {
    digitalWrite(inA, HIGH);
    digitalWrite(inB, LOW);
    analogWrite(pwmPin, speed);
  } else {
    digitalWrite(inA, LOW);
    digitalWrite(inB, HIGH);
    analogWrite(pwmPin, -speed);
  }
}

void stopMotors() {
  analogWrite(ENA, 0);
  analogWrite(ENB, 0);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

// Callback signature changed in Arduino core 3.0; this guard covers both.
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
void onReceive(const esp_now_recv_info_t *info, const uint8_t *data, int len) {
#else
void onReceive(const uint8_t *mac, const uint8_t *data, int len) {
#endif
  if (len == sizeof(cmd)) {
    memcpy(&cmd, data, sizeof(cmd));
    lastPacketMs = millis();
  }
}

void setup() {
  Serial.begin(115200);
  pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(ENB, OUTPUT); pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  stopMotors();
  WiFi.mode(WIFI_STA);
  esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE);  // Sender must use the same channel
  if (esp_now_init() != ESP_OK) {
    Serial.println("ESP-NOW init failed");
    return;
  }
  esp_now_register_recv_cb(onReceive);
  lastPacketMs = millis();
}

void loop() {
  if (millis() - lastPacketMs > FAILSAFE_MS) {
    stopMotors();  // Link lost: halt the car
    return;
  }
  int left = constrain(cmd.speed + cmd.turn, -255, 255);
  int right = constrain(cmd.speed - cmd.turn, -255, 255);
  driveMotor(ENA, IN1, IN2, left);
  driveMotor(ENB, IN3, IN4, right);
  delay(20);
}

// ---------- Sender sketch: ESP-NOW joystick remote ----------
// Board: ESP32 DevKit V1, Arduino core 3.3.13. Upload to the remote board.
// Replace receiverMac with the MAC address of the car board.
#include 
#include 
#include 

uint8_t receiverMac[] = {0xA4, 0xCF, 0x12, 0x34, 0x56, 0x78};  // Your car board

const int JOY_X = 34;  // ADC1 pin
const int JOY_Y = 35;  // ADC1 pin
const int JOY_SW = 32; // Pushbutton, INPUT_PULLUP

typedef struct {
  int16_t speed;  // Must match the receiver struct exactly
  int16_t turn;
} DriveCommand;

DriveCommand cmd = {0, 0};

int readAxis(int pin) {
  int v = analogRead(pin) - 2047;  // Center is near 2047
  if (v > -200 && v < 200) return 0;  // Dead zone
  return map(constrain(v, -2047, 2047), -2047, 2047, -255, 255);
}

void setup() {
  Serial.begin(115200);
  pinMode(JOY_SW, INPUT_PULLUP);
  WiFi.mode(WIFI_STA);
  esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE);  // Receiver must use the same channel
  if (esp_now_init() != ESP_OK) {
    Serial.println("ESP-NOW init failed");
    return;
  }
  esp_now_peer_info_t peer = {};
  memcpy(peer.peer_addr, receiverMac, 6);
  peer.channel = 1;
  peer.encrypt = false;
  if (esp_now_add_peer(&peer) != ESP_OK) {
    Serial.println("Failed to add peer");
  }
}

void loop() {
  cmd.speed = readAxis(JOY_Y);  // Forward is positive
  cmd.turn = readAxis(JOY_X);   // Right is positive
  esp_now_send(receiverMac, (uint8_t *) &cmd, sizeof(cmd));
  delay(50);  // 20 packets per second
}

Test and tune it

Drive the car toward a wall at low speed and release the stick. The car should stop within half a second of the last packet. If it keeps rolling, the failsafe is not running, so check that lastPacketMs updates only inside the receive callback.

If one wheel spins backward, swap that motor's two wires at the L298N output. If the car turns left when you push right, swap the sign of the turn value in the sender, or swap the left and right motor wiring as a pair.

If packets stop arriving beyond a few feet indoors, check that both boards use channel 1 and that the receiver antenna area is clear of the metal chassis plate. Move the car board above the plate if the link is weak.

FAQ

Does ESP-NOW need a router?

No. ESP-NOW sends packets directly from one ESP32 to another by MAC address. It needs no router, no Wi-Fi password, and no internet connection.

What is the ESP-NOW range?

Range is similar to 2.4 GHz Wi-Fi in open air and drops fast through walls. Keep the receiver antenna clear of metal plates and test the failsafe at the edge of range.

Why does my car keep driving after I switch the remote off?

The receiver is not running a link-loss watchdog, or the watchdog timeout is too long. This build stops the motors after 500 ms with no packet. Check that lastPacketMs updates only in the receive callback.

Can I use ESP-NOW with an ESP32-S3 or ESP32-C3 as well?

Yes. ESP-NOW works across the ESP32 family, but the sender and receiver must use the same channel and the same struct. Check the pinout post for your exact board before you wire the L298N.

Why do the motors run slow on a 6 V pack?

The L298N drops about 2 V, so a 6 V pack gives each motor about 4 V. That is normal for this driver. A higher supply is not an option here: the pack is already 6 V and the TT motors are rated 3 to 6 V. Switch to a MOSFET driver such as the TB6612FNG for less drop.

Parts used

Build it with the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32 (two boards, one for the remote and one for the car), the Smart Robot Car Chassis Kit with Speed Encoder and Battery Box for Arduino, 2WD / 4WD, the L298N Dual H-Bridge Motor Driver Module for Arduino, and the HiLetgo Game Joystick Sensor Module, PS2, 2-Axis with Pushbutton. The L298N robot car build in L298N Robot Car: Wire and Drive Two DC Motors covers the same driver in a wired build, and the ESP32 vs ESP32-S3 vs ESP32-C3 vs ESP32-C6 comparison helps if you pick a different board for the remote.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

For the full ESP-NOW explainer behind this build, see ESP-NOW Explained: Two ESP32 Boards, No Router.

ESP32-S2 vs ESP32-S3: USB, Bluetooth, and Camera Compared

ESP32-S2 Mini board beside an ESP32-S3 DevKitC board

ESP32-S2 vs ESP32-S3: USB, Bluetooth, and Camera Compared

Pick the ESP32-S3 for most new projects. It adds a second core, Bluetooth LE, more SRAM, PSRAM support and vector instructions to the same Wi-Fi and native USB base as the S2. Pick the ESP32-S2 only when you need Wi-Fi plus native USB without Bluetooth, or when you need its built in DACs.

ESP32-S2 vs ESP32-S3 at a glance

The table below uses the Espressif ESP32-S2 Series Datasheet v1.9 and the Espressif ESP32-S3 Series Datasheet v2.2 (2026-03-05).

Spec (unit) ESP32-S2 ESP32-S3
CPU Single Xtensa LX7 Dual Xtensa LX7
Max clock (MHz) 240 240
SRAM (KB) 320 512
GPIO pins (count) 43 45
Wi-Fi Wi-Fi 4, 2.4 GHz Wi-Fi 4, 2.4 GHz
Bluetooth None BLE 5
USB USB OTG full speed USB OTG full speed plus USB Serial/JTAG
PSRAM Up to 2 MB external Up to 16 MB in package
ADC channels (count, bits) 20, 12-bit 20, 12-bit
DAC channels (count) 2, 8-bit 0
Vector instructions No Yes, 128-bit SIMD
Camera interface Yes, DVP 8 to 16 bit (via I2S, up to 40 MHz) Yes, DVP 8 to 16 bit
Touch pins (count) 14 14

How do the CPUs compare?

Both chips use the Xtensa LX7 architecture at up to 240 MHz. The difference is core count: the S2 has one LX7 core and the S3 has two. A single core at 240 MHz handles a Wi-Fi connection plus a sensor task without strain. Two cores handle that same load plus a display, a camera or an audio pipeline at the same time.

The S3 also has 512 KB of SRAM against 320 KB on the S2. That 192 KB gap matters when a project holds a display buffer or a network buffer plus application state. The S3 adds 128-bit vector instructions that speed neural network and signal processing work. The S2 has no vector unit, so on-device AI runs slower or not at all.

For a simple Wi-Fi sensor that wakes, reads and posts, the second core is invisible. For a project that streams, displays and networks at once, the second core is the difference between smooth operation and dropped frames.

What is the Bluetooth difference?

The ESP32-S2 has no Bluetooth radio at all. It cannot do Bluetooth LE, Bluetooth Classic, beacons or phone pairing, and no software adds a radio that is not on the chip. The ESP32-S3 has Bluetooth LE 5, with 1 Mbps, 2 Mbps and coded PHY data rates plus extended advertising. It does not have Bluetooth Classic, so classic audio streaming and classic serial port profile links are still out.

This is the most common reason a builder regrets an S2 pick. A Wi-Fi sensor that later gains a phone app for setup needs Bluetooth LE for provisioning, and the S2 cannot provide it. If there is any chance your project will need Bluetooth, buy the S3. The price gap between S2 and S3 boards is small, and a board swap late in a project costs far more.

How does USB compare?

Native USB is the shared strength of both chips. The S2 and the S3 each have a full speed USB OTG peripheral with an integrated transceiver. Either chip can act as a USB device, such as a keyboard, a MIDI device or a serial port, or as a USB host that reads a flash drive or a keyboard. That is a step up from the original ESP32, which needs an external USB to serial chip for every USB connection.

The S3 adds a USB Serial/JTAG controller, which gives flashing and debugging over the same USB cable without a separate debug probe. The S2 has USB OTG but no dedicated Serial/JTAG controller, so its debug path is less direct. For a USB gadget project, both chips work. For a USB gadget that also needs debugging over USB, the S3 is the smoother board.

Which chip handles cameras and displays?

Both chips have a DVP camera interface at 8 to 16 bit, implemented with the I2S hardware, so the S2 can run a camera. The S3 is still the camera pick in this pair. It has an LCD interface, PSRAM support up to 16 MB in package, dual cores and the vector instructions that make image work practical. A camera frame needs a buffer that the S2 struggles to hold: the S2 has 320 KB of SRAM and only up to 2 MB of external PSRAM, and it lacks the LCD interface and the vector unit that the S3 uses for image work.

Displays follow the same split. A small SPI display works on either chip. A large parallel RGB display with a frame buffer needs the S3 PSRAM and LCD interface. If your project has a large display, the S3 is the only pick in this pair. If it has a small SPI OLED or TFT, either chip works, and the S2 is the cheaper board.

What does the S2 still do better?

The S2 has two built in 8-bit DAC channels, which the S3 lacks. A project that needs a true analog voltage output, such as a simple waveform generator or a control voltage, can use the S2 DAC directly, while the S3 needs an external DAC chip or a filtered PWM signal. The S2 DACs are DAC_1 on GPIO 17 and DAC_2 on GPIO 18 in the S2 datasheet. That DAC difference is the one S2 advantage that decides a real project.

The S2 also suits a Wi-Fi only USB device with no Bluetooth requirement, such as a USB sensor dongle or a Wi-Fi to USB bridge. Its single core and lower SRAM are ample there, and its 43 GPIO pins are only two fewer than the S3. An existing S2 design that works should stay on the S2; a redesign to the S3 buys nothing if the project uses neither Bluetooth nor a camera.

Which board should you pick?

Project type Pick this chip Why
Camera or AI vision ESP32-S3 Both have DVP, S3 adds PSRAM, LCD interface and vector instructions
Bluetooth LE sensor or beacon ESP32-S3 S2 has no Bluetooth radio
Colour display or HMI ESP32-S3 PSRAM and LCD interface
USB keyboard, MIDI or HID Either, S3 preferred Both have USB OTG; S3 adds Serial/JTAG debug
Wi-Fi only sensor, no Bluetooth ESP32-S2 Single core is ample, lower cost, 43 GPIO pins
Analog voltage output ESP32-S2 Built in DACs, two 8-bit channels
Existing S2 design in production ESP32-S2 No redesign cost when Bluetooth and camera are not needed

How do you migrate a project from S2 to S3?

Migrating a project from the ESP32-S2 to the ESP32-S3 is mostly a board selection change, because both chips run the same Arduino core and the same ESP-IDF. Start by listing the pins your S2 project uses and mapping each one to the S3 board, because the pin numbers differ between the S2 Mini and the S3 DevKitC-1. Check the strapping pins on the new board before you wire anything, and move any sensor off a pin that is a strapping pin on the S3.

Next, check the libraries. Code that uses Wi-Fi, I2C, SPI, UART and USB OTG ports across both chips with no change, because the APIs are the same. Code that uses the S2 DAC needs a rework, because the S3 has no DAC: replace the DAC output with a filtered PWM signal or an external DAC chip. Code that uses Bluetooth needs a fresh start on the radio side, because the S2 had no Bluetooth stack to port from, so add the BLE setup from an S3 example and test it on the bench.

Then check memory and partitions. The S3 has 512 KB of SRAM against 320 KB on the S2, and its DevKitC-1 boards offer 8 MB or 16 MB of PSRAM, so a project that was tight on the S2 has room to breathe. Raise the display buffer or the network buffer only after the basic port works, and test the migrated project on the bench before you deploy it. Wi-Fi signal strength, boot behaviour and deep sleep wake timing all differ between the chips, and a project that worked on the S2 can behave differently on the S3 if a pin that was safe on one board is a strapping pin on the other.

For the S2 pins in this comparison, see the ESP32-S2 Mini pinout guide.

FAQ

Does the ESP32-S2 have Bluetooth?

No. The ESP32-S2 has no Bluetooth radio. If your project needs Bluetooth LE, choose the ESP32-S3.

Is the ESP32-S3 better than the S2 for Wi-Fi?

Wi-Fi itself is the same on both chips: 2.4 GHz Wi-Fi 4. The S3 is better at everything around the Wi-Fi, because it has a second core, more SRAM and Bluetooth LE.

Can the ESP32-S2 run a camera?

Yes. The S2 has a DVP 8 to 16 bit camera interface, implemented with the I2S hardware, with a clock up to 40 MHz. It holds smaller frames than the S3, because it has only 320 KB of SRAM and up to 2 MB of external PSRAM, and it has no LCD interface or vector unit. Camera projects that need large frames belong on the S3.

Do both chips have native USB?

Yes. Both have full speed USB OTG, so either can act as a USB device or host. The S3 adds a USB Serial/JTAG controller for flashing and debugging.

Should I upgrade an S2 project to the S3?

Upgrade when the project gains Bluetooth, a camera, a large display or AI work. Keep the S2 when the project is a working Wi-Fi only USB device with no new radio or display requirement.

Parts used

ESP32-S2 Mini Development Board: the S2 board for Wi-Fi only USB projects. ESP32-S3 Development Board DevKitC-1 N8R2 N16R8: the S3 board for camera, display, Bluetooth and AI projects.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

For the full pin table, see the ESP32-S3 DevKitC-1 pinout guide.

ESP8266 vs ESP32: Specs, Power, and Which to Pick

Microcontroller datasheet open beside an ESP32 board and a Raspberry Pi Pico

ESP8266 vs ESP32: Specs, Power, and Which to Pick

Pick the ESP32 for any new project that needs Bluetooth, more than one analog input, or more than about 50 KB of free RAM. Keep the ESP8266 only when you are maintaining a working design that already uses it. Espressif marks the ESP8266 as Not Recommended for New Designs, so new work should start on an ESP32 family chip.

ESP8266 vs ESP32 at a glance

The table below uses the Espressif ESP8266EX Datasheet v7.1 (2025-11-18, which updated the product status to Not Recommended for New Designs) and the Espressif ESP32 Series Datasheet v5.3.

Spec (unit) ESP8266 ESP32
CPU Single Tensilica L106, 32-bit Dual Xtensa LX6, 32-bit
Max clock (MHz) 80, up to 160 240
User RAM (KB) About 50 usable from 80 KB data RAM 520 SRAM
Flash (MB) Up to 16 external, 1 to 4 typical on boards 4 in package typical, up to 16 external
GPIO pins (count) 17 at chip level, 11 usable on common boards 34
ADC 1 channel, 10-bit, 0 to 1.0 V at chip 18 channels, 12-bit, two ADC units
DAC None 2 channels, 8-bit
Wi-Fi 802.11 b/g/n, 2.4 GHz 802.11 b/g/n, 2.4 GHz
Bluetooth None Classic plus BLE 4.2
UART (count) 2, one transmit only 3
SPI (count) 1 usable plus HSPI 2 usable plus flash SPI
I2C Software bit banged, 1 bus typical 2 hardware buses
PWM channels (count) Software PWM typical 16 LEDC channels
Logic voltage (V) 3.3 3.3
Deep sleep current (uA) 20, chip level About 10, board dependent

The RAM row deserves a note. The ESP8266EX datasheet describes about 50 KB of programmable space accessible in heap plus data when the chip runs in station mode. The ESP32 has 520 KB of SRAM. That gap is the single largest practical difference between the two chips, and it decides which libraries fit.

Is the ESP8266 still recommended for new designs?

No. Espressif marks the ESP8266EX as Not Recommended for New Designs, abbreviated NRND. Espressif defines NRND as a product that is still in production but not recommended for new designs, because newer products offer better function, lower cost or a longer future. NRND does not mean the chip is discontinued. Espressif lists the ESP8266 in its Longevity Commitment at a minimum of 15 years from January 1, 2014, so existing products built on it can still be supplied and repaired.

The practical meaning is simple. If you already ship a product on the ESP8266, you can keep ordering it and keep supporting it. If you are starting a new design, Espressif points you at the ESP8684, sold as the ESP32-C2, as the direct upgrade path: the v7.1 datasheet cover recommends the upgraded model ESP8684. The ESP32-C3 is the board level equivalent that most makers reach for. The ESP32-C3 has a single RISC-V core at 160 MHz, 400 KB of SRAM, 22 GPIO pins and Bluetooth LE 5, at a similar price point to ESP8266 boards.

Software support follows the same direction. Espressif directs new framework development at the ESP32 line. Community firmware projects have also moved on: ESPHome lists the ESP8266 as not recommended for new projects and recommends the ESP32-C3 instead at a similar price, while noting that existing ESP8266 devices keep working and keep receiving support. ESPEasy declared its ESP8266 builds feature complete in April 2025, because new plugins no longer fit in the limited binary space and RAM.

How do the CPUs and memory compare?

The ESP8266 has one Tensilica L106 core at 80 MHz by default, with 160 MHz available as a clock option. The ESP32 has two Xtensa LX6 cores at up to 240 MHz. Raw clock speed understates the gap, because the ESP32 also has a second core, a faster bus and far more RAM. A Wi-Fi stack plus a sensor task plus a display task runs comfortably on the ESP32 and strains the ESP8266.

Memory is where ESP8266 projects hit a wall. About 50 KB of heap is available to your code once the Wi-Fi stack is running. A TLS connection, a JSON document and a display buffer can consume that budget before your application logic starts. The ESP32 has 520 KB of SRAM, so the same project has room for a display buffer, a TLS session and a web server at once. Flash follows the same pattern: most ESP8266 boards carry 1 MB to 4 MB of flash, while most ESP32 boards carry 4 MB or more.

The lesson is to count RAM before you count pins. A project that fits in 50 KB of RAM runs fine on the ESP8266. A project that needs a secure connection, a large display or a camera does not fit, and the ESP32 is the correct pick.

How do GPIO, ADC and peripherals compare?

The ESP8266 exposes 17 GPIO pins at the chip level, but common boards such as the NodeMCU expose about 11 usable pins, and several of those carry boot duties. GPIO 0, GPIO 2 and GPIO 15 must sit at specific levels at boot, and GPIO 16 is tied to the deep sleep wake timer and supports no interrupts. A project with four sensors, a display and two buttons can run out of usable pins on an ESP8266 board.

The ESP32 exposes 34 GPIO pins, with 6 input only pins at GPIO 34 to 39, and far fewer boot traps. It has two hardware I2C buses, three UARTs, two usable SPI buses, 16 PWM channels and 10 touch pins. The ESP8266 has one ADC channel at 10-bit resolution, and the chip input range is 0 to 1.0 V, although NodeMCU style boards add a voltage divider that scales the board input to 0 to 3.3 V. The ESP32 has 18 ADC channels at 12-bit resolution, with the ADC2 and Wi-Fi conflict described in the ADC post linked below.

Peripheral count decides real projects. A robot with two motors, an ultrasonic sensor, a line sensor and a display needs more pins and more PWM channels than an ESP8266 board comfortably provides. The ESP32 provides them with pins to spare.

Which radios does each chip have?

Both chips have 2.4 GHz Wi-Fi 4, 802.11 b/g/n. Neither has 5 GHz Wi-Fi. The ESP8266 has no Bluetooth radio of any kind. The ESP32 has Bluetooth Classic and Bluetooth LE 4.2. That difference alone decides many projects: a phone app over Bluetooth, a Bluetooth beacon, or a classic serial link needs the ESP32.

ESP-NOW, the Espressif peer to peer protocol, runs on both chips, so a simple ESP-NOW remote works on either. But an ESP-NOW project that also needs Bluetooth, a display or more memory still belongs on the ESP32.

What about power use?

Both chips draw low current in deep sleep at the chip level, and board level deep sleep current is higher because of the USB to serial chip, the voltage regulator and the power LED on the board. The ESP8266 draws 20 uA in deep sleep at the chip level, and the ESP32 draws about 10 uA. Neither chip wins on sleep current alone. The difference is what each chip can do while awake: the ESP32 finishes a Wi-Fi task faster on two cores at 240 MHz and returns to sleep sooner, while the ESP8266 takes longer at 80 MHz.

For a battery sensor that wakes once an hour, posts a reading and sleeps again, both chips work, and the ESP32-C3 or ESP32-C6 is often the better low power pick than either. For a mains powered device, power use is not the deciding factor at all.

When should you keep the ESP8266?

Keep the ESP8266 in three cases. First, you are maintaining a product or a fleet that already runs on it, and a redesign costs more than the benefit. Second, you need a drop in replacement for a failed ESP8266 board in a working project, such as a NodeMCU with an OLED display or an ESP-01S module in an existing socket. Third, you are teaching a class or a workshop with existing ESP8266 boards and existing lesson material, and the lessons fit in the available RAM.

In every other case, start on the ESP32. The ESP32 DevKit V1 is the general purpose pick. The ESP32-C3 SuperMini is the low cost pick for a simple Wi-Fi sensor. Both cost little more than an ESP8266 board and remove the RAM, pin and Bluetooth limits that cause most ESP8266 project failures.

How do you migrate a project from ESP8266 to ESP32?

Start by listing the pins your ESP8266 project uses, including the boot pins and the single ADC pin. Map each one to an ESP32 pin, and move any ADC2 pin to an ADC1 pin, GPIO 32 to 39, when Wi-Fi is in use. Next, check the libraries: most Arduino libraries for sensors and displays work on both chips, but Wi-Fi and web server code uses different headers, so expect a short porting pass. Then check RAM: code that was squeezed to fit 50 KB of heap will have room to breathe, but a hard coded small buffer may still limit a display or a JSON document, so raise those buffers after the move.

Test the migrated project on the bench before you deploy it. Wi-Fi signal strength, boot behaviour and deep sleep wake timing all differ between the chips. A project that worked on the bench on the ESP8266 can behave differently on the ESP32 if a pin that was safe on one board is a strapping pin on the other.

For the wider family picture, see the ESP32 family comparison.

FAQ

Is the ESP8266 discontinued?

No. Espressif marks the ESP8266 as Not Recommended for New Designs, which is not the same as discontinued. Espressif lists a minimum 15 year production commitment from January 1, 2014, so existing designs can still be supplied.

Is the ESP32 better than the ESP8266?

Yes, for new projects. The ESP32 has two cores at 240 MHz, 520 KB of SRAM, 34 GPIO pins, 18 ADC channels and Bluetooth Classic plus BLE. The ESP8266 has one core at 80 MHz, about 50 KB of usable RAM, 11 usable GPIO pins on common boards and no Bluetooth.

Can I use ESP8266 code on an ESP32?

Most sensor and display code ports with small changes. Wi-Fi, web server and pin code needs a porting pass, because the headers and the pin numbers differ. Test the ported code on the bench before you deploy it.

What replaces the ESP8266 for new designs?

Espressif recommends the ESP32-C2 as the direct upgrade. At board level, the ESP32-C3 is the closest low cost equivalent, with a single RISC-V core, 400 KB of SRAM and Bluetooth LE 5.

Does the ESP-01S still have a use?

Yes, as a Wi-Fi add-on or a drop in replacement in an existing ESP-01 socket. It is a single purpose module with very few usable GPIO pins, so it suits a simple serial to Wi-Fi bridge, not a new multi sensor project.

Parts used

ESP8266 NodeMCU Development Board, 6-Pack: the NodeMCU board for maintaining existing ESP8266 projects. ESP32 DevKit V1 Development Board, 30-Pin WROOM-32: the ESP32 board for new projects that need more pins, RAM and Bluetooth. ESP8266 ESP-01S WiFi Module: the small ESP-01S module for serial to Wi-Fi bridges and drop in replacements.

Sources

Last updated: 2026-11-21. Search volume: not verified. Product links use the store short link form with the product ID; confirm the product slug at publish time.

ESP32-CAM Pinout: Camera, SD Card, and Free GPIO Pins

ESP32-CAM board with OV2640 camera module and pin headers. Caption: ESP32-CAM board with OV2640 camera module. Description: Front view of the ESP32-CAM board used in this pinout guide.

ESP32-CAM Pinout: Camera, SD Card, and Free GPIO Pins

Answer in brief: The ESP32-CAM uses most of its GPIO pins for the camera and the microSD card. Only a small set of pins stays free for sensors and outputs. This guide maps the camera pins, the SD card pins, and the free pins. It also covers power, boot mode, and safe wiring.

Quick Facts

Item Detail Source
Board AI-Thinker ESP32-CAM Espressif ESP32 Series Datasheet
Logic voltage 3.3 volts Espressif ESP32 Series Datasheet
USB port None on board ESP32-CAM camera driver pin map
Programming pins GPIO1 TX and GPIO3 RX ESP32-CAM camera driver pin map
Flash mode pin GPIO0 held low at reset ESP32-CAM camera driver pin map
Camera pins used 15 pins ESP32-CAM camera driver pin map
SD card pins in 4-bit mode 6 pins ESP32-CAM camera driver pin map
SD card pins in 1-bit mode 3 pins ESP32-CAM camera driver pin map
Free pins with no SD card 6 pins ESP32-CAM camera driver pin map

ESP32-CAM Pinout Table

This table is an original pinout table built from the source data listed below. It is not a copied image. Check the board print against this table before you wire anything. Some boards print VCC on one header and 5V on the other header.

Header pin label GPIO Function Notes
5V Power 5 volt input Use a stable 5 volt supply
GND Power Ground Common ground for all wiring
GPIO12 GPIO12 SD DATA2, ADC, touch Free only when SD card is not used
GPIO13 GPIO13 SD DATA3, ADC, touch Free only when SD card is not used
GPIO15 GPIO15 SD CMD, ADC, touch, strapping Free only when SD card is not used
GPIO14 GPIO14 SD CLK, ADC, touch Free only when SD card is not used
GPIO2 GPIO2 SD DATA0, ADC, touch, strapping Free only when SD card is not used
GPIO4 GPIO4 SD DATA1, ADC, touch Free only when SD card is not used
3V3 Power 3.3 volt output Do not use as a 5 volt input
GPIO16 GPIO16 PSRAM chip select Do not use for other wiring
GPIO0 GPIO0 Camera XCLK, strapping, boot Hold low at reset for flash mode
GND Power Ground Common ground for all wiring
VCC Power 5 volt input Same 5 volt rail as the 5V pin
U0R GPIO3 UART receive Connect to adapter TX for programming
U0T GPIO1 UART transmit Connect to adapter RX for programming
GND Power Ground Common ground for all wiring

Power Pins

The board takes 5 volts through the 5V pin or the VCC pin. Both pins sit on the same 5 volt rail on this board. Use one 5 volt input at a time. Do not feed 5 volts into the 3V3 pin. That mistake can damage the board.

Strapping and Boot Pins

GPIO0 controls flash mode. Hold GPIO0 low at reset to enter flash mode. Release it after programming starts. Normal run mode needs GPIO0 high or floating at reset. A jumper wire to ground works for this step. Remove the jumper after the upload.

GPIO0 also carries the camera clock, XCLK. That dual role is normal on this board. Do not add a permanent pull-down to GPIO0. A permanent pull-down would force flash mode at every reset. Use a temporary jumper only during programming.

GPIO2 and GPIO15 are also strapping pins. They share SD card duties on this board. Keep them free of strong pull-downs at boot when the SD card is in use. Check the Espressif ESP32 Series Datasheet for the full strapping table before you add boot-time wiring.

Camera Pins

The camera uses 15 pins on this board. Those pins are fixed. Do not reassign them to other parts. The list below is the camera driver pin map for the AI-Thinker board.

Camera signal GPIO Notes
Data D0 GPIO5 Camera data line
Data D1 GPIO18 Camera data line
Data D2 GPIO19 Camera data line
Data D3 GPIO21 Camera data line
Data D4 GPIO36 Camera data line, input only
Data D5 GPIO39 Camera data line, input only
Data D6 GPIO34 Camera data line, input only
Data D7 GPIO35 Camera data line, input only
XCLK GPIO0 Camera clock, also boot pin
PCLK GPIO22 Camera pixel clock
VSYNC GPIO25 Camera vertical sync
HREF GPIO23 Camera horizontal reference
SDA GPIO26 Camera control bus data
SCL GPIO27 Camera control bus clock
PWDN GPIO32 Camera power down control

SD Card Pins

The microSD slot uses 6 pins in 4-bit mode. That mode gives the fastest SD writes on this board. The 6 pins are GPIO14, GPIO15, GPIO2, GPIO4, GPIO12, and GPIO13. All 6 pins are then busy. No free GPIO remains from that set while 4-bit mode runs.

SD signal GPIO Mode
CLK GPIO14 4-bit and 1-bit
CMD GPIO15 4-bit and 1-bit
DATA0 GPIO2 4-bit and 1-bit
DATA1 GPIO4 4-bit only
DATA2 GPIO12 4-bit only
DATA3 GPIO13 4-bit only

Free GPIO Pins

Free pins depend on SD card use. With no SD card, 6 pins are free. Those pins are GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15. With 1-bit SD mode, 3 pins are free. Those pins are GPIO4, GPIO12, and GPIO13. With 4-bit SD mode, none of those 6 pins are free.

GPIO33 is the red LED pin. You can blink it in code. It is not a good general output for a load. GPIO16 is the PSRAM chip select. Leave GPIO16 alone. GPIO32 is the camera power-down pin. Leave it under camera driver control.

ADC, Touch, and PWM

GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15 all support ADC input. They also support touch input on the ESP32 chip. That overlap is useful. It is also a limit. A pin in SD use cannot serve as an ADC input at the same time.

I2C, SPI, and UART

The camera control bus uses GPIO26 for SDA and GPIO27 for SCL. Those pins are busy. Do not add a second I2C device on the same two pins without checking the camera driver first. A shared bus can clash with camera control.

USB and Programming

This board has no USB port. Program it with a 3.3 volt USB-to-serial adapter. Set the adapter to 3.3 volts. A 5 volt adapter setting can damage the 3.3 volt logic. Check the adapter jumper before every upload.

Connect adapter TX to board U0R, which is GPIO3. Connect adapter RX to board U0T, which is GPIO1. Connect ground to ground. Connect adapter 3.3 volt output only if the adapter can supply enough current. A separate 5 volt supply on the 5V pin is often more stable.

Hold GPIO0 low. Press reset. Start the upload. Release GPIO0 after the upload starts. Remove the GPIO0 jumper after the upload ends. Press reset once more to run the new code. For a full setup walkthrough, see the live post How to Start with ESP32-CAM for WiFi Camera Projects (live post #15173). For the flash steps in detail, see the live post ESP32-CAM Flashing and First Camera Stream: From Unboxing to WiFi Video (live post #22720).

How to flash the ESP32-CAM

The ESP32-CAM has no USB port, so every flash goes through its UART pins, GPIO1 (U0T) and GPIO3 (U0R). The board enters download mode only when GPIO0 is held low at reset.

Method 1: ESP32-CAM-MB programmer (easiest)

The ESP32-CAM-MB is a carrier board with the same footprint as the ESP32-CAM. It carries a CH340G USB-to-UART chip and two buttons, IO0 and RST. Seat the ESP32-CAM on the MB, connect it to your computer with a USB cable, and flash from the Arduino IDE as normal. No jumper wires are needed.

Hold IO0, press and release RST, then release IO0 to enter download mode. Start the upload, then press RST once to run the new code. If the upload works without the button sequence, skip it; some MB boards enter download mode on their own.

Two MB facts to know. First, the MB 5V pin sometimes cannot supply enough current for a flash, so power the board from a separate 5V supply if an upload fails partway. Second, the MB can hold GPIO0 low through the CH340 DTR line, so remove the ESP32-CAM from the MB and power it from a 5V supply to run it.

Method 2: USB-to-serial adapter (FTDI, CH340, or CP2102)

A USB-to-serial adapter works with any ESP32-CAM that has no MB. Set the adapter to 3.3 volts first; a 5 volt setting can damage the 3.3 volt pins.

Adapter pin ESP32-CAM pin Notes
TX U0R (GPIO3) Adapter TX to board RX
RX U0T (GPIO1) Adapter RX to board TX
GND GND Common ground
3.3V Leave unconnected Power the board from a separate 5V supply

Connect a jumper from GPIO0 to GND. Press the reset button on the board, or power-cycle it, with the jumper in place. Start the upload. Remove the GPIO0 jumper after the upload starts, then press reset once more to run the new code. If the upload fails, lower the upload speed to 115200 baud and check that the driver for your chip (FTDI, CH340, or CP2102) is installed.

Method 3: esptool.py from the command line

esptool.py is Espressif’s official flashing tool, and the Arduino IDE uses it under the hood. Use it to flash a prebuilt binary or erase the flash. Install it with pip install esptool, then put the board in download mode with the GPIO0 jumper method above.

Check the connection first. esptool.py --port COM3 flash_id (use your own port, such as /dev/ttyUSB0 on Linux) prints the flash size and confirms the board answers. Erase with esptool.py --chip esp32 --port COM3 erase_flash. Erasing is the fix when a board holds a bad sketch that keeps crashing at boot.

Flash a full build with one command. The classic ESP32 addresses are bootloader 0x1000, partitions 0x8000, boot_app0 0xe000, app 0x10000:

esptool.py -p COM3 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/app.bin

Flash only the app: esptool.py -p COM3 -b 460800 --chip esp32 write_flash --flash_mode dio --flash_size detect 0x10000 build/app.bin. A merged or factory binary already contains all four parts, so flash it at 0x0. Flashing it at 0x10000 makes it overflow the end of the flash.

Arduino IDE settings for the ESP32-CAM

These settings apply to every Arduino IDE flash. Install the ESP32 board package from the Boards Manager with the URL https://espressif.github.io/arduino-esp32/package_esp32_index.json, then set the following under Tools.

Setting Value Why
Board AI Thinker ESP32-CAM Selects the AI-Thinker pin map and PSRAM
Port Your USB-serial port The MB or adapter port, not a Bluetooth port
Upload Speed 921600 Fast uploads; drop to 115200 if uploads fail
Partition Scheme Huge APP (3MB No OTA/1MB SPIFFS) CameraWebServer is too big for the default 1.2MB app slot
Flash Size 4MB Matches the ESP32-CAM flash chip
PSRAM Enabled The camera frame buffer lives in PSRAM

The partition scheme is the setting that catches most people. The default scheme gives the app about 1.2 MB, and CameraWebServer is larger than that, so the IDE stops with “Sketch too big”. Huge APP gives the app about 3 MB and drops OTA updates. Set it once and leave it.

Flash errors and what they mean

A failed upload usually means the board never entered download mode, the power dipped, or the app does not fit.

Message Meaning Fix
Failed to connect to ESP32: Timed out waiting for packet header The board never entered download mode (esptool may report boot mode 0x13) Hold GPIO0 low at reset, check the cable is a data cable, install the CH340 or CP2102 driver, try a lower upload speed
Sketch too big The app is larger than the partition scheme allows Set Partition Scheme to Huge APP (3MB No OTA/1MB SPIFFS)
Camera init failed The flash worked but the camera did not start See the troubleshooting post
Brownout detector was triggered The power supply dipped during WiFi or camera start Use a stable 5V supply rated at 2A or more

Camera init failures and brownouts after a good flash are covered here: https://qualityrcparts.com/esp32-cam-troubleshooting-brownout-camera-init-failed/

Pins to Avoid

Avoid GPIO16 for any new wiring. It is the PSRAM chip select. Avoid GPIO32 for general use. It controls camera power down. Avoid GPIO0 as a permanent output. It is the boot pin and the camera clock.

Avoid GPIO36, GPIO39, GPIO34, and GPIO35 as outputs. They are input-only pins. Avoid GPIO6 through GPIO11. Those pins connect to the on-board flash memory. They do not appear on the headers. Do not try to use them.

Avoid 5 volt logic on any GPIO pin. This board uses 3.3 volt logic. A 5 volt signal needs a level shifter. A direct 5 volt input can damage the pin.

Max Current and Logic Voltage

Logic voltage is 3.3 volts on every GPIO pin. That value comes from the Espressif ESP32 Series Datasheet. Treat 3.3 volts as the high level. Treat 0 volts as the low level. Keep sensor outputs at 3.3 volts or below.

At the strongest drive setting, a GPIO pin sources about 40 mA (IOH) and sinks about 28 mA (IOL), per Table 5-4 of the Espressif ESP32 Series Datasheet v5.3. Those are drive-strength values at 3.3 volts, not a recommended continuous load. Cumulative IO output current for the chip is 1200 mA at absolute maximum, per section 5.1 of the same datasheet. Treat a small LED through a resistor as the practical per-pin load, not 40 mA.

Use a transistor or a driver for any load above a small LED. Keep LED current low with a series resistor. A 220 ohm resistor is a common bench value for a 3.3 volt LED test. Check the LED datasheet for its own forward voltage before you pick a resistor.

Wiring and Power Warnings

Power the board before you connect a 5 volt sensor. Keep the USB-to-serial adapter at 3.3 volts. Double-check the adapter jumper. A wrong jumper is a fast way to damage the board.

Keep wires short. Use a cable under 3 feet for bench tests when you can. Long wires pick up noise. Noise causes SD errors and camera glitches. Twist power and ground wires together when the run is long.

Pin Test Sketch

Language: Arduino. Library: Arduino ESP32 core version 2.0.14, with the built-in esp_camera driver. No extra library install is needed for this test. Code status: COMPILED with PlatformIO 6.2.0 (espressif32, board esp32cam) on 2026-11-22, SUCCESS in 30.18 seconds (RAM 10.4%, Flash 11.7%).

// ESP32-CAM pin test sketch
// Board: AI-Thinker ESP32-CAM
// Arduino ESP32 core version 2.0.14
// Code status: COMPILED with PlatformIO 6.2.0, esp32cam, 30.18 seconds

#include "esp_camera.h"

// Camera pin map for the AI-Thinker board.
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22

// Free pin test uses GPIO4 when no SD card is fitted.
// GPIO4 is SD DATA1 in 4-bit mode, so remove the card first.
const int testPin = 4;

void setup() {
  // Start serial at 115200 baud for debug output.
  Serial.begin(115200);
  delay(1000); // Wait 1 second for the monitor to open.

  // Set the test pin as an output and blink the red LED pin.
  pinMode(testPin, OUTPUT);
  pinMode(33, OUTPUT);

  // Start the camera with a small frame size for the test.
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000; // 20 megahertz camera clock.
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_QVGA; // Small size for a fast test.
  config.jpeg_quality = 12; // Lower number means higher quality.
  config.fb_count = 1;

  // Report the camera start result on serial.
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed, error 0x%x\n", err);
    return;
  }
  Serial.println("Camera init OK");
}

void loop() {
  // Blink the test pin and the red LED pin in turn.
  digitalWrite(testPin, HIGH);
  digitalWrite(33, LOW);
  delay(500); // Wait 500 milliseconds.
  digitalWrite(testPin, LOW);
  digitalWrite(33, HIGH);
  delay(500); // Wait 500 milliseconds.
  Serial.println("Pin test tick");
}

Expected result: the serial monitor shows “Camera init OK” and then a tick line each 1 second. The red LED blinks in turn with the test pin. If camera init fails, check the ribbon cable seating first. Then check the 5 volt supply.

Frequently Asked Questions

How many free GPIO pins does the ESP32-CAM have?

It has 6 free pins with no SD card. The pins are GPIO2, GPIO4, GPIO12, GPIO13, GPIO14, and GPIO15. The count drops to 3 pins in 1-bit SD mode. It drops to 0 pins from that set in 4-bit SD mode.

Can I use GPIO0 as a normal output?

No, not as a normal output. GPIO0 is the boot pin and the camera clock. It must be high at reset for normal run mode. Use a free pin from the SD set instead.

Why does my ESP32-CAM reset when WiFi starts?

A weak 5 volt supply is the most common cause. WiFi draws a current spike at start. Use a stable 5 volt supply rated at 1 ampere or more. Keep wires short and check the ground.

Does the ESP32-CAM have a USB port?

No, it has no USB port. Program it with a 3.3 volt USB-to-serial adapter. Connect adapter TX to U0R and adapter RX to U0T. Hold GPIO0 low at reset for flash mode.

How do I flash the ESP32-CAM with the ESP32-CAM-MB?

Seat the ESP32-CAM on the MB, connect it to your computer, and upload from the Arduino IDE. Hold IO0, press and release RST, then release IO0 to enter download mode. Press RST once after the upload to run the code. If the board will not run while seated in the MB, remove it and power it from a 5V supply.

Which USB-to-serial adapter works with the ESP32-CAM?

Any FTDI, CH340, or CP2102 adapter works, as long as you set it to 3.3 volts and wire TX to U0R (GPIO3), RX to U0T (GPIO1), and GND to GND. Power the board from a separate 5V supply. Hold GPIO0 low at reset to enter download mode, and remove the jumper after the upload starts.

Why does the Arduino IDE say “Sketch too big” for CameraWebServer?

The default partition scheme gives the app about 1.2 MB, and CameraWebServer is larger than that. Set Tools, Partition Scheme to Huge APP (3MB No OTA/1MB SPIFFS). That gives the app about 3 MB and drops OTA updates, which a first flash does not need.

What flash addresses does esptool use for the ESP32-CAM?

Bootloader at 0x1000, partition table at 0x8000, boot_app0 at 0xe000, and the app at 0x10000. A merged or factory binary already contains all four parts, so flash it at 0x0. Flashing a merged binary at 0x10000 makes it overflow the end of the flash.

Why does my ESP32-CAM stay in download mode after flashing?

GPIO0 is still held low. Remove the GPIO0 to GND jumper, or remove the board from the MB carrier, then press reset once. The board boots normally when GPIO0 is high or floating at reset.

Boards That Match This Pinout

These boards use the pinout in this guide. Check the product page for current stock before you order. Stock changes over time.

Related reading: compare this board with the wider ESP32 family in the staged pillar ESP32 vs ESP32-S3 vs ESP32-C3 vs ESP32-C6 (row 22, staged). For sibling pinouts, see How to Use the ESP32 DevKit V1 Board for WiFi Projects and XIAO ESP32S3 Pinout.

Parts used in this guide

Related guides: flashing walkthrough https://qualityrcparts.com/esp32-cam-flashing-first-camera-stream/, troubleshooting https://qualityrcparts.com/esp32-cam-troubleshooting-brownout-camera-init-failed/, CAM vs S3-CAM comparison https://qualityrcparts.com/esp32-cam-s3-cam-camera-projects-guide/, pillar https://qualityrcparts.com/which-esp32-should-i-buy/, DevKit V1 pinout https://qualityrcparts.com/esp32-devkit-v1-pinout/, S3 DevKitC-1 pinout https://qualityrcparts.com/esp32-s3-devkitc-1-pinout/

Sources

  • Espressif ESP32 Series Datasheet v5.3, https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
  • ESP32-CAM camera driver pin map, Espressif Arduino ESP32 core, https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Camera/CameraWebServer/camera_pins.h

Last updated 2026-11-22.

ESP32-S2 Mini Pinout: GPIO, USB OTG, and ADC

ESP32-S2 Mini development board with USB-C port and pin headers. Caption: ESP32-S2 Mini board, front view with USB-C port. Description: Top view of the ESP32-S2 Mini board used in this pinout guide.

ESP32-S2 Mini Pinout Guide: GPIO, USB OTG, and ADC

The ESP32-S2 Mini pinout starts with one clear limit: this chip has WiFi only, and it has no Bluetooth. The ESP32-S2 chip has 43 GPIO pins. It runs a single-core Xtensa LX7 core at 240 MHz. Native USB OTG uses GPIO19 and GPIO20. DAC uses GPIO17 and GPIO18.

Quick facts

Item Value Source
Chip GPIO count 43 GPIO pins ESP32-S2 Series Datasheet
Core Single-core Xtensa LX7 at 240 MHz ESP32-S2 Series Datasheet
Radios WiFi only, no Bluetooth ESP32-S2 Series Datasheet
Logic voltage 3.3 volts ESP32-S2 Series Datasheet
USB OTG pins GPIO19 D- and GPIO20 D+ ESP32-S2 Series Datasheet
ADC1 pins GPIO1 to GPIO10 ESP32-S2 Series Datasheet
ADC2 pins GPIO11 to GPIO20 ESP32-S2 Series Datasheet
DAC pins GPIO17 and GPIO18 ESP32-S2 Series Datasheet
UART0 pins GPIO43 TX and GPIO44 RX ESP32-S2 Series Datasheet
Strapping pins GPIO0, GPIO45, GPIO46 ESP32-S2 Series Datasheet
Module GPIO count 37 GPIO pins on ESP32-S2-MINI-2 ESP32-S2-MINI-2 Datasheet v1.4
Module flash 4 MB flash, optional 2 MB PSRAM ESP32-S2-MINI-2 Datasheet v1.4

ESP32-S2 Mini pinout table

Use this table as the chip reference. Match each GPIO number to the silkscreen on your board before you wire it.

GPIO Main role Notes
GPIO0 Strapping and boot Hold low at reset for download mode
GPIO1 to GPIO10 ADC1 channels 0 to 9 Analog input, 3.3 volt max
GPIO11 to GPIO16 ADC2 channels 0 to 5 ADC2 shares use with WiFi
GPIO17 ADC2 channel 6, DAC channel 1 True analog output pin
GPIO18 ADC2 channel 7, DAC channel 2 True analog output pin
GPIO19 ADC2 channel 8, USB OTG D- Native USB, not an ADC pin in use
GPIO20 ADC2 channel 9, USB OTG D+ Native USB, not an ADC pin in use
GPIO21 to GPIO32 General GPIO Check board silkscreen for exposure
GPIO33 to GPIO42 General GPIO Check board silkscreen for exposure
GPIO43 UART0 TX Serial transmit pin
GPIO44 UART0 RX Serial receive pin
GPIO45 Strapping Check level at boot
GPIO46 Strapping Check level at boot

The header order on the LOLIN S2 Mini board follows the WEMOS S2 Mini schematic V1.0.0. Each side has two rows of 8 pins. J2 is the right outer row, J5 the right inner row, J4 the left inner row, and J3 the left outer row, with pin 1 at the top of each row in the schematic.

Header Pin order, top to bottom
J2, right outer EN, GPIO3, GPIO5, GPIO7, GPIO9, GPIO11, GPIO12, 3V3
J5, right inner GPIO1, GPIO2, GPIO4, GPIO6, GPIO8, GPIO10, GPIO13, GPIO14
J4, left inner GPIO40, GPIO38, GPIO36, GPIO34, GPIO21, GPIO17, GND, GPIO15
J3, left outer GPIO39, GPIO37, GPIO35, GPIO33, GPIO18, GPIO16, GND, VBUS

That is 27 GPIO pins on the headers in total. GPIO0 is not on the headers; it is the BOOT button only. GPIO15 carries the blue onboard LED. Check the silkscreen on your board against this table before you wire it.

Power pins

Power the board through the USB-C port at 5 volts. The board steps that input down to 3.3 volts for the chip through an ME6211C33 regulator, per the WEMOS S2 Mini schematic V1.0.0. The ME6211 is a 500 milliampere class LDO, so treat 500 milliamperes as the ceiling for the whole 3.3 volt rail, chip included, and keep external 3.3 volt loads well below it. Do not feed 5 volts into any GPIO pin. Use a short USB cable under 3 feet long for stable uploads. Power motors and servos from a separate supply, not from the board. Share a common ground between the board and that supply. Check the silkscreen for the 5 volt, 3.3 volt, and ground labels on your board.

Strapping and boot pins

Strapping pins set the boot mode at reset. The ESP32-S2 strapping pins are GPIO0, GPIO45, and GPIO46, per the ESP32-S2 Series Datasheet. GPIO0 low at reset enters download mode for flashing. GPIO0 high at reset starts the normal sketch. Do not tie a strapping pin hard to 3.3 volts or ground. Keep boot pins free during the first test. If the board will not boot, remove wires from GPIO0, GPIO45, and GPIO46 first. Then test the board with no wires attached.

ADC pins

ADC1 uses GPIO1 to GPIO10, per the ESP32-S2 Series Datasheet. Use ADC1 for analog sensors when WiFi is on. ADC2 uses GPIO11 to GPIO20, per the same datasheet. ADC2 does not work well while WiFi runs. Keep analog input at or below 3.3 volts. Use a voltage divider for a sensor that outputs more than 3.3 volts. Do not use GPIO19 and GPIO20 as ADC inputs, since they carry USB OTG.

DAC and touch pins

DAC uses GPIO17 and GPIO18, per the ESP32-S2 Series Datasheet v1.9. Those two pins give a true analog voltage output. Use them for a simple analog test or a low-speed analog signal. Touch uses GPIO1 to GPIO14, which are TOUCH1 to TOUCH14, per the ESP32-S2 Series Datasheet v1.9, section 2.3.4. All 14 touch pins double as ADC pins: GPIO1 to GPIO10 are ADC1, and GPIO11 to GPIO14 are ADC2 channels 0 to 3.

PWM pins

Most GPIO pins can output PWM through the LEDC driver in the Arduino core. Pick a free GPIO pin that is not a strapping pin, a USB pin, or a DAC pin. Use a 5,000 Hz frequency for an LED test. Use a 50 Hz frequency for a servo signal. Drive a motor through a driver board, never direct from a GPIO pin. See the ESP32 family comparison for how the S2 differs from the S3 on Bluetooth and USB.

I2C pins

I2C can use most GPIO pins on the ESP32-S2, per the ESP32-IDF GPIO reference. No fixed SDA and SCL pins are stated in the verified source data for this post. Pick two free GPIO pins and set them in code. Add pull-up resistors of 4.7 kilo-ohms to 3.3 volts on SDA and SCL if your sensor board lacks them. Keep I2C wires under 1 foot long where you can. Use 3.3 volt I2C sensors only. For the I2C protocol behind the wiring, see I2C vs SPI vs UART: Which Protocol for Your Sensor or Display.

SPI pins

SPI can also use most GPIO pins on the ESP32-S2, per the ESP32-IDF GPIO reference. No fixed MOSI, MISO, SCK, and CS pins are stated in the verified source data for this post. Pick free GPIO pins and set them in code. Use one CS pin per SPI device. Start at a low clock speed, such as 1,000,000 Hz. Use 3.3 volt SPI devices only.

UART pins

UART0 uses GPIO43 for TX and GPIO44 for RX, per the ESP32-S2 Series Datasheet. UART0 is the main serial port for debug output. A second UART can use other free GPIO pins in code. Keep UART wires crossed: TX on one board goes to RX on the other board. Use 3.3 volt UART signals only. Set both ends to the same baud rate, such as 115,200 baud.

USB pins

Native USB OTG uses GPIO19 for D- and GPIO20 for D+, per the ESP32-S2 Series Datasheet. The S2 Mini board brings these pins to a USB-C port. Use that port for flashing and for serial output. Do not use GPIO19 or GPIO20 for sensors. Use a data-capable USB cable, not a charge-only cable. Use a cable under 3 feet long for uploads. USB OTG lets the board act as a USB host for some devices, but that needs host code. The pin test sketch below uses the port for serial only.

Pins to avoid

Avoid GPIO0, GPIO45, and GPIO46 for sensors that pull the pin low at boot. Avoid GPIO19 and GPIO20 for sensors, since they carry USB OTG. Avoid ADC2 pins GPIO11 to GPIO20 for analog reads while WiFi is on. Avoid GPIO17 and GPIO18 for digital loads if you need DAC output. Avoid 5 volt signals on every GPIO pin. The chip uses 3.3 volt logic only. If a pin is not on the board silkscreen, leave it alone and pick an exposed GPIO pin instead.

Max current and logic voltage

Logic voltage is 3.3 volts on all GPIO pins, per the ESP32-S2 Series Datasheet v1.9. At the strongest drive setting, a GPIO pin sources about 40 mA (IOH) and sinks about 28 mA (IOL), per Table 5-4 of the same datasheet. Those are drive-strength values at 3.3 volts, not a recommended continuous load, and the default drive strength is 20 mA. Treat a small LED through a resistor as the practical per-pin load, not 40 mA. Drive a relay, a motor, or a servo through a driver or a transistor. The 3.3 volt rail ceiling is 500 milliamperes from the ME6211C33 regulator, per the WEMOS S2 Mini schematic V1.0.0.

Wiring and power warnings

Check the voltage of every sensor before you wire it. A 5 volt sensor output can harm a 3.3 volt GPIO pin. Remove power before you move wires. Do not short the 3.3 volt pin to ground. If the board smells hot, unplug it at once. Use a separate supply for motors and servos. Share only the ground wire between supplies. Keep the board on a non-metal surface while you test it.

Pin test sketch

This sketch blinks an external LED on GPIO4 and reads ADC1 on GPIO1. It uses only the Arduino core for ESP32, version 3.3.13. No extra library is needed. Wire the LED anode to GPIO4 through a 220 ohm resistor. Wire the LED cathode to ground. Wire a potentiometer wiper to GPIO1. Code status: code not compiled. No Arduino CLI or PlatformIO is installed here, so compilation was not run.

// ESP32-S2 Mini pin test sketch
// Board: ESP32-S2 Mini, Arduino core for ESP32 version 3.3.13
// Code status: code not compiled
// LED on GPIO4, ADC input on GPIO1, serial at 115200 baud
const int ledPin = 4; // GPIO4, plain digital pin
const int adcPin = 1; // GPIO1, ADC1 channel 0
void setup() {
  Serial.begin(115200); // Start serial for test output
  pinMode(ledPin, OUTPUT); // Set LED pin as output
  delay(500); // Wait 500 ms for serial to settle
}
void loop() {
  digitalWrite(ledPin, HIGH); // Turn LED on
  int adcValue = analogRead(adcPin); // Read ADC1 on GPIO1
  Serial.print("ADC1 GPIO1 value: "); // Label the reading
  Serial.println(adcValue); // Print raw ADC count
  delay(500); // Wait 500 ms with LED on
  digitalWrite(ledPin, LOW); // Turn LED off
  delay(500); // Wait 500 ms with LED off
}

If the LED blinks and the serial monitor shows ADC values that change with the potentiometer, GPIO4 and GPIO1 both work. If the LED stays dark, check the resistor value and the LED polarity. If the ADC value stays at 0, check the potentiometer wiring to GPIO1.

Frequently asked questions

Does the ESP32-S2 Mini have Bluetooth?

No, the ESP32-S2 chip has WiFi only and no Bluetooth, per the ESP32-S2 Series Datasheet. Do not use Bluetooth code on this board. Use WiFi or USB for a wireless link instead.

Which pins are safe for a first sensor on the ESP32-S2 Mini?

Use ADC1 pins GPIO1 to GPIO10 for analog sensors, per the ESP32-S2 Series Datasheet. Use GPIO4 for a plain digital test. Keep strapping pins, USB pins, and DAC pins free unless you need them.

Can the ESP32-S2 Mini use 5 volt sensors?

No, the GPIO pins use 3.3 volt logic only, per the ESP32-S2 Series Datasheet. A 5 volt signal can harm a GPIO pin. Use a level shifter or a voltage divider for a 5 volt sensor.

Why does my board fail to boot after I add wiring?

A strapping pin may be held low at reset. The strapping pins are GPIO0, GPIO45, and GPIO46, per the ESP32-S2 Series Datasheet. Remove wires from those pins and test the board with no wires attached.

Why does ADC2 read poorly when WiFi is on?

ADC2 shares hardware with WiFi on the ESP32-S2, per the ESP32-S2 Series Datasheet. ADC2 uses GPIO11 to GPIO20. Use ADC1 pins GPIO1 to GPIO10 for reads while WiFi runs.

Can I use GPIO19 and GPIO20 for a sensor?

No, GPIO19 and GPIO20 carry native USB OTG on this board, per the ESP32-S2 Series Datasheet. Use them only for USB. Pick a different free GPIO pin for the sensor.

Product callout

Start with the ESP32-S2 Mini Development Board for a first board at the bench. For a single spare, see the ESP32-S2 Mini Development Board Single. For a bench stock of boards, see the ESP32-S2 Mini Development Board 10-Pack. Check stock on the product page at order time.

Sources

Last updated: 2026-11-21. Status: STAGED ONLY, zero live writes, zero publishes.

For the classic 30-pin board, see the ESP32 DevKit V1 pinout guide.