Ami Tavory

Noob experience in connecting esp32cam to LEGO vehicle

Recommended Posts

1. Cutting, soldering, and connecting wires to othe components, may harm your equipment and/or you. I am not an expert on this topic (quite the opposite), and just want to discuss some noob pitfalls. Exercise caution especially when cutting and soldering.
2. Everything in this post involves generic parts bought in AliExpress, including the LEGO bricks.

Following are some points on connecting an esp32cam to a LEGO vehicle, so that it is powered by a standard LEGO plug, can transmit a video stream over wifi, and responds to bluetooth commands.grey_lightning.jpeg

(The model is a modification of Madoca's wonderful Blue Lightning buggy with all the realistic parts removed, and the structure rearranged to accommodate the microcontroller stuff I plan to mount on it.)

The esp32cam is going for less than 5$, which means you can probably get whatever number you want and just leave them in your models. It is very powerful: with a bit more hardware, it can control motors and many useful sensors. On the downside, this approach is less polished than using LEGO controllers or some other great projects (for example, using md5stack). There are many great tutorials I used for setting it up, and I just wanted to link to useful ones and write some pitfalls I ran into. Do please comment if there are any errors or ways to improve.

1. To start, you need an esp32cam and FTDI (one FTDI for all esps is enough). Also some Dupont female-to-female and male-to-male wires, heatshrink wraps, and soldering stuff. 


2. Flashing the basic stuff onto the esp32cam is explained very well in this talk. Two things to note (possibly specific to the Chinese boards):

  a. All tutorials on esp32cam use units that were shipped with the camera preconnected, and say to snap it in if it comes separately. If you need to connect yours, note that there's a lid you need to raise when inserting it (it's easy to miss if you don't know it's there, and took me some time to notice).

  b. You might get better results programming the esp32cam on 3.3V, but, after that, use 5V. This requires changing jumpers on the FTDI, and using the 5V input for the esp32cam. 

  c. Obviously, make sure you can run your sketch and see a video stream while your esp32cam is still connected to the FTDI board, before you try powering it via a LEGO battery box and mounting it on a model. So the steps probably are: program with the FTDI using 3.3V, test/debug using the FTDI using 5V, then disconnect and proceed to the next steps. 

2. Now prepare the LEGO wiring. I did the entire steps following, just to see at the end that I shorted something, and had to cut more LEGO cable and start again. Because of this, it is probably good to check with a multimeter at each step that you get the expected voltage (7.3 or 9 depending on whether the battery box is rechargeable or not - I didn't try it with 12).

  a. Take an expendable LEGO PF cable, and align it to the following image (from scuttlebots). Cut the cable (probably at midpoint) using a wire cutter.


Note that for powering a microcontroller, we only need the two outer wires


b. Strip the wires, and cut and strip also two female Dupont wires. By convention, black is for ground, and use some lighter colour for VCC. Solder the Duponts to the stripped LEGO cable


(this was my first attempt, and I redid it to remove the blobs).

Remember to solder black to ground, since, otherwise, you could fry your microcontroller by connecting wrongly.

3. Get some heatshrink tubing (I didn't know which kind I need, so just bought several different ones online), and wrap the soldering so that there are no exposed connections.



5. Temporarily connect male-to-male Duponts, and use a multimeter to ensure things are working:

  a. Connect the plug to a battery box.
  b. Connect the male Duponts to the female, and touch the multimeter prongs to the other sides of the male parts.
  c. Use the multimeter to see the voltage is stable.


6. Mount the esp32cam to some Lego. For the board I had, I found it fit a 5X7 liftarm frame very well, with the pins accessible and pluggable at the back. I tried to hot-glue it, but it didn't stick, so I just scotch-taped the back part (there must be a better alternative). 

Share this post

Link to post
Share on other sites

Most of the projects combining microcontrollers and bricks, have electronic wires running all over the place. This makes modular building difficult, and, moreover, the wires don't have the strength that the bricks' power cables does. I'm trying to build simple modular microcontroller/sensor components, where the electronic wires are tucked away, the power-functions cable is the only thing that sticks out, and the power-functions cable is the one that takes the connection stress (if you tug on it, the electronic wires don't come out). 

For an ESP32Cam, I came up with something like the following. From the front, it is a camera in a liftarm 5X7 frame:


In the back, there are only two curved panels, with a power-functions cable sticking out:


The electronic wires, soldering, and other crap, is on the inside:



The main point is run the power-functions cable through two liftarms connected via pins. This way, if the cable gets tugged, it is the one that bears the stress. Internally, it does not pass the stress to the parts soldered to it. Model.pdf

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.