Beta ends on 30 November: 30 days of Pro free →
Blog/Tutorial/An ESP32-CAM camera in my loco: the step-by-step guide
Tutorial

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.

Frédéric
Frédéric

Creator of LocoPilote

21 November 2026

📖 7 min read

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

ItemDetails
ESP32-CAM boardThe black board with the micro-SD card reader (“AI Thinker” model, the most common one)
USB programmerThe small “ESP32-CAM-MB” board supplied with it, which the camera board plugs onto, with its micro-USB socket
Camera moduleThe OV3660 sensor on its orange ribbon cable (or OV2640 in other batches: both work)
Micro-USB cableA data cable, not a charge-only one
Windows PCThe one that runs LocoPilote
Wi-FiYour 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.

  1. Download Arduino IDE 2 from arduino.cc/en/software (Windows, “Win 10 and newer”) and install it, leaving every option at its default.
  2. Open Arduino IDE, then File → Preferences. In “Additional boards manager URLs”, paste: https://espressif.github.io/arduino-esp32/package_esp32_index.json
  3. Click OK, then open the Boards Manager (board icon on the left, or Tools → Board → Boards Manager).
  4. Type esp32 and 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

  1. Plug the camera board onto the ESP32-CAM-MB programmer, lens facing up, with all the pins lined up.
  2. Connect the micro-USB cable between the programmer and the PC.
  3. In Arduino: Tools → Port should offer a new port, for example COM5. Select it.
  4. 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.

  1. Tools → Board → esp32 → AI Thinker ESP32-CAM.
  2. Tools → Partition Scheme → Huge APP (3MB No OTA/1MB SPIFFS).
  3. File → Examples → ESP32 → Camera → CameraWebServer. A new window opens with several tabs.
  4. 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, often CAMERA_MODEL_ESP_EYE);
    • remove the // in front of #define CAMERA_MODEL_AI_THINKER.
  5. 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";
  1. File → Save As… to keep a copy, for example in Documents.

Step 4 — Upload the program and find the camera’s address

  1. Click the Upload arrow (→, top left). Compiling takes 1 to 3 minutes, then “Writing…” runs up to 100 %.
  2. Open Tools → Serial Monitor and select 115200 baud at the bottom right.
  3. 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
  1. Write down this address, for example 192.168.1.42 (yours will be different).
  2. On the PC, open http://192.168.1.42 in your browser, then click Start Stream: the picture should appear.
  3. Also test the address LocoPilote will need: http://192.168.1.42:81/stream should 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.

  1. 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).
  2. Look for the connected devices or DHCP server menu: “DHCP leases”, “Static IP address” or “Reservation”, depending on the router.
  3. 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

  1. Locomotives → open the loco’s record → Camera tab. You can also go through the Cab panel → ⚙ Camera settings.
  2. Type: ESP32-CAM / MJPEG stream.
  3. Address: http://192.168.1.42:81/stream, with the address noted in step 4, without forgetting :81/stream.
  4. 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.
  5. Save. If the camera is mounted upside down in the loco, choose the image turned by 180°.
  6. 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 seeWhat to do
“Failed to connect to ESP32” during uploadThe 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 jumperWith the ESP32-CAM-MB programmer, the IO0 button replaces it (see the “Failed to connect” row above).
No COM port in ArduinoInstall 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 monitorNot 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 monitorCheck 115200 baud and press RST.
The serial monitor stays empty even after RST, on two PCs and with two cablesThe board is probably faulty: ask for an exchange.
Picture in the browser but “unreachable” in LocoPiloteCheck :81/stream at the end of the address and close the browser tab that is still showing the camera.
Frozen picture in LocoPiloteChoose 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

Share:
Frédéric

Frédéric

Creator of LocoPilote

Developer and railway modeller, creator of LocoPilote. Passionate about automating model railway layouts.

Related articles