Back lovickconsulting.com Prusa Connect Camera Core One Esp32 S3 Ov5640
Update (November 2026): This project was featured on Hackaday — “Camera Upgrades For 3D Printers” .
Prusa Connect will show a live picture of each printer if you give it a camera, and Prusa publishes open-source firmware that turns an inexpensive ESP32 camera board into one. I wanted one on my Core One that was small enough to sit inside the enclosure, sharp enough to read a first layer, and able to record a timelapse of every print without a computer involved. That took a printed holder, a different camera module and, over August, 42 revisions of the firmware. This post is an account of what went wrong along the way, because most of it is the kind of thing that will catch anyone who tries the same board.
The board is a Seeed Studio XIAO ESP32-S3 Sense : an ESP32-S3 with 8 MB of PSRAM, Wi-Fi and a microSD slot on a board the size of a thumbnail. It ships with a small camera module, which I replaced with an OV5640. The OV5640 has two things the stock modules lack: a 5-megapixel sensor (2592 × 1944) and an autofocus motor, which matters when the camera is a few centimetres from a print bed that moves.
The holder started as ESP32 Camera Mod for CORE One on Printables by KeepTheBOX , which follows the design of Prusa’s own Buddy3D camera: it sits in a top corner of the enclosure and is held there by three magnets. It is a neat design: the corner is chamfered, and the three magnets sit around the corner’s diagonal, 120° apart, so the holder self-locates and pulls itself square. I changed two things.
The first was the magnets. The original pockets are for 8 × 3 mm discs, and I wanted to be able to use other sizes, so I rebuilt the magnet features in OpenSCAD as parameters: diameter, thickness, the radial and axial fit, and the position, expressed in the printer’s own corner geometry rather than in the CAD program’s coordinates. That last part is what made it work. Measured from the STEP file, each magnet sits 35° off the corner diagonal at a radius of 20.28 mm, so once the corner is the frame of reference a new magnet size is one number changed and everything else follows. Each pocket also got a 3 mm hole behind it, so a magnet that has been pressed in too far can be pushed back out with a rod rather than dug out. I have printed versions for 10 × 2, 8 × 3, 8 × 5 and 6 × 4 mm magnets; the one on the printer uses 6 × 4 mm discs, in pockets 0.05 mm wider per side and 0.3 mm deeper than the magnet.
The second was the case, which I made a third deeper, 26.6 mm instead of 20, by stretching it along its depth in PrusaSlicer. Both parts went through PP, PC, PETG and carbon-fibre nylon (PA-CF) before I settled on plain PETG, printed on the Core One with a 0.6 mm nozzle at 0.2 mm layers, 240°C on the nozzle and 85°C on the bed; the holder has three perimeters and 25% infill. The camera is inside a heated enclosure, so the material has to cope with the chamber temperature as well as hold a magnet.
Both parts are on Printables as a remix of the original , with the OpenSCAD files for other magnet sizes and the PrusaSlicer projects with these settings. Like the original, it is under a Creative Commons Attribution–NonCommercial–ShareAlike licence.
Autofocus, and a corrupted firmware blob
The OV5640’s autofocus is run by a tiny 8051 microcontroller inside the sensor, and it does nothing until its firmware is uploaded, 4 KB, over the camera’s control bus, every time the camera starts. Espressif’s camera driver has code for this, but in the Arduino build I was using it is compiled out: the autofocus functions exist only as stubs. So the firmware had to be loaded by hand.
My first attempts used an autofocus routine from another project, and the sensor’s microcontroller loaded it and then sat in its start-up state forever. The cause turned out to be the blob itself. It was 4,332 bytes, with a stray 0x80 byte inserted roughly every 16 bytes; the real firmware is 4,077 bytes. The first few bytes were right, so reading them back after the upload made it look as though everything had arrived intact. Replacing it with Espressif’s own copy, and porting their command handshake faithfully, fixed it at once. Autofocus now works, and there is a simple way to see that it does: one button relaxes the lens so a close object goes visibly soft, and pressing Autofocus snaps it back.
The lesson is an old one. When a known protocol fails at the first step, check the data before the code.
The SD card that would not mount
The timelapse needs the SD card, and on this board the stock firmware could not see one at all: cardType=0 , on any card. It took three separate fixes, and each one on its own looked as though it should have been the answer.
A shared pin. On the XIAO ESP32-S3 Sense, GPIO21 is both the on-board status LED and the SD card’s chip-select line. The firmware was blinking the status LED, which held the card’s chip-select and stopped it initialising. The fix is to leave the LED off and hold the pin high, so on this board there is no status LED.
Stack overflows. Several of the firmware’s background tasks had stacks of 2,000 to 3,000 bytes, too small for the logging code they called. The SD card task overflowed its stack and corrupted the heap, which can also wedge the SD driver. Giving eight tasks larger stacks cost 13 KB of RAM, of which there is plenty.
Timing. A separate test sketch showed the card, the pins and the driver all working perfectly, but only when the card was accessed a few seconds after boot. The firmware was mounting it 100 ms into boot and giving up by 600 ms. An 800 ms settle and up to ten retries, tearing the driver down between each, fixed the rest.
The first two are bugs in the upstream firmware on this board rather than in my changes, so I have reported them to Prusa .
Later, the card itself became the problem. ESP-IDF’s FAT driver is less tolerant than Windows of a slightly unusual FAT32 layout, so a card that Windows formats and reads without complaint can be rejected by the camera. Formatting with the SD Association’s SD Card Formatter rather than with Windows fixed that. A power cut during a write can also leave a cheap card’s file system damaged, so the firmware now tells “card present but corrupt” apart from “no card”, and has a Recover button that reformats the card from the browser. I also lowered the SD clock from 20 to 10 MHz, because the XIAO runs the card in 1-bit mode and 20 MHz is marginal. After three episodes on the same bulk-pack card I have concluded that the real fix is a high-endurance card, of the kind sold for dash cams, which is built to be written to all day.
Digital zoom, the hard way
The camera sees the whole bed, and for a first layer I wanted to zoom in. The obvious way is to have the sensor read out a smaller window of its pixel array, which costs nothing per frame. It gave a magenta cast. I tried re-applying the white balance, reordering the sensor set-up and switching on pixel binning; none of it cleared the cast, and binning made the picture worse.
So the zoom is now done in software: the sensor always captures its full frame, with normal colour, and the firmware decodes each JPEG, crops the part you asked for and re-encodes it. That too took two goes. The first re-encode produced psychedelic false colour, because the decoder writes pixels in one byte order and the encoder reads them in the other. The second was correct in colour but very dark, because of how the library scales 5- and 6-bit colour channels; converting to full 8-bit colour before re-encoding fixed it. The zoom is capped so the crop never falls below 640 × 480 (4× at full resolution), and once zoomed you can drag the view around the frame, which works as a virtual pan and tilt.
Exposure that would not sit still
On a fixed scene the OV5640’s automatic exposure hunts, swinging the picture between washed out and dark. The firmware now has a “Lock exposure to current” button, which reads the exposure and gain the sensor has settled on, fixes them and turns automatic exposure off, so it freezes on a good picture rather than jumping to a default. Brightness, contrast and saturation are written straight to the sensor’s image-processing registers, which gives far finer control than the five steps the driver offers, and the whole set-up, including the zoom and pan, can be saved and restored.
A timelapse that starts itself
The part I use most is the timelapse. The camera polls the printer’s local PrusaLink interface, and when a print starts it begins recording; when the print finishes it stops and closes the file. It only stops recordings it started itself, so a manual recording is left alone. The video is a standard MJPEG AVI on the SD card that plays in VLC, and the file header is rewritten after every frame, so a recording cut short by a power cut is still playable up to that point. Videos and stills download from the camera’s own web page. There is no server involved anywhere.
The firmware is on GitHub at github.com/SamLovick/Prusa-Firmware-ESP32-Cam , on the xiao-esp32s3-ov5640 branch, with a changelog that records every one of the 42 revisions and why it was made. It is a fork of Prusa’s 1.1.2 release under the same GPL-3.0 licence, and it reports itself to Prusa Connect as 1.1.2 so Connect knows what it is talking to.
It is written for one board and one camera, and I would rather say so plainly than have you discover it. The status LED is off for the reason above; the automatic update from Prusa’s GitHub is switched off, because it would replace this firmware with the stock one (updates are by uploading a compiled .bin from the browser); and it joins your Wi-Fi directly rather than starting a set-up access point, so you put your network name and password in mcu_cfg.h before building (or set WIFI_FORCE_STA_CREDENTIALS to false to get Prusa’s set-up access point back). If you have a XIAO ESP32-S3 Sense and an OV5640 it should work as it is. On any other board, the SD and autofocus fixes are the parts most worth borrowing. If you try it and something does not behave, an issue on the repository would be very welcome.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
