An ESP32-CAM camera in my loco: the step-by-step guide
An ESP32-CAM board films the track from the loco and sends the picture over Wi-Fi; LocoPilote shows it in the Cab. The full guide, from installing Arduino to the first test, without writing any code.
The ESP32-CAM board films the track from the loco and sends the picture over Wi-Fi; LocoPilote shows it in the Cab. Allow one hour the first time, including 10 minutes of downloading.
What you need
| Item | Details |
|---|---|
| ESP32-CAM board | The black board with the micro-SD card reader (“AI Thinker” model, the most common one) |
| USB programmer | The small “ESP32-CAM-MB” board supplied with it, which the camera board plugs onto, with its micro-USB socket |
| Camera module | The OV3660 sensor on its orange ribbon cable (or OV2640 in other batches: both work) |
| Micro-USB cable | A data cable, not a charge-only one |
| Windows PC | The one that runs LocoPilote |
| Wi-Fi | Your home network on 2.4 GHz: the ESP32 cannot see 5 GHz |
First of all: gently lift the small black latch of the connector on the board, slide in the camera’s ribbon cable (contacts facing the board), then close the latch.
Step 1 — Install Arduino and the ESP32 package
Arduino is the free software that sends the program to the board. You only install it once.
- Download Arduino IDE 2 from arduino.cc/en/software (Windows, “Win 10 and newer”) and install it, leaving every option at its default.
- Open Arduino IDE, then File → Preferences. In “Additional boards manager URLs”, paste:
https://espressif.github.io/arduino-esp32/package_esp32_index.json - Click OK, then open the Boards Manager (board icon on the left, or Tools → Board → Boards Manager).
- Type
esp32and install “esp32 by Espressif Systems”. It is a big download: wait for the message saying it has finished.
Step 2 — Connect the board to the PC
- Plug the camera board onto the ESP32-CAM-MB programmer, lens facing up, with all the pins lined up.
- Connect the micro-USB cable between the programmer and the PC.
- In Arduino: Tools → Port should offer a new port, for example COM5. Select it.
- No port shows up? The CH340 driver (the programmer’s USB chip) is missing. Install it from the manufacturer’s website, wch-ic.com (https://www.wch-ic.com/downloads/CH341SER_EXE.html), then unplug and plug in again. Still nothing? Try another cable: many cables only charge.
Step 3 — Prepare the “CameraWebServer” program
No need to write any code: the ESP32 package includes a ready-made example that films and streams the picture.
- Tools → Board → esp32 → AI Thinker ESP32-CAM.
- Tools → Partition Scheme → Huge APP (3MB No OTA/1MB SPIFFS).
- File → Examples → ESP32 → Camera → CameraWebServer. A new window opens with several tabs.
- Select the board model. Depending on the package version, this is in the CameraWebServer.ino tab or in the board_config.h tab. Look for the list of
#define CAMERA_MODEL_...lines:- add
//in front of the active line (the one without it, oftenCAMERA_MODEL_ESP_EYE); - remove the
//in front of#define CAMERA_MODEL_AI_THINKER.
- add
- In CameraWebServer.ino, replace the asterisks with your Wi-Fi name and password, keeping the quotation marks:
const char *ssid = "NomDeMaBox";
const char *password = "MotDePasseWifi";- File → Save As… to keep a copy, for example in Documents.
Step 4 — Upload the program and find the camera’s address
- Click the Upload arrow (→, top left). Compiling takes 1 to 3 minutes, then “Writing…” runs up to 100 %.
- Open Tools → Serial Monitor and select 115200 baud at the bottom right.
- Press the small RST button on the camera board. After a few seconds, you will read:
WiFi connected
Camera Ready! Use 'http://192.168.1.42' to connect- Write down this address, for example
192.168.1.42(yours will be different). - On the PC, open
http://192.168.1.42in your browser, then click Start Stream: the picture should appear. - Also test the address LocoPilote will need:
http://192.168.1.42:81/streamshould show the picture on its own.
Close the browser before moving on to LocoPilote: the camera often serves only one screen at a time.
Step 5 — Always keep the same address
Your router may give the camera a different address the next time it is switched on, and LocoPilote would no longer find it. So you ask the router to reserve its address.
- Open your router’s web interface in the browser (often
http://192.168.1.1; the address is usually printed on a label on the router). - Look for the connected devices or DHCP server menu: “DHCP leases”, “Static IP address” or “Reservation”, depending on the router.
- Find the esp32-… device (or the one with the address noted in step 4) and reserve that address for it.
If this is too complicated, it is not a blocker: you will just have to correct the address in LocoPilote if it changes.
Step 6 — Connect the camera in LocoPilote
- Locomotives → open the loco’s record → Camera tab. You can also go through the Cab panel → ⚙ Camera settings.
- Type: ESP32-CAM / MJPEG stream.
- Address:
http://192.168.1.42:81/stream, with the address noted in step 4, without forgetting:81/stream. - Click ▶ Test the camera. If all is well, you will read “Image received · N frames/s”. Otherwise, LocoPilote tells you why: unreachable, no image, and so on.
- Save. If the camera is mounted upside down in the loco, choose the image turned by 180°.
- Open the Cab of this loco: the windscreen shows the camera, and the Full-screen camera tab enlarges it. The 📸 Photo button saves an image in Pictures → LocoPilote.
The setting stays on this PC: it is not sent to the server. If the camera switches off, the Cab shows “Camera lost — trying again…” and the picture comes back on its own within 30 seconds of switching it back on.
To install it in the loco, the board needs a stable 5 V supply, not the track current directly. A small 5 V regulator and a capacitor are required: that will be the subject of a second guide.
Troubleshooting
| What you see | What to do |
|---|---|
| “Failed to connect to ESP32” during upload | The board does not enter programming mode. Tools → Upload Speed = 115200, close the serial monitor. Click Upload; during “Connecting……”, hold IO0 (programmer), press then release RST (edge of the camera board), release IO0. Otherwise: unplug, hold IO0, plug the USB back in, release, upload. Push the board firmly onto the programmer, try another cable or another USB socket on the PC. |
| No IO0–GND jumper | With the ESP32-CAM-MB programmer, the IO0 button replaces it (see the “Failed to connect” row above). |
| No COM port in Arduino | Install the CH340 driver (step 2); change the USB cable; try another socket on the PC. |
| “Multiple libraries were found for WiFi.h” or “Invalid library” | These are only warnings, with no effect. |
| “Brownout detector was triggered” in the serial monitor | Not enough power: plug directly into the PC (not into a hub), or into a 5 V 2 A charger. |
| “Camera init failed” | Wrong model selected (go back to step 3, AI Thinker) or ribbon cable not fully inserted: open the latch again and put it back in straight. |
| Dots scrolling without “WiFi connected” | Wrong Wi-Fi name or password, or a 5 GHz-only router; move the camera closer to the router for the test. |
| Nothing in the serial monitor | Check 115200 baud and press RST. |
| The serial monitor stays empty even after RST, on two PCs and with two cables | The board is probably faulty: ask for an exchange. |
| Picture in the browser but “unreachable” in LocoPilote | Check :81/stream at the end of the address and close the browser tab that is still showing the camera. |
| Frozen picture in LocoPilote | Choose the Still image over http type with the address http://192.168.1.42/capture (without :81) and send us the log with “Report a problem”. |
© 2026 LocoPilote — text and screenshots: reproduction prohibited without permission. Short quotes allowed with a link to this article. Legal notice

Frédéric
Creator of LocoPilote
Developer and railway modeller, creator of LocoPilote. Passionate about automating model railway layouts.
Related articles

Getting started with LocoPilote: your first train, no hardware needed
From creating your account to a first train stopping at the station: LocoPilote's welcome steps one by one, with no command station or layout connected.

Blocks and detection: stopping a train in the right place with a single detector
One block, one detector, and the train still stops in the middle of the platform: how LocoPilote computes the stop, and what makes it accurate.

The accelerated clock: model time that runs up to 60 times faster
On a model railway, a real hour is long. With LocoPilote's accelerated clock, your layout's day runs up to 60 times faster, and scheduled departures follow model time.