🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

In a previous project, I made an ESP32 pretend to be a USB webcam.

This time, I wanted to do it properly - turn it into a real USB webcam with a real camera.

I also wanted to push things a bit further - I’ve got an I2C thermal camera module - why not turn that into a USB camera?

The ESP32S3 has native USB support, which means it can present itself directly as a USB device - this opens up a whole world of possibilities.

For USB video, I’m using USB UVC (USB Video Class). I’m also sticking to MJPEG to make things simple.

The nice thing about MJPEG is that it’s not a video codec in the traditional sense — it’s just a stream of individual JPEG images, sent one after another over USB.

Simple case: a normal camera module

Many ESP32-compatible camera modules already output JPEG-compressed images.

That means the “encoder” part of the webcam is basically free:

Our code turns into this:

  1. Capture a JPEG frame from the camera
  2. Hand the JPEG bytes to the USB stack
  3. Repeat

You really can’t get much simpler than that.

You can use any S3 dev board - there are some nice ones that have built in cameras, but you could use a standard dev board and a camera module.

Camera Modules

What you can’t use is the old ESP-CAM boards - firstly these don’t have USB and secondly the standard ESP32 doesn’t have native USB support.

Moving to thermal: a 32×24 infrared camera

The thermal camera is where things get interesting.

I’m using an MLX90640. This module outputs a 32×24 pixel temperature image over I2C. That’s just 768 pixels total - really tiny and not very usable raw.

But it is enough data to work with.

Our new code flow is:

  1. Read the raw thermal image over I2C
  2. Convert temperatures to grayscale or false colour
  3. Scale the image up to 320×240
  4. JPEG encode it
  5. Stream it over USB using UVC

IR Module

I2C debugging (and a reminder to myself)

Before any of it actually worked, I managed to lose a fair bit of time debugging what I thought was an I2C software problem.

  • I scanned addresses.
  • Checked pull-ups.
  • Tried different voltages.
  • Swapped code around.

Eventually, I looked at the board under a microscope abd found that it was just a dodgy solder joint on the on-board 3.3 V regulator.

You can see a detailed post on this here

3V3 Regulator

This particular thermal camera board includes:

  • Built-in I2C pull-up resistors (2.2 kΩ to 3.3 V)
  • An on-board 3.3 V regulator

In theory, that means the board expects to be powered from 5 V, feeding the regulator.

In practice, the regulator is a low-dropout device (around 120 mV dropout at 100 mA), so powering the board directly from 3.3 V worked just fine.

Importantly, because the pull-ups are tied to the 3.3 V rail, there are no weird voltage levels on the I2C bus even when powered this way - which does make me wonder how well it would work with a real 5v logic device.

Making 32×24 pixels usable

Once the thermal data is coming in reliably, the next problem is obvious:

32×24 pixels is tiny.

The solution is to scale it up by a factor of 10× in each direction, producing a 320×240 image that fits nicely into a webcam frame.

I implemented two scaling options:

  • Nearest neighbour: very fast, but can look a bit blocky
  • Bilinear scaling: smoother, still fast enough on the ESP32-S3

Both give surprisingly good results, and once the image is scaled and colour-mapped, you’d never guess it started life at such a low resolution.

Scaling methods compared

JPEG encoding and USB streaming

After scaling, the image is JPEG-encoded and sent over USB using the UVC stack.

From the host computer’s point of view, this is just a normal webcam:

  • Works in standard camera apps
  • No custom drivers
  • No special software

Despite the low input resolution, the frame rate is perfectly usable, and the ESP32-S3 has more than enough performance to keep everything running smoothly.

You can see it all in actiion here - it’s pretty cool (or hot!).

Related Posts

Pong Cam - My ESP32S3 Thinks It's a WebCam! - I turned an ESP32-S3 into a plug-and-play USB webcam—with no camera attached. The ESP32 generates its own frames, encodes them as JPEGs, and streams them over UVC as MJPEG. I ramp it up from a static BBC test card, to animated GIF playback, and finally a fully playable Pong running at a solid 30 FPS. Under the hood: Espressif’s UVC device component (TinyUSB), Bulk mode for stability, AnimatedGIF for decoding, and esp_new_jpeg for fast JPEG encoding (~21–23 ms/frame). It’s a fun proof that the S3 can be a real-time “display” straight into your PC.
ESP32-S3 USB UAC - I turned my new ESP32‑S3 board into a USB Audio device. After a ninja LED fix and confirming the IMU and charging, I streamed mic audio over Web Serial (with a slick AI-made ‘Audio Studio’) and then via USB UAC. The mic sounds great, but the speaker is crackly over UAC—even though I2S WAV playback is perfectly clean. ESP-IDF worked; Arduino didn’t. Bonus annoyance: macOS vs Windows is a toggle, not a combo. Still, this board passes QA.
When “Software Bugs” Are Actually Bad Soldering - A quick MLX90640 IR camera test turned into a dead-on-I2C mystery. I ran the usual checks—addresses, pull-ups, voltages, wiring—and even fixed my forgotten UART/I2C jumper, but still nothing. A peek under the microscope revealed sketchy solder on the 3V3 LDO; a quick reflow and the sensor sprang to life. Lesson relearned: don’t trust factory soldering, look early with a microscope, and stop blaming software when the hardware’s silent.
Self Organising WS2811 LEDs - I've successfully used addressable WS2811 LED strings and an ESP-CAM board to create an adjustable lighting system. The best part is that the image processing code can be duplicated in JavaScript which allows you to use a plain dev board to drive the LEDs instead of needing a camera on your ESP32 board. If you want to replicate this project, you'll need your own ESP32 dev board and some addressable LEDs. After figuring out the location of each LED in 2D space, it's easy to map from each LED's x and y location onto a pattern you want to show on the frame buffer. Desiring to keep it accessible, I've posted detailed instructions and my sample code on GitHub, making sure anyone with basic knowledge can undertake this fun technological DIY project!
A Potentially Explosive Error - Just received the new PCBs for the ESP32-TV project and they're looking sharp with only a tiny resistor tweak needed. But I discovered a sneaky, undocumented resistor causing a conflict between the ESP32 and USB2244 over the USB connection. Fixed that, but there's a bigger issue lurking in the design - check the schematic in the video and see if you can spot it before I reveal the explosive mistake!

Related Videos

I Turned an ESP32 into a Thermal USB Webcam - Last time I made an ESP32 pretend to be a webcam; this time it’s a real USB UVC cam streaming MJPEG. Then I go further: I bolt on a tiny 32x24 infrared sensor, scale it up to 320x240 with nearest-neighbor or bilinear, JPEG it, and stream it like any normal webcam. Along the way I show why ESP32-CAM won’t work (no native USB), dive into I2C gremlins (run a scanner first, check pull-ups), and fix a flaky 3.3V regulator solder job. Quick hardware tour: onboard 2.2K pull-ups, ME6212 LDO, and an AT32F415 MCU. Audio can wait—today’s all about making thermal video look good over UVC.
My ESP32S3 Thinks It's a WebCam! - I turned a vanilla ESP32-S3 dev board into a USB UVC webcam that doesn’t use a camera at all—first streaming a static test card, then an animated GIF, and finally a real-time Pong game. The ESP32 pre-decodes GIF frames to RGB, JPEG-encodes them, and streams MJPEG, and for the live game it renders to a framebuffer, JPEG-encodes in ~23 ms, and just about hits 30 fps. There’s room to optimize (dual-core draw/encode), and this approach is great for dashboards, sensor visualizations, or testing video pipelines. Shout out to PCBWay for the boards—they turned out great.
Stop Using printf() - Debug ESP32 the Right Way - Right, let’s give this a go. Instead of drowning in printf()s and blinking LEDs, I show how the ESP32-S3’s built‑in USB JTAG lets you hit Debug in the Arduino IDE (or PlatformIO) and actually step through code. We set breakpoints, add watch expressions, use conditional breakpoints, and even edit variables live with a simple FizzBuzz/LED demo. It’s quick, it works, and it beats “works on my machine”—just mind real‑time code and ISRs. Works on ESP32s with native USB.
ESP32-S3 USB UAC Audio Device - does it work? - Time for an audio project: I took my PCBWay ESP32‑S3 board for a spin—fixed the common anode/cathode LED mix‑up, verified the IMU and battery charger, then tested an I2S PDM mic and tiny speaker with a Web Serial Audio Studio (scope, spectrogram, tuner). I also turned it into a USB UAC device in ESP‑IDF: the mic is clean, but speaker over UAC is crackly (Mac/Windows toggle oddity); direct I2S WAV playback is perfect, so the hardware passes QA.
Super Easy ESP32-S3 Dev Board - Making an ESP32-S3 dev board is way easier than it looks. I simplify the datasheet reference: skip the external crystal, wire native USB D+/D− (pins 19/20) straight to a USB-C with 5.1k CC pulldowns, add a BOOT switch and an EN RC reset, and power it with an LD117 LDO that’s happy with ceramic caps. In KiCad I build the schematic with Espressif libraries, add LEDs for 5V, 3V3, and a blink GPIO, set up net classes, route a clean USB differential pair, stitch a solid ground plane, and label everything. It’s a bit wide—just gang breadboards together—and you end up with a neat, professional S3 dev board you can flash and debug over USB.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts