ESP32-S3 Face Detection Guide: XIAO Sense and S3-CAM

The ESP32-S3 can look at a camera frame and tell you where the faces are, on the chip itself, with no cloud account and no video leaving the board.

This guide covers what the ESP32-S3 can and cannot do with faces, detection vs recognition, which boards work, the no-code and Arduino routes, and the mistakes that waste the most time. Nothing here needs a paid app or a cloud account for the on-device routes.

What is face detection on the ESP32-S3, and what can it actually do?

Face detection on the ESP32-S3 means a small neural network model runs on the chip, looks at each camera frame, and returns a box around every face it finds, plus a confidence score for each box. Your code gets the boxes: light an LED, count people, trigger a relay, send an MQTT message, or save a snapshot.

It works on the ESP32-S3 and not well on the classic ESP32 because of the hardware. The ESP32-S3 has vector instructions that speed up neural network math, and camera boards built on it carry 8 MB of PSRAM, which holds the frame and the model weights. Source: Espressif edge AI workshop and ESP-WHO docs.

Detection runs on small frames. The models are trained on small inputs, so the camera captures at a low resolution for inference even when the sensor can shoot much higher. Espressif’s workshop lists QVGA (320 by 240) as the typical frame size for face detection and HVGA (480 by 320) for face recognition. Source: Espressif edge AI workshop, Assignment 4.

What is the difference between face detection and face recognition?

Detection and recognition are two different jobs, and mixing them up is the most common source of disappointment with these boards.

Face detection answers “is there a face in this frame, and where”. It returns boxes and confidence scores and knows nothing about who the person is. A doorbell that lights up when someone approaches and a people counter at a doorway need detection only.

Face recognition answers “whose face is this”. It runs detection first, then turns each detected face into a numerical embedding and compares it against faces you enrolled earlier. You show the board each person’s face and give it a name, and the board stores the result. A door lock that opens for family members needs recognition.

Recognition is harder, slower, and more fragile than detection. It needs the face to be larger in the frame, better lit, and facing the camera more directly. It also stores face data on the board: tell everyone in the household what the camera stores, and do not use recognition to identify people who have not agreed to be enrolled. This guide gives no accuracy percentage for recognition, because no primary source we checked publishes one.

Task Question it answers Needs enrollment Typical use
Face detection Is there a face, and where No Doorbell alert, people counting, intruder alert
Face recognition Whose face is this Yes, one enrollment per person Door lock for family, attendance
Person detection Is there a person in frame No Room occupancy, trail camera trigger

Which ESP32-S3 boards work for face detection?

Any ESP32-S3 camera board with PSRAM can run a face detection model. The classic ESP32-CAM is the exception: on-device face detection models were removed from the Arduino ESP32 core version 3, so the classic board is a poor choice for new on-device face projects. It can still capture a picture and send it to a cloud API for detection. Source: Robojax tutorial.

Board Chip Camera PSRAM Face detection
XIAO ESP32S3 Sense ESP32-S3 detachable camera 8 MB Yes, on device
ESP32-S3-N16R8 CAM ESP32-S3 OV5640, 5 MP 8 MB Yes, on device
Classic ESP32-CAM ESP32 OV2640 4 MB Not recommended on device

The XIAO ESP32S3 Sense is the smallest option: an ESP32-S3 dual-core 240 MHz board with 8 MB PSRAM and 8 MB flash, a detachable camera, a digital microphone, a microSD slot, WiFi and Bluetooth 5.0, in a 21 by 17.5 mm footprint. The detachable camera matters: mount the tiny camera where the faces are and keep the board tucked away.

The ESP32-S3-N16R8 CAM is the larger, cheaper bench board: a dual-core ESP32-S3 with 16 MB flash plus 8 MB PSRAM and an OV5640 5 MP camera, with two USB-C ports that split OTG and serial duties, so it programs over USB with no adapter. The higher resolution sensor does not make detection better, because detection runs on small frames.

Which approach should you pick?

There are four working routes. Pick one row and follow its section.

Approach Code needed Toolchain Best for
SenseCraft AI (Seeed) None, deploy in a browser Web platform, USB cable Fastest first detection
Arduino IDE with esp-dl models Arduino sketch Arduino IDE, ESP32 core 2.0.17 Full control, offline recognition
ESP-WHO with ESP-IDF C, ESP-IDF project ESP-IDF v5.5.x Espressif reference examples
Cloud API detection Arduino sketch plus an API key Arduino IDE, internet Classic ESP32-CAM

How do I run face detection with SenseCraft AI, with no code?

SenseCraft AI is Seeed’s edge AI platform. It deploys a prebuilt model to a supported board from a browser, with no machine learning code and no toolchain install. This is the fastest route to a working face detector.

  1. Plug the XIAO ESP32S3 Sense into your computer with a USB-C data cable. A charge-only cable will power the board but the browser will never see it.
  2. Open the SenseCraft AI model page at https://sensecraft.seeed.cc/ai/model. Under Pretrained Models, set Task to Detection and Supported Devices to XIAO ESP32S3 Sense, then search “Face”.
  3. Pick the Swift-YOLO face detection model. As of July 2025 there were two face models listed, and the Makerguides tutorial reports only the Swift-YOLO one worked.
  4. Click Deploy Model, then Connect Device, pick the COM port the board is on, and confirm. The model downloads to the board in about 1 to 2 minutes. Source: Seeed SenseCraft AI wiki.
  5. The preview starts on its own, with bounding boxes drawn around detected faces in the live feed, each box carrying a confidence score.

Two settings control what counts as a detection. The confidence threshold filters detections by how sure the model is that something is a face: every detection scores 0 to 100 percent, and anything below the threshold is discarded. A lower threshold catches more faces but also flags more non-faces. The IoU (Intersection over Union) threshold decides which overlapping boxes to keep when the model draws several boxes around one face. Source: Makerguides tutorial.

SenseCraft models also offer outputs from the sidebar: a GPIO pin that goes high when a face is detected, serial output over UART, I2C or SPI with the face count and confidence, or MQTT over WiFi for a home automation system. GPIO is enough for a door opener or an alarm; MQTT is for Home Assistant. Source: Makerguides tutorial and Seeed wiki.

How do I run face detection with Arduino IDE?

Use the Arduino route when you want the detection inside your own sketch, for example a camera that also drives a relay or serves a web page. The Robojax XIAO face recognition tutorial is the clearest Arduino reference we found, and its settings are strict: get one wrong and the sketch will not compile or will not detect anything.

  1. Install Arduino IDE and add the ESP32 board package. In Boards Manager, install ESP32 core version 2.0.17. This version matters most: Espressif removed the on-device face detection models in core 3, so the project cannot compile there. Version 2.0.17 is the last 2.x release with both those models and the XIAO_ESP32S3 board definition. Source: Robojax tutorial.
  2. Select the board as XIAO_ESP32S3, not ESP32S3 Dev Module. The board definition carries the right camera pins and PSRAM settings.
  3. Set PSRAM to OPI PSRAM. It is off by default, and nothing works without it. Set Flash Size to 8 MB, Partition Scheme to Default with SPIFFS, USB CDC On Boot to Enabled, and Upload Speed to 921600, dropping to 460800 if uploads fail. Source: Robojax tutorial.
  4. Use the face detection models from the ESP32 core: HumanFaceDetectMSR01 as stage one to find candidate faces, and HumanFaceDetectMNP01 as stage two to refine the boxes and add five facial keypoints. The pipeline captures at 240 by 240 in RGB565, runs both stages, draws the boxes into the frame, then compresses to JPEG for streaming. Source: Robojax tutorial.
  5. Get the camera stream working before adding detection. Flash a plain camera sketch first and confirm the video shows in a browser. If the stream fails, the fault is in the camera setup, not the model. Our ESP32-S3-CAM setup guide covers the first-stream steps.

How do I add face recognition, so the board knows who it is?

Recognition adds two steps after detection: enroll faces, then match new faces against them.

Enrollment means showing the board each person’s face and storing the result. In the Robojax offline recognition project, enrollment happens from the board’s own web page: you type a name into a roster slot, point the camera at the person, and save. The board makes its own WiFi network for this, so no router and no internet are involved, and no face ever leaves the board. The stored data is a numerical embedding, not a photo, but it still identifies a person.

Matching means each new detected face is turned into an embedding and compared against every stored embedding. The EloquentEsp32cam docs describe the pipeline: align the face, generate a 512-dimensional embedding, compare it against stored embeddings, and return the best match if the similarity passes a threshold. Recognition typically takes 80 to 150 ms on ESP32-S3 hardware, for the recognition step alone. Source: EloquentEsp32cam DeepWiki docs.

The ESP-WHO framework is the Espressif reference route for recognition, with a state machine for ENROLL, RECOGNIZE, and DELETE operations. It targets ESP-IDF v5.5.x and the ESP32-S3 and ESP32-P4 chips. Source: Espressif ESP-WHO get started guide.

Do not use recognition as a security lock on its own. A small on-device model can be fooled by a printed photo, and no primary source we checked publishes a spoof resistance claim for these models. Keep a separate lock, code, or key for anything that must stay secure.

What are the accuracy and speed limits?

No source we checked publishes one tested accuracy number or one tested frame rate for ESP32-S3 face detection, so this guide gives neither as a universal claim. The limits below are what named sources state on their own setups.

  • Resolution for inference is small. Face detection runs at QVGA (320 by 240) and face recognition at HVGA (480 by 320) in Espressif’s workshop, and the Arduino recognition pipeline captures at 240 by 240. A face that is small in the frame will not be detected, whatever the sensor’s maximum resolution is. Source: Espressif edge AI workshop, Robojax tutorial.
  • Recognition is slower than detection. The EloquentEsp32cam docs state recognition typically takes 80 to 150 ms on ESP32-S3 hardware, for the recognition step alone, or roughly 7 to 12 recognitions per second before capture and streaming are counted. Source: EloquentEsp32cam DeepWiki docs.
  • Frame rate depends on resolution and settings. The Tokay Lite vendor page, for an ESP32-S3 camera board with 8 MB PSRAM, states its face detection model runs at 1 to 10 frames per second depending on resolution and settings. That is a vendor claim for their board, not a measured number for the XIAO Sense or the S3-N16R8 CAM. Source: Maxlab Tokay Lite page.
  • Lighting and angle matter more than the sensor. Faces that face the camera, are well lit, and fill a reasonable part of the frame detect reliably. Backlit faces, faces in profile, and faces at a steep angle do not. Test where the camera will live before mounting it permanently.

What are the common mistakes?

  • Using Arduino ESP32 core 3 for an on-device face sketch. The face detection models were removed in core 3. Use 2.0.17. If a sketch fails to compile with a missing face detect header, check the core version first.
  • Leaving PSRAM off. OPI PSRAM is off by default on the XIAO board definition, and the face pipeline will not run without it. Set it before the first upload.
  • Picking the wrong board definition. XIAO_ESP32S3, not ESP32S3 Dev Module. The wrong definition gives the wrong camera pins.
  • Running detection at full sensor resolution. The models are trained on small inputs. Capture small for detection.
  • Trusting recognition as the only lock. No spoof resistance claim exists for these small models. Keep a separate lock or code.

How do I troubleshoot face detection that does not work?

Work through this list in order.

The camera never shows a picture. Flash a plain camera sketch first. If that fails, the fault is wiring, pins, or power, not the model. Check the USB cable is a data cable and reseat the camera ribbon cable. Our ESP32-CAM getting started guide covers first-stream failures.

The sketch will not compile, missing human face detect headers. Check the ESP32 core version in Boards Manager. It must be 2.0.17 for the on-device face models. Source: Robojax tutorial.

The board boots but detection never fires. Check PSRAM is set to OPI PSRAM in the Arduino IDE tools menu, and that the frame size is 240 by 240 or QVGA. Then lower the confidence threshold and test with a face close to the camera, well lit, facing the lens.

Faces are detected but with many false positives. Raise the confidence threshold until non-faces stop triggering, then check real faces still trigger.

Which board should you buy?

  • Buy the XIAO ESP32S3 Sense if you want the smallest camera that runs face detection or the no-code SenseCraft AI route.
  • Buy the ESP32-S3-N16R8 CAM if you want the cheapest bench board, you prefer dual USB-C with no adapter, or you want the extra flash headroom.
  • Keep the classic ESP32-CAM if you only need to stream video or send a picture to a cloud API for detection.
  • Buy neither yet if you need to identify strangers, read faces at long range, or run a security system. No small on-device model does those jobs well. Our Arducam camera guide covers the Pi side.

Parts used in this guide

Prices and stock were verified live on qualityrcparts.com on 2026-11-21. All three items are in stock and purchasable.

Shipped fast and securely from our secure facility in Queensbury, NY. QRC ships within the USA only.

Related guides

FAQ

Can the ESP32-S3 do face detection? Yes. The ESP32-S3 runs small on-device face detection models with no cloud. Detection runs on small frames, typically QVGA (320 by 240) or 240 by 240. Source: Espressif ESP-WHO docs and edge AI workshop.

What is the difference between face detection and face recognition on ESP32-S3? Detection finds faces and returns boxes. Recognition identifies whose face it is by comparing it against faces you enrolled earlier. Detection needs no enrollment; recognition needs one per person, stores face embeddings on the board, and is slower and more sensitive to lighting and angle. Source: Espressif ESP-WHO docs, EloquentEsp32cam docs.

Which ESP32 board is best for face detection? The XIAO ESP32S3 Sense is the best small board, and the ESP32-S3-N16R8 CAM is the best cheap bench board. Both are ESP32-S3 with 8 MB PSRAM and run the same on-device models. The classic ESP32-CAM is not recommended for new on-device face work. Source: Robojax tutorial, QRC live listings.

Can I do face detection on ESP32-S3 with Arduino? Yes, with Arduino IDE and ESP32 core version 2.0.17. Core 3 removed the on-device face detection models, so 2.0.17 is required. Select XIAO_ESP32S3, set PSRAM to OPI PSRAM, and capture at 240 by 240. Source: Robojax tutorial.

Can the ESP32-S3 do face recognition offline? Yes. Recognition runs on the board with no internet: the Robojax offline project enrolls faces from the board’s own web page over its own WiFi network. No face data leaves the board. Source: Robojax tutorial, Espressif ESP-WHO docs.

How far away can the ESP32-S3 detect a face? No primary source we checked publishes a detection range in feet or meters. Detection depends on how large the face is in the small inference frame, plus lighting and angle. Test at the real mounting distance.

Sources

Last updated: 2026-11-21

ESP32-CAM RTSP Streaming: Setup Guide for VLC and NVR

The ESP32-CAM is a cheap way to build a WiFi camera, but the sketch most beginners start with does not speak RTSP. The stock Espressif CameraWebServer example streams MJPEG over HTTP, and that is all it does. If you want VLC, Frigate, Blue Iris, or an NVR to pick the camera up as a standard network camera, you need RTSP, which needs different firmware or a different library.

This guide covers the working routes, the board each one fits, the exact RTSP URL each serves, VLC viewing, Frigate and Home Assistant setup, and expected frame rate. Nothing here needs a paid app or a cloud account.

What is RTSP, and when does it beat MJPEG?

RTSP, Real Time Streaming Protocol, is the standard way network cameras hand video to players and recorders. A client asks for a stream, the two agree on transport settings, and video flows over RTP. VLC, ffmpeg, Frigate, Blue Iris, ZoneMinder, and most NVR software all speak RTSP.

MJPEG over HTTP, the /stream endpoint in the stock CameraWebServer sketch, is simpler: the camera sends one JPEG image after another in a single HTTP response, and any browser can show it. NVR software generally cannot record it, and detection tools cannot consume it directly.

Use RTSP to record footage, run motion or person detection, watch several cameras in one app, or feed the camera into Home Assistant through Frigate or go2rtc. Stick with MJPEG over HTTP for a quick live view in a browser. If you have not set up the board yet, start with our ESP32-CAM getting started guide first.

How do I watch the stream in a browser?

The stock CameraWebServer example is the fastest way to a live picture in a browser. It serves MJPEG over HTTP: the camera sends one JPEG image after another in a single HTTP response, and any browser shows it with no plugin and no extra app.

Flash it from the Arduino IDE. Open File, then Examples, then ESP32, then Camera, then CameraWebServer. Select the AI-Thinker camera model in board_config.h, enter your 2.4 GHz WiFi network name and password, and set the partition scheme to Huge APP (3MB No OTA/1MB SPIFFS); the camera example needs at least 3 MB of app space. Flash the board the same way the flashing walkthrough shows.

Watch the serial monitor at 115200 baud. When the board connects it prints “Camera Ready! Use ‘http://’ followed by its IP address”. Open that address in a browser on the same network. Press Start Stream for the live picture, or Get Still for a single photo. The example starts at QVGA resolution for a higher initial frame rate; raise it from the menu once the stream is stable.

The page has two servers behind it. The settings page and the single-photo endpoint live on port 80, and the live stream lives on port 81.

AddressWhat it servesUse it for
http://<IP>/Settings page with Start Stream and Get Still buttonsWatching and changing settings in a browser
http://<IP>/captureOne JPEG photo, port 80Saving a single still from a browser or a script
http://<IP>:81/streamLive MJPEG stream, port 81Embedding the stream in your own page or home automation software

Use the left-hand menu on the settings page to change the resolution, JPEG quality, brightness, contrast, and white balance while the stream runs. With PSRAM the example starts at UXGA and a JPEG quality of 10; without PSRAM it drops to SVGA and a quality of 12, because the frame buffer does not fit in internal RAM. If the picture stutters, lower the resolution first; the frame rate section below shows what to expect at each size.

Which board works for RTSP?

Any ESP32 camera board with PSRAM can run an RTSP server. The classic AI-Thinker style ESP32-CAM has an ESP32 chip with 4 MB PSRAM and an OV2640 camera. The ESP32-S3-N16R8 CAM board runs an ESP32-S3 chip with 8 MB PSRAM and an OV5640 camera, and its two USB-C ports mean no serial adapter is needed. Both boards stream MJPEG video over RTSP, not H.264, which matters for bandwidth and Home Assistant (see the frame rate section).

Pin tables conflict across sources. A wrong camera pin map is the most common reason a build compiles cleanly and shows no video, so verify the pins against your exact board variant before flashing, using that variant’s own documentation.

What are the RTSP setup options?

There is no single official RTSP example from Espressif for the classic ESP32-CAM. The working routes are community firmware and libraries. Pick one row and follow its section.

Approach Best for Boards RTSP URL pattern Code or config needed
esp32cam-rtsp firmware by rzeldent Fastest setup, no code changes ESP32, ESP32-S2, ESP32-S3 camera modules rtsp://IP:554/mjpeg/1 Flash with PlatformIO, configure in a browser
Micro-RTSP library by geeksville Arduino or PlatformIO sketch you control Classic ESP32-CAM (OV2640) rtsp://IP:8554/mjpeg/1 Arduino sketch plus the Micro-RTSP library
Tasmota32 webcam firmware Users who already run Tasmota and want MQTT control Classic ESP32-CAM (AI-Thinker template) rtsp://IP:8554/mjpeg/1 Flash the webcam binary, run one command
ESPHome rtsp_server component ESP32-S3 boards already in ESPHome ESP32 camera boards running ESPHome rtsp://IP:554/ Add two lines to your ESPHome YAML

Sources: esp32cam-rtsp at https://www.esp32.diy/esp32cam-rtsp/ ; Micro-RTSP at https://github.com/geeksville/Micro-RTSP ; circuit.rocks tutorial at https://learn.circuit.rocks/esp32-cam-with-rtsp-video-streaming ; Tasmota guide at https://cgomesu.com/blog/Esp32cam-tasmota-webcam-server/ ; ESPHome docs at https://beta.esphome.io/components/rtsp_server/ .

How do I set up esp32cam-rtsp, the no-code route?

Recommended route for most buyers. The firmware turns the board into an RTSP server, an HTTP MJPEG streamer, and a snapshot endpoint at once, all configured through a web page, with no code changes. Latest release at the time of writing: 1.0.8 (2026-09-29).

  1. Install PlatformIO (VS Code extension or CLI) and clone the project: git clone https://github.com/rzeldent/esp32cam-rtsp.git.
  2. Enter download mode. USB-C boards do this on their own; if an upload fails, hold BOOT, press and release RESET, then release BOOT. On a classic ESP32-CAM, use a 3.3 V USB-to-serial adapter or an ESP32-CAM-MB carrier, and hold GPIO0 low while resetting. 5 V logic damages the board.
  3. Flash your board target, for example pio run -t upload -e esp32cam_ai_thinker for the AI-Thinker board.
  4. On first boot the firmware starts its own WiFi access point. Join it, open the config page shown in the serial monitor, enter your WiFi credentials and camera settings, then save. The board reboots onto your network.
  5. Open VLC and play rtsp://<ip address>:554/mjpeg/1.

The same firmware also serves MJPEG at http://<ip address>/stream and a still at http://<ip address>/snapshot. Turn on RTSP authentication in the web interface if anyone outside your household can reach your network, and never forward port 554 through your router.

How do I set up Micro-RTSP in an Arduino sketch?

Use this route when you want the RTSP server inside your own sketch, for example a camera that also reads sensors or drives outputs. Micro-RTSP is a small RTSP server library implementing RTSP and JPEG-over-RTP, with a reference streamer built for the OV2640 on the classic ESP32-CAM.

  1. Install Micro-RTSP from the ZIP in the circuit.rocks ESP32-RTSP repo, or as a PlatformIO dependency; it is not in the Arduino Library Manager. Full example: https://github.com/circuitrocks/ESP32-RTSP .
  2. Put your WiFi credentials in the sketch’s credentials header before compiling.
  3. Wire the classic ESP32-CAM: 5 V and ground to the header pins, adapter TX to board U0R and RX to U0T, and a button between IO0 and ground. Use a 5 V, 2 A supply; a computer USB port is often not enough.
  4. Hold the download button while powering up or resetting, then upload. The serial monitor at 115200 baud shows the boot message and board IP.
  5. In VLC play rtsp://<ip address>:8554/mjpeg/1. Note the port: 8554, not 554.

The example loop sends a frame about every 100 ms, roughly 10 fps at 800 by 600, per the Micro-RTSP docs for that example. Run only one streaming server at a time; enabling both web and RTSP makes streaming very slow.

How do I enable RTSP on Tasmota?

Use this route only if you already run Tasmota or want its MQTT control and web interface. Flash the tasmota32-webcam firmware, apply the AI-Thinker template, then enable the RTSP server from the Tasmota console:

WcRtsp 1

The stream is then live at rtsp://<device IP>:8554/mjpeg/1. Enable it once; the RTSP server runs independently of the HTTP stream. The Tasmota guide reports VLC is the most reliable viewer. Full steps: https://cgomesu.com/blog/Esp32cam-tasmota-webcam-server/ .

How do I add RTSP to an ESPHome camera?

If your camera already runs ESPHome, add the RTSP server component next to your configured esp32_camera block:

rtsp_server:

That is the whole configuration. The stream is served at rtsp://<device IP>:554/ with no path after the port. Optional settings: port (default 554), max_connections (1 to 4, default 2), and allowed_ips (addresses or networks allowed to connect).

Two facts catch people out. First, the stream is MJPEG over RTSP, and the camera only streams while at least one client is playing. Second, there is no encryption or authentication; allowed_ips filters by address but authenticates nobody, so use it only on a trusted local network. Source: ESPHome RTSP docs.

How do I watch the stream in VLC?

VLC is the best first test for any of the four routes, because its RTSP support is solid and its error messages point at the real problem.

  1. Open VLC, go to Media, then Open Network Stream, or press Ctrl+N.
  2. Paste the RTSP URL for your firmware: port 554 for esp32cam-rtsp and ESPHome, port 8554 for Micro-RTSP and Tasmota. The path is /mjpeg/1 for esp32cam-rtsp, Micro-RTSP, and Tasmota, and the root path / for ESPHome.
  3. Click Play. If the picture appears, the camera, firmware, and network path all work, and any later failure is in the next app, not the camera.

If the video lags by a second or more, the cause is usually VLC network caching, not the camera. VLC buffers network streams at 1000 ms by default. In the stream dialog, click Show more options and lower caching to 300 ms, or to 0 ms for the lowest delay. Zero caching makes the picture more sensitive to WiFi jitter, so on a weak signal keep some caching and fix the signal instead.

How do I add the camera to Home Assistant and Frigate?

Two warnings first, because most tutorials get this part wrong.

Warning one: Home Assistant Generic Camera cannot play this stream. Its pipeline plays only H.264 and HEVC, and every RTSP route in this guide serves MJPEG. The ESPHome docs state this directly. Source: ESPHome RTSP docs.

Warning two: if the camera runs ESPHome, Home Assistant does not need RTSP at all. The ESPHome native API already exposes the camera entity. RTSP is for other software.

The route that works is Frigate, with go2rtc if your Frigate version uses it. Frigate reads the MJPEG RTSP stream with ffmpeg and handles detection and recording. A working Frigate camera entry from the Home Assistant community, using the Tasmota or Micro-RTSP URL:

cameras:
  esp32_cam:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.72:8554/mjpeg/1
          roles:
            - detect
            - record
    detect:
      width: 640
      height: 360
      fps: 5

Replace the IP address with your camera IP, and use port 554 with the matching path for esp32cam-rtsp or ESPHome. Keep detection resolution low; community users run 640 by 360 at 5 frames per second. Source: Home Assistant community Frigate thread.

If you only want a live dashboard view, skip RTSP and use the ESPHome native camera entity or the HTTP MJPEG stream. RTSP earns its place when Frigate or an NVR must record or analyze the feed.

How do I save a snapshot or record the stream?

A live stream is only useful while you watch it. Three ways to keep what the camera sees: a single still from the browser, a photo saved to the SD card, or a recording of the RTSP stream on your computer.

For one still, open http://<IP>/capture in a browser and save the JPEG it returns. The esp32cam-rtsp firmware serves the same thing at http://<IP>/snapshot. Both return a single frame, so you can also fetch them from a script on a schedule.

For a photo saved on the board itself, use the SD card slot. The sketch below wakes the camera, takes one photo when you press the button on GPIO 13, and saves it as /photo001.jpg, /photo002.jpg, and so on, with the counter kept in flash so it survives a reset. The card must be FAT32, 32 GB or less. The sketch mounts the card in 1-bit mode, which uses GPIO 2, 14, and 15 only, so GPIO 13 stays free for the button.

camera_fb_t *fb = esp_camera_fb_get();
if (fb) {
  File file = SD_MMC.open("/photo001.jpg", FILE_WRITE);
  file.write(fb->buf, fb->len);
  file.close();
  esp_camera_fb_return(fb);
}

The full sketch is the compiled source for this section: it sets up the AI-Thinker camera pins, mounts the card, and saves one numbered photo per button press. It compiled clean with PlatformIO on the ESP32-CAM board.

For a recording, use ffmpeg on your computer against the RTSP URL. The command below copies the stream straight to a file with no re-encoding, so it costs almost no CPU and loses no quality. TCP transport keeps packets from dropping, which matters for MJPEG because a lost packet corrupts the frame it lands in.

ffmpeg -rtsp_transport tcp -i "rtsp://<IP>:554/mjpeg/1" -c copy capture.mp4

Replace <IP> with your camera IP and 554 with 8554 for Micro-RTSP or Tasmota. For long recordings, split the file every 15 minutes so one crash does not lose the whole capture: add -f segment -segment_time 900 -segment_format mp4 -reset_timestamps 1 and name the output capture_%03d.mp4. Frigate does the same job continuously if you already run it; its camera entry in this guide has a record role for exactly this.

What latency and frame rate should I expect?

No source gives one tested frame rate for every board and firmware, so this guide gives no universal number. The numbers below are what named sources measured on their own setups. Your result moves with resolution, JPEG quality, WiFi signal, and client count.

  • ESPHome measured about 5 fps over WiFi and 10 over Ethernet at 640 by 480 on an ESP32-S3 with an OV5640, using its high performance network settings; without them the same test ran at about 1 fps over WiFi. Source: ESPHome RTSP docs.
  • The Micro-RTSP example sends a frame about every 100 ms, roughly 10 fps at 800 by 600 in its own documentation. Source: Micro-RTSP docs.
  • The esp32cam-rtsp project states that resolution and frame rate are bounded by the ESP32 processor and available PSRAM. Source: esp32cam-rtsp project page.

Start at 640 by 480 and raise resolution only after the stream is stable. MJPEG uses more bandwidth than H.264 at the same picture quality, since every frame is a full JPEG. Assume one viewer at a time on a classic ESP32-CAM; ESPHome defaults to two RTSP clients.

How much bandwidth does MJPEG need?

MJPEG sends every frame as a full JPEG image, so the bandwidth is the frame size times the frame rate. A higher resolution means a bigger frame and a lower frame rate, and there is no compression between frames to hide it. The table below uses measured frame rates from the sources cited; your result moves with JPEG quality, WiFi signal, and how many viewers are connected.

ResolutionExpected frame rateWhat it is good for
QVGA 320 by 24020 to 30 fpsFastest motion, lowest detail; best first test of a new setup
VGA 640 by 480About 5 fps over WiFi, 10 over Ethernet on an ESP32-S3The starting point this guide recommends; good balance of detail and speed
SVGA 800 by 600About 10 fpsMore detail for a door or driveway camera on a strong signal
UXGA 1600 by 12002 to 5 fpsStill photos and slow scenes only; a 1600 by 1200 JPEG frame is 100 to 250 KB

Worked example, from the cited frame sizes: a UXGA frame of 100 to 250 KB at 3 frames per second is 300 to 750 KB per second, about 2.4 to 6 Mbit per second, for one viewer. Drop to 640 by 480 and the same stream needs a fraction of that, which is why this guide starts there. Assume one viewer at a time on a classic ESP32-CAM; a second viewer halves the rate each one sees. ESPHome defaults to two RTSP clients for the same reason.

If the stream is slow, do not add bandwidth first. Lower the resolution, raise the JPEG quality number (a higher number means more compression and a smaller frame), disconnect other viewers, and move the board closer to the router. The frame rate section above shows the numbers each route measured on its own setup.

What are the common mistakes?

  • Flashing the stock CameraWebServer sketch and expecting RTSP. It serves MJPEG over HTTP only.
  • Using the wrong port. Port 554 belongs to esp32cam-rtsp and ESPHome; port 8554 belongs to Micro-RTSP and Tasmota. The wrong port gives a connection refused error even when the camera runs fine.
  • Using the wrong path. The path is /mjpeg/1 for esp32cam-rtsp, Micro-RTSP, and Tasmota, and the root path / for ESPHome.
  • Powering the classic ESP32-CAM from a weak USB port. The board needs a stable 5 V, 2 A supply. Brownouts during WiFi connection look like firmware bugs and are usually power.
  • Running two streaming servers at once in the Micro-RTSP sketch. The tutorial warns this makes streaming very slow. Pick one.
  • Pointing Home Assistant Generic Camera at an MJPEG RTSP URL. It cannot play it. Use Frigate or go2rtc, or the ESPHome native camera entity.
  • Opening RTSP to the internet. None of these routes is built for that, and ESPHome RTSP has no authentication at all. Keep the camera on your local network.
  • Trusting a pin table from a different board variant. Pin maps conflict across sources. Verify the camera pins against your exact board variant before blaming the firmware.

How do I troubleshoot a stream that will not play?

Work through this list in order; each step rules out one layer.

VLC says “Your input can’t be opened” or times out. Check the board IP in the serial monitor or your router, confirm the camera and computer share a network, and confirm the port and path match your firmware in the table above. Check the router is not isolating WiFi clients (AP isolation) and that no firewall blocks the RTSP port.

VLC connects but shows a black or frozen frame. Drop to 640 by 480 and move closer to the router. The ESP32-CAM is 2.4 GHz only, so a 5 GHz network name will never work.

The stream stutters or drops frames. Lower the resolution and frame rate, disconnect other viewers, and check the power supply, since a marginal 5 V supply causes this under load. In VLC, force RTP over RTSP (TCP) when UDP packets drop.

The camera boots but never joins WiFi. Re-enter the network name and password, watching case and trailing spaces. Check the serial monitor at 115200 baud for connection messages and the assigned IP. A reboot loop usually means power first, then a loose camera ribbon cable.

The camera works in VLC but Frigate reports “Unable to read frames”. Confirm the URL in VLC first, then copy it exactly into Frigate. The common cause is port 554 when the firmware serves on 8554, or an ESPHome web server port, which is HTTP, not RTSP. Source: Home Assistant community thread.

Wrong colors or artifacts. Reseat the camera ribbon cable and lower the resolution.

Parts used in this guide

Prices and stock were verified live on qualityrcparts.com on 2026-11-21 through the public Store API. All three items are in stock and purchasable; the live product page is the current price.

Shipped fast and securely from our secure facility in Queensbury, NY. QRC ships within the USA only.

Related guides

Frequently asked questions

Does the ESP32-CAM support RTSP out of the box?

No. The stock CameraWebServer example serves MJPEG over HTTP only, with no RTSP server. Add RTSP with esp32cam-rtsp firmware, the Micro-RTSP library, Tasmota webcam firmware, or the ESPHome rtsp_server component. Source: Home Assistant community, Tasmota guide.

What is the RTSP URL for an ESP32-CAM?

It depends on the firmware: rtsp://IP:554/mjpeg/1 for esp32cam-rtsp, rtsp://IP:8554/mjpeg/1 for Micro-RTSP and Tasmota, rtsp://IP:554/ for ESPHome. Replace IP with the camera IP from your router or serial monitor. Source: esp32cam-rtsp, Micro-RTSP, Tasmota, and ESPHome docs.

Can I add an ESP32-CAM RTSP stream to Home Assistant?

Not through Generic Camera: its pipeline plays only H.264 and HEVC, and ESP32-CAM RTSP serves MJPEG. Feed the stream to Frigate or go2rtc instead, or use the ESPHome native camera entity. Source: ESPHome RTSP docs.

Why does VLC say it cannot open my ESP32-CAM stream?

The usual causes are a wrong IP address, the wrong port (554 vs 8554), the wrong path (/mjpeg/1 vs the ESPHome root path), AP isolation, or a firewall blocking the RTSP port. Check the stream in VLC first, then copy that working URL into any other app. Source: Micro-RTSP and circuit.rocks docs.

What frame rate will I get from an ESP32-CAM over RTSP?

There is no single tested number. ESPHome measured about 5 fps over WiFi and 10 over Ethernet at 640 by 480 on an ESP32-S3 with an OV5640, and the Micro-RTSP example runs about 10 fps at 800 by 600. Start at 640 by 480. Source: ESPHome and Micro-RTSP docs.

Is RTSP better than MJPEG for an ESP32-CAM?

RTSP is better when a recorder, NVR, or detection tool needs the feed, because those tools speak RTSP and generally cannot consume an MJPEG HTTP stream. MJPEG over HTTP is better for a quick live view in a browser. Both carry the same MJPEG video, so RTSP does not improve the picture, it makes the feed usable by more software. Source: ESPHome docs, esp32cam-rtsp page.

Can I view an RTSP stream in a web browser?

No, not directly. Browsers do not play RTSP. Use VLC or an NVR app for RTSP, the HTTP MJPEG stream at http://IP/stream for a browser view, or Frigate or go2rtc between the camera and the browser. Source: circuit.rocks docs, esp32cam-rtsp page.

How do I watch the MJPEG stream in a browser?

Flash the stock CameraWebServer example, open the IP address the serial monitor prints, and press Start Stream. The live stream itself is at http://<IP>:81/stream, and a single still is at http://<IP>/capture. The example starts at QVGA; raise the resolution from the menu once the stream is stable.

How do I save a single photo from the camera?

Open http://<IP>/capture in a browser and save the JPEG it returns, or use http://<IP>/snapshot on esp32cam-rtsp firmware. To save on the board itself, use the SD snapshot sketch in this guide: press the button on GPIO 13 and the photo lands on the card as /photoNNN.jpg. The card must be FAT32, 32 GB or less.

How do I record the RTSP stream to a file?

Run ffmpeg on your computer: ffmpeg -rtsp_transport tcp -i “rtsp://<IP>:554/mjpeg/1” -c copy capture.mp4. Use port 8554 for Micro-RTSP or Tasmota. Add -f segment -segment_time 900 to split long recordings into 15-minute files. Frigate records continuously if you already run it.

Why is the stream slow at high resolution?

Every MJPEG frame is a full JPEG image, so a UXGA frame of 100 to 250 KB at a few frames per second needs several Mbit per second for one viewer. Drop to 640 by 480, raise the JPEG quality number for smaller frames, disconnect other viewers, and move the board closer to the router.

Sources

Last updated: 2026-11-22

Hexapod Spider Robot Kit Build: 18 Servos, Six Legs

Hexapod spider robot kit with six legs and 18 servos

Hexapod Spider Robot Kit Build: 18 Servos, Six Legs

Build the hexapod spider robot kit with 18 servos across six legs, driven by PCA9685 boards over I2C. Three legs lift and swing while the other three hold the body up, which is the tripod gait. The servos need a 5 to 6 V supply rated at 10 A, because 18 servos can draw more than any USB port supplies.

Quick facts

Item Value
Legs 6 legs, 3 servos per leg, 18 servos total
Gait Tripod gait: 3 legs lift, 3 legs support
Drivers PCA9685 boards, 16 channels each; two boards cover 18 servos
Controller Freenove Crawling Robot Controller in the kit, Arduino IDE compatible; wireless remote included
Servo supply Separate 5 to 6 V, sized for stall current
Battery Not included; 2x 3.7 V 18650 flat-top cells plus a charger, bought separately

Hexapod spider robot kit: how does it walk?

A hexapod walks with a tripod gait. At any moment, three legs touch the ground and hold the body up, while the other three lift, swing forward, and set down. Then the two tripods swap. The body never has fewer than three legs on the ground, so it stays stable without balancing.

Each leg has three servos: a hip servo that swings the leg forward and back, a knee servo that lifts the leg, and an ankle servo that sets the foot angle. Three servos per leg times six legs is 18 servos. No Arduino has 18 PWM pins to spare, which is why the build uses PCA9685 boards.

The two tripods are the front left, middle right, and rear left legs in one group, and the front right, middle left, and rear right legs in the other. Lift one tripod, swing it forward, set it down, then lift the other. That is the whole walk. Turning shifts the swing direction, and strafing shifts the foot targets sideways.

Why do 18 servos need two PCA9685 boards?

One PCA9685 drives 16 servos. Eighteen servos need two boards, with 16 channels on the first and 2 on the second. The boards share one I2C bus, so the wiring stays at two wires plus power. Set the first board to address 0x40 and the second to 0x41 with its A0 solder pad, then pass each address to its own library object.

Both boards share the same 50 Hz servo frequency, and each channel is independent. The sketch below creates two driver objects, one per address, and a helper that maps a servo number from 0 to 17 onto the right board and channel. The gait code then thinks in legs and joints, not in boards and channels.

The kit as shipped needs no PCA9685 at all: its own Freenove Crawling Robot Controller drives all 18 servos directly from ports 22 to 39, with the yellow servo wire to S, red to +, and black to -. The kit ships with a remote, and the kit controller plus its provided library handle the first walks. The PCA9685 wiring in this post is the path for builders who drive the servos from their own board instead of the kit controller. The kit tutorial also requires the batteries to be fully charged before assembly, with about 8.0 to 8.4 V across the two 18650 cells, and warns that wrong batteries can damage the servos.

How do you size power for 18 servos?

Size for stall current, not idle current. Eighteen servos starting or stalling together draw several amps, far more than any USB port or board regulator supplies. No single authoritative figure exists for the stall current of the servos in this kit, and the common SG90 stall figures disagree across resellers, so this post states no per-servo current number. Size generously and meter the rail on your own build.

Use a separate 5 to 6 V supply rated at 10 A or more for the servo rail, and feed it to the PCA9685 V+ terminals. A 5 V 10 A bench supply works on the bench. That 10 A rating is a planning rating with headroom, not a computed stall total. The kit itself runs from 2x 3.7 V 18650 cells, which is a separate power path from the PCA9685 servo rail in this post; do not feed the 18650 pack straight into the servo rail.

Add a large capacitor across each V+ terminal, 1000 microfarads or more, close to the board. Eighteen servos starting at once draw a sharp spike, and the capacitor absorbs it. Use thick wire for the V+ feed, because thin jumper wires drop voltage at 10 A and heat up. Never route servo current through the Arduino 5 V pin.

How do you assemble and test the legs?

Assemble one leg at a time and test it before you fit the next. Center each servo at 90 degrees with the sketch before you fit the horn, so the leg starts at its middle position. A horn fitted 30 degrees off center steals a third of that joint travel and the leg will never reach its full step.

Test the tripod gait with the body held up in your hand first. Lift the robot, run the gait, and watch the feet. Three feet should lift and swing while the other three stay still, then swap. If a leg swings the wrong way, its hip servo is reversed in the mapping, so flip its direction sign in the code, not the wiring.

Set the robot down only after the lifted test looks right. On the floor, start with short steps and low speed. A hexapod that steps too far tips forward, because the support tripod moves behind the center of mass. Short steps keep the body over its feet.

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
PCA9685 board 1 VCC Controller 5 V or 3V3 Logic only; use 3.3 V on an ESP32 so the I2C pull-ups stay at 3.3 V
PCA9685 board 1 GND Controller GND and servo supply negative Common ground for all three
PCA9685 board 1 SDA Controller SDA I2C data; address 0x40, A0 pad open
PCA9685 board 1 SCL Controller SCL I2C clock
PCA9685 board 2 VCC Controller 5 V or 3V3 Logic only
PCA9685 board 2 GND Controller GND and servo supply negative Common ground
PCA9685 board 2 SDA Controller SDA Shared I2C bus; address 0x41, A0 pad bridged
PCA9685 board 2 SCL Controller SCL Shared I2C bus
Both boards V+ terminals Separate 5 to 6 V supply, 10 A or more Servo power only; thick wire, one feed per board
Board 1 channels 0 to 15 Servos 0 to 15 Legs 1 to 5 full sets plus one joint of leg 6
Board 2 channels 0 and 1 Servos 16 and 17 Remaining two joints of leg 6
Capacitor 1000 uF or more Across each V+ terminal and ground Absorbs the 18-servo start-up spike; mind the polarity

Power budget

Eighteen micro servos draw several amps while walking and far more if they all stall at once, so the supply must cover the walking current with margin, and the fuse or pack must survive the stall spike without cutting out mid-step. A 5 V 10 A bench supply is the bench choice. A battery pack needs the same current rating. The kit battery is 2x 3.7 V 18650 flat-top cells plus a charger, none of which are included.

The logic side draws only a few milliamps. The controller, the two PCA9685 chips, and the remote receiver run from the controller supply. The servo rail is separate, and only the grounds join. Never power the servos from the controller 5 V pin, and never feed the servo supply into the controller.

Heat matters at 10 A. Use thick wire for the V+ feeds, keep the runs short, and check the terminal screws after the first hour of walking. A loose screw at 10 A heats up and drops voltage, and the legs will jitter and stall.

Build steps

  1. Unbox the kit and count the parts: frame, six legs, 18 servos, horns, screws, the Freenove Crawling Robot Controller, and remote. Confirm the battery is not included: buy 2x 3.7 V 18650 flat-top cells plus a charger, and fully charge them before assembly.
  2. Run the kit as shipped first if you can: load the provided code on the kit controller, calibrate the servos with the calibration graph in the kit tutorial, and walk it on the remote. The PCA9685 steps below are the own-board alternative, not the kit default.
  3. Center every servo at 90 degrees with the sketch before you fit any horn. Fit each horn at the middle position.
  4. Assemble one leg at a time: hip, knee, then ankle. Test each leg by hand for free movement before you fit the next.
  5. Fit the six legs to the body in the tripod groups: front left, middle right, rear left in one group, and the other three in the second group.
  6. Wire the two PCA9685 boards from the wiring table. Set board 1 to 0x40 and board 2 to 0x41 with the A0 pad.
  7. Connect the servos to the boards in order, 0 to 17, and connect the separate servo supply to both V+ terminals. Join the grounds.
  8. Upload the sketch below. Hold the body up and run the tripod gait. Confirm three legs lift and swing while the other three hold still, then swap.
  9. Set the robot on the floor and walk it forward in short steps. Shorten the step if it tips forward.

Code

Library: Adafruit PWM Servo Driver library. Board: Arduino IDE compatible controller. The sketch maps servo numbers 0 to 17 across two PCA9685 boards and runs a basic tripod gait. Tune the step size and the per-leg direction signs for your kit.

// Hexapod spider robot: 18 servos, 2 x PCA9685, tripod gait
// Board: Arduino IDE compatible controller.
// Library: Adafruit PWM Servo Driver (Adafruit_PWMServoDriver).
#include 
#include 

Adafruit_PWMServoDriver pwmA = Adafruit_PWMServoDriver(0x40);  // Servos 0-15
Adafruit_PWMServoDriver pwmB = Adafruit_PWMServoDriver(0x41);  // Servos 16-17

#define SERVOMIN 150   // About 730 microseconds at 50 Hz; calibrate per servo
#define SERVOMAX 600   // About 2930 microseconds at 50 Hz; calibrate per servo
#define SERVO_FREQ 50

// Legs 0-5, joints 0=hip, 1=knee, 2=ankle. Servo number = leg*3 + joint.
// Tripod 1: legs 0, 2, 4. Tripod 2: legs 1, 3, 5.
const uint8_t TRIPOD1[3] = {0, 2, 4};
const uint8_t TRIPOD2[3] = {1, 3, 5};

uint16_t angleToPulse(int angle) {
  return map(constrain(angle, 0, 180), 0, 180, SERVOMIN, SERVOMAX);
}

void setServo(uint8_t servo, int angle) {
  uint16_t pulse = angleToPulse(angle);
  if (servo < 16) pwmA.setPWM(servo, 0, pulse);
  else pwmB.setPWM(servo - 16, 0, pulse);
}

void setLeg(uint8_t leg, int hip, int knee, int ankle) {
  setServo(leg * 3 + 0, hip);
  setServo(leg * 3 + 1, knee);
  setServo(leg * 3 + 2, ankle);
}

void setTripod(const uint8_t legs[3], int hip, int knee, int ankle) {
  for (uint8_t i = 0; i < 3; i++) setLeg(legs[i], hip, knee, ankle);
}

void setup() {
  pwmA.begin();
  pwmA.setOscillatorFrequency(27000000);
  pwmA.setPWMFreq(SERVO_FREQ);
  pwmB.begin();
  pwmB.setOscillatorFrequency(27000000);
  pwmB.setPWMFreq(SERVO_FREQ);
  delay(10);
  // Park every servo at 90 degrees: legs centered, feet down.
  for (uint8_t s = 0; s < 18; s++) setServo(s, 90);
  delay(500);
}

void loop() {
  // Tripod gait, one step per cycle. Tune the angles for your kit.
  // Lift tripod 1, swing forward, set down.
  setTripod(TRIPOD1, 110, 60, 90);  // Lift and swing forward
  delay(300);
  setTripod(TRIPOD1, 110, 90, 90);  // Set down
  setTripod(TRIPOD2, 70, 90, 90);   // Push body forward
  delay(300);
  // Lift tripod 2, swing forward, set down.
  setTripod(TRIPOD2, 110, 60, 90);
  delay(300);
  setTripod(TRIPOD2, 110, 90, 90);
  setTripod(TRIPOD1, 70, 90, 90);
  delay(300);
}

Test and tune it

Hold the body up and run the gait. Three legs should lift and swing while the other three stay still, then swap. If a leg in the wrong tripod moves, its leg number is wrong in the TRIPOD table.

If a leg swings backward instead of forward, flip its hip direction sign in the gait code. Do not rewire the servo, because the mapping is the fault.

Set the robot down and walk it 3 feet. If it tips forward, shorten the swing from 110 degrees toward 100 degrees. Short steps keep the body over the support tripod.

FAQ

How many servos does a hexapod need?

Eighteen servos: three per leg times six legs. Each leg has a hip servo, a knee servo, and an ankle servo. One PCA9685 drives 16 servos, so this build uses two boards.

What is the tripod gait?

Three legs hold the body up while the other three lift, swing forward, and set down. Then the two tripods swap. The body always has three legs on the ground, so it stays stable without balancing.

Why does my hexapod jitter when it walks?

The servo supply sags under the start-up spike of 18 servos. Add a 1000 microfarad capacitor across each V+ terminal, check the supply current rating, and tighten the terminal screws.

Can I power 18 servos from USB?

No. Eighteen micro servos together draw several amps while walking and far more at stall. Use a separate 5 to 6 V supply rated at 10 A or more for the servo rail.

Does the kit include a battery?

No. The kit needs 2x 3.7 V 18650 flat-top cells plus a charger, none included, and the remote takes 1x 9 V battery or USB power. For the PCA9685 servo rail in this post, use a bench supply for indoor testing.

Parts used

Build it with the Hexapod Spider Robot Kit with Remote, Six Legs with 18 Motors, Arduino IDE Compatible, Walking and Crawling STEM Project (Battery Not Included) and the PCA9685 16-Channel PWM Servo Driver Board, 12-Bit IIC Interface, Arduino + Raspberry Pi, 2-Pack (two boards cover 18 servos; one board drives only 16). For a servo arm build without the driver board, see How to Build a Robot Arm with ESP32 and Servo Motors, and the arm build uses the same driver in Joystick Robot Arm: 4-Axis Control with PCA9685. For the servo signal behind the positions, see Digital vs Analog Servo Guide: Which Servo Holds Center.

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 Battery Sensor Node: Deep Sleep and Power Budget

Battery powered ESP32 sensor node with DHT22 sensor and buck converter

ESP32 Battery Sensor Node: Deep Sleep and Power Budget

This battery sensor node runs an ESP32 on battery by waking it on a timer, reading a DHT22 sensor, and putting it back into deep sleep. The ESP32 chip draws about 10 microamps in deep sleep, against 160 to 240 mA with Wi-Fi transmitting. The board keeps drawing milliamps: the regulator, the USB serial chip, and the power LED.

Quick facts

Item Value
Sleep current, chip About 10 uA in deep sleep, ESP32 Series Datasheet v5.3
Awake current 80 to 160 mA, peaks near 240 mA on Wi-Fi transmit
Wake source RTC timer, every 10 minutes
Sensor DHT22, temperature and humidity
Power Battery pack through an XL4015 buck converter set to 5 V
No solar This build uses battery power only; no solar panel is fitted

Battery sensor node: how does deep sleep save battery?

Deep sleep powers down the main CPUs, the Wi-Fi and Bluetooth radios, and most peripherals. Only the RTC domain stays alive, with its timer and a small block of RTC memory. The chip draws about 10 microamps in that state, against 160 to 240 mA with Wi-Fi transmitting. That is a reduction of about 24,000 times.

Deep sleep is effectively a reboot. When the timer fires, the bootloader runs, the sketch loads from flash again, and setup() starts from the top. Normal variables are lost. Only variables tagged RTC_DATA_ATTR survive, in the 8 KB RTC slow memory, so the sketch keeps its boot count there and does its work in setup().

The pattern is wake, work, sleep. The node wakes every 10 minutes, reads the DHT22, connects to Wi-Fi, sends the reading, and sleeps again. The awake time is a few seconds. The sleep time is 597 seconds. Average current is what decides battery life, and the average is dominated by the few awake seconds, not the long sleep.

Why does a dev board never reach 10 microamps?

The 10 microamp figure is the bare ESP32 chip, from the Espressif ESP32 Series Datasheet v5.3. A DevKit V1 board adds an always-on power LED, a USB to serial chip, and a linear regulator, and each of those draws current around the clock. A typical DevKit V1 measures a few milliamps in deep sleep, not 10 microamps. That is still a large saving over 160 mA awake, but it changes the battery math by a factor of 100.

Measure your own board before you promise battery life. Put a USB power meter inline, or a multimeter on the battery lead, and read the current in deep sleep. Write the number down. Every battery estimate in this post uses a 1 mA planning figure for the whole node, not a measured board value, because no bench measurement of the stocked board exists. Replace the planning figure with your measured value before you promise a battery life.

You can cut the board overhead further by removing the power LED or by using a bare module, but that is a hardware modification and it voids any return. For a first build, measure the board as it ships and size the battery for the measured figure.

How do you work out the battery life?

Average current is the awake share times the awake current, plus the sleep share times the sleep current. Wake for 3 seconds at 150 mA every 600 seconds, and sleep at 1 mA the rest of the time. The awake share is 3 divided by 600, or 0.5 percent. The average is 0.005 times 150 mA plus 1 mA, which is about 1.75 mA.

Divide the battery capacity by the average current to get the life. A 2500 mAh pack at 1.75 mA average lasts about 1400 hours, or about 59 days. That is an estimate, not a promise. Cold weather cuts capacity, the buck converter wastes 10 to 20 percent, and the Wi-Fi connect time varies with signal strength.

The biggest lever is the awake time. Every second of Wi-Fi connect time at 150 mA costs as much as 150 seconds of sleep at 1 mA. Keep the awake work short: read the sensor first, connect, send one small packet, and sleep. Do not wait for a slow server, and do not retry forever. Three tries, then sleep and try again next cycle.

How do you power the node from a battery?

The XL4015 buck converter steps the battery voltage down to a steady 5 V for the ESP32 USB input or the 5 V pin. Set the output to 5 V with a multimeter before you connect the board, and never adjust the trimmer while the board is connected. A wrong turn can send the full battery voltage into the board.

The buck converter itself draws current, even with no load. That quiescent draw joins the sleep current, so measure the whole node, converter included, not the board alone. The XL4015 chip draws 2.1 mA typical and 5 mA maximum quiescent current (XLSEMI datasheet Rev 1.6), and the stocked module adds an LED display that draws more, so a converter that draws 5 mA idle will dominate a node that sleeps at 1 mA. The chip runs from 8 to 36 V in and 1.25 to 32 V out; the module is advertised at 4 to 38 V in, 1.25 to 36 V out, and 5 A. Feed it from a battery inside the module range and set the output to 5 V.

This build uses battery power only. No solar panel is fitted, and no solar claim is made, because no solar panel is stocked for this build. If you add solar later, size the panel for the average current plus the charge controller losses, and test it through a cloudy week before you trust it.

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 pack positive XL4015 IN+ Battery input to the buck converter; set the output before connecting the board
Battery pack negative XL4015 IN- and ESP32 GND Common ground
XL4015 OUT+ ESP32 5 V pin or USB 5 V Regulated 5 V output; set to 5.0 V with a multimeter first
XL4015 OUT- ESP32 GND Common ground
DHT22 VCC ESP32 3V3 Module supply 3.3 to 6 V per the Aosong datasheet; the stocked module is a wired 3-wire module (+, -, Out)
DHT22 GND ESP32 GND Common ground
DHT22 DATA ESP32 GPIO 4 Single-wire data; 10 k pull-up resistor between DATA and 3V3 if the module has none

Power budget

The budget below uses a 1 mA planning figure for the sleep current of the whole node, board plus buck converter, because that is the honest planning figure for a DevKit V1 as shipped. It is a planning figure, not a bench measurement: no measured sleep current exists for the stocked board. The chip alone sleeps at about 10 microamps, but the board overhead dominates. Measure your node and redo the math with the measured value.

Awake for 3 seconds at 150 mA every 600 seconds, asleep at 1 mA otherwise, gives an average of about 1.75 mA. A 2500 mAh pack lasts about 59 days at that average, before converter losses and cold weather. Cut the wake interval to 30 minutes and the same pack lasts about 83 days, not 4 months: the awake share falls to one third, but the 1 mA sleep current dominates the average, so tripling the interval only stretches the life by about 40 percent. A slow Wi-Fi join stretches the awake time too: about 13 seconds awake per cycle cuts the same pack to about 25 days.

The DHT22 draws 1 to 1.5 mA while measuring and 40 to 50 uA in standby, per the Aosong datasheet, and the bare sensor pins run VCC, DATA, NC, GND with the grille facing you. Do not read it more often than once every 2 seconds. It is a rounding error next to the Wi-Fi radio. The radio is the cost. Keep the awake time short, send one small packet, and sleep.

Build steps

  1. Set the XL4015 output to 5.0 V with a multimeter, with no board connected. Lock the trimmer and recheck the output.
  2. Wire the battery, the buck converter, and the ESP32 from the wiring table. Wire the DHT22 to GPIO 4 with its pull-up resistor.
  3. Install the Adafruit DHT sensor library and the Adafruit Unified Sensor library from the Library Manager.
  4. Upload the sketch below. Open the serial monitor at 115200 baud and confirm the node reads the DHT22 and prints the boot count.
  5. Measure the deep sleep current with a USB power meter or a multimeter on the battery lead. Record the value and update the battery math in this post.
  6. Leave the node running on battery for 24 hours. Confirm it wakes every 10 minutes and the boot count rises by about 144 per day.
  7. Calculate the battery life from your measured sleep current, not from the 10 microamp chip figure. Replace the planning figure in this post with the measured value.

Code

Libraries: Adafruit DHT sensor library, Adafruit Unified Sensor library. Board: ESP32 DevKit V1. The sketch does its work in setup() because deep sleep restarts the chip on every wake.

// Battery ESP32 sensor node: DHT22 + deep sleep, timer wake
// Board: ESP32 DevKit V1. Libraries: Adafruit DHT sensor library.
#include 
#include 
#include 

#define DHT_PIN 4
#define DHT_TYPE DHT22
#define uS_TO_S 1000000ULL
#define SLEEP_SECONDS 600  // Wake every 10 minutes

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

DHT dht(DHT_PIN, DHT_TYPE);

// RTC memory survives deep sleep; normal variables do not.
RTC_DATA_ATTR int bootCount = 0;

void setup() {
  Serial.begin(115200);
  bootCount++;
  Serial.print("Boot count: ");
  Serial.println(bootCount);

  dht.begin();
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("DHT22 read failed");
  } else {
    Serial.print("Temp: "); Serial.print(temperature, 1);
    Serial.print(" C, Hum: "); Serial.print(humidity, 1);
    Serial.println(" %");
    // Join Wi-Fi with a bounded wait, then send the reading here:
    // HTTP POST, MQTT, or ESP-NOW. Keep it short: connect, send
    // once, then sleep. A slow join stretches the awake time, so
    // the 10 second cap below keeps one bad cycle from draining
    // the battery.
    WiFi.begin(WIFI_SSID, WIFI_PASS);
    unsigned long wifiStart = millis();
    while (WiFi.status() != WL_CONNECTED && millis() - wifiStart < 10000) {
      delay(500);
    }
  }

  // Arm the RTC timer, then sleep. This call never returns.
  esp_sleep_enable_timer_wakeup(SLEEP_SECONDS * uS_TO_S);
  Serial.println("Going to sleep for 10 minutes");
  Serial.flush();  // Let the text leave before power drops
  esp_deep_sleep_start();
}

void loop() {
  // Never reached: deep sleep restarts the chip from setup().
}

Test and tune it

Confirm the node wakes every 10 minutes by watching the boot count rise by 6 per hour. A count that rises faster means the node is resetting instead of sleeping, usually from a weak battery or a loose wire.

Measure the sleep current with the USB cable unplugged and the battery connected. If the meter reads over 5 mA in sleep, the buck converter quiescent draw or the power LED is the cause. Measure the board alone, then the converter alone, to find which one dominates.

Run the node for a week on battery and log the battery voltage at each wake. A steady fall is normal. A sudden drop means the Wi-Fi connect time grew, usually from a weak signal, so move the node closer to the router.

FAQ

How long will an ESP32 sensor node last on battery?

It depends on the measured sleep current, not the 10 microamp chip figure. At 1.75 mA average, a 2500 mAh pack lasts about 59 days. Measure your board in deep sleep and redo the math with that number.

Why does my ESP32 use more power asleep than the datasheet says?

The datasheet figure is the bare chip. The DevKit board adds a power LED, a USB serial chip, and a regulator, and each draws current around the clock. Measure the whole board, not the chip.

What wakes the ESP32 from deep sleep?

The RTC timer is the workhorse: wake every N minutes to sample and report. A pin, a touch pad, or the ULP coprocessor can also wake it. This build uses the timer only.

Does deep sleep keep my variables?

No. Deep sleep restarts the chip, so normal variables are lost. Only variables tagged RTC_DATA_ATTR survive, in the 8 KB RTC slow memory. Keep counters and last readings there.

Can I add solar power to this node?

Not in this build. No solar panel is stocked for it, so no solar claim is made here. A solar version needs a panel, a charge controller, and a cloudy-week test before you trust it.

Parts used

Build it with the ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, the DHT22 / AM2302 Digital Temperature & Humidity Sensor Module, and the XL4015 5A DC-DC Step Down Buck Converter Module with LED Display, 2-Pack. The always-on version is ESP32 WiFi Sensor Telemetry: Live Dashboard with BME280, and the flash logging version is ESP32 Sensor Data Logger: Flash Logging and WiFi Download. 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.

For the ESP-NOW protocol behind the gateway pattern, see ESP-NOW Explained: Two ESP32 Boards, No Router.

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.

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.

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-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.