Jump to content

Recommended Posts

Posted

Hello everyone! Recently, every time I visit the LEGO Technic, Mindstorms, Model Team and Scale Modeling forum, I do notice more and more topics with some kind of custom electronics or Arduino MCU’s used with LEGO models. And here’s another one :classic:

I started this project some time ago, when I was in search of an RC system for LEGO with two key features:

1) Proportional control for servos to make steering very accurate
2) Ability to control the car directly with a physical remote, excluding any kind of smartphone app between them

While each requirement has its own solution, they cannot be combined:

1) A Powered-Up motor can be used for proportional steering, but it can be controlled only with a smartphone (or with a gamepad, but it also must be connected via the app)
2) There are numerous Power Functions compatible remotes, but none of them feature proportional control 

My initial approach was to adjust the PF controls (old topic here) so these PF-servos could rotate proportionally. Thanks to @gyenesvi and @oracidI learned about the GeekServos, and, eventually, found the way to control them with a PF-compatible remote. However, I didn’t abandon the idea of developing a complete solution which would meet my needs.

Though DIY, soldering and so on are not the first things one would love to do when building LEGO models, perhaps my solution can still be useful for some enthusiasts.

So, finally, now I’m happy to share it here - the GeekShield.

IMG-9978-thumb.jpg

Features:

  • Classic Bluetooth gamepad support (Dualshock 4, DualSense, Xbox Wireless Controller and many others)
  • Direct Bluetooth connection (no iOS/Android apps needed)
  • 2x Power Functions ports, maximum 1.5A at peak per channel (2x Buggy Motors can be used together)
  • 5x classic servo (3-wire) connectors (*only 1 GeekServo can be controlled when using 2xPF motors).
  • Pluggable 2S LiPo battery
  • Battery discharge protection
  • Ready to use Arduino Library for easy programming with Arduino IDE
  • Board size: 5x9 studs + mounts (fits inside 7x11 frame). 
  • Height: 4 studs together with a compact battery

IMG-9979.jpg   IMG-9977.jpg 

Steps to make the GeekShield:

  1. Order PCB production. Though this sounds complicated, now it’s an easy and affordable online service offered by many manufacturers for private use
  2. Buy some other electronic components
  3. Solder the components together. Some basic soldering skills are needed at this point, but no hi-tech or industrial equipment will be required
  4. Write a few lines of code in Arduino IDE to configure the way you want to control your model. The GeekShield library hides most of the code inside, so the sketches are as simple as possible

All source code and PCB files are available on my GitHub (https://github.com/pink0D/GeekShield/). I’m also planning to add some wiki pages there to describe the making process in detail. 

Will be pleased to answer any questions in this topic.

Additionally, I’ve built a MOD of 42161 Lamborghini Huracan as a “mule” car to demonstrate the GeekShield and its relatively small size that fits inside even of a 15-stud wide (1:16 scale) model.

While the drivetrain is entirely custom and has nothing in common with the original model, I was able to place my shield, the battery, 2x L-motors and the GeekServo so the MOD still has the same exterior (except for 2 little panels on the roof), interior, opening doors and hood.

Drifting is not as spectacular as it could be due to model’s weight, but anyway, it’s quite powerful and very cool to drive.

IMG-9967.jpg   IMG-9975.jpg   IMG-9973.jpg   IMG-9971.jpg   IMG-9969.jpg   IMG-9970.jpg   

IMG-9972.jpg         

 

Posted

Holy cow, this is incredibly nicely designed.

I am in total awe - all the boards I love so much assembled in a way, I never could do! This "base" PCB is ingenious - everything is so clean and smartly assembled! Wow.

Congratulations and a deep bow.

Simply wonderful. And as a side note: I truly believe software development was not just "using the Arduino IDE" (which I love) but serious coding - very serious coding was necessary to make this work. Hardware is one thing, figuring out the soft things is an entirely different world.

I am blown away - thank you so much for sharing!

All the best,
Thorsten

Posted
11 hours ago, LabManager said:

1) A Powered-Up motor can be used for proportional steering, but it can be controlled only with a smartphone (or with a gamepad, but it also must be connected via the app)

You can do that all standalone with a hub or via external ESP i.E:

 

Posted

Sure, there are some more options:

1) Powered Up Motor -> Technic Hub (88012 or even 88009) -> Custom DIY ESP32 gamepad with BLE support (example)
Then use legoino library to control the Hub by LWP 3.0

2) Powered Up Motor -> Technic Hub -> ESP32 board which supports both BLE and BT Classic -> Dualshock or XBox controller
The ESP32 will have the same function as the smartphone app: it will control the hub by BLE link with inputs received from the gamepad via BT Classic
 

Posted
On 2/1/2025 at 12:26 AM, Toastie said:

i.e.: what

i.e. hub, pybricks, Xbox-controller
Or external ESP with legoino, as I showed her years ago.
No "App" at alle required.

But the solution of @LabManager has completely other features of a different world.

 

Posted

Nice work! The possibility of driving directly with a gamepad is very appealling compared to the Lego remotes, or smartphone.

You mentioned there is battery discharge protection. Is that built into the motor driver, or is it implemented in software?

Posted
1 hour ago, tseary said:

You mentioned there is battery discharge protection. Is that built into the motor driver, or is it implemented in software?

It's a hybrid solution.

The software part: one of ESP32's pins is connected to the voltage divider so the ADC can measure 2S battery voltage indirectly.  Though this adds some error (not mentioning that ESP32's ADC has poor accuracy itself), the software can read a value which is +/- 10% near the true battery voltage. That's enough to catch the situation when the battery level becomes too low.

The hardware part: the ESP32 cannot shutdown itself, but the Pololu's power switch has a nice feature: it can not only switch the power on and off with the physical pushbutton, it can also cut off the power when it gets a signal from the MCU. So when the ESP32 measures the low battery level, it can just shutdown the power supply of the whole board.

Posted
4 hours ago, LabManager said:

The hardware part: the ESP32 cannot shutdown itself, but the Pololu's power switch has a nice feature: it can not only switch the power on and off with the physical pushbutton, it can also cut off the power when it gets a signal from the MCU. So when the ESP32 measures the low battery level, it can just shutdown the power supply of the whole board.

That is a very nice and safe solution! I am really totally impressed by your work!

All the best,
Thorsten

Posted

This looks like yet another really nice project @LabManager! The code looks nicely structured. I have a few questions:

- What are those "other electronic components"? Is it like wires and connectors / resistors, or is it those two small green boards?

- What does the BT connect to? The ESP? Or one of those smaller separate boards?

- What powers/controls the PF ports, does it have a separate motor driver? Is it one of the small separate boards? Are the two PF ports separately controllable?

- Are the PF connectors glued to the board?

- Why can only be 1 GeekServo used when using 2 PF motors? Is it related to power (max amps) or number of output channels?

 

Posted
6 hours ago, gyenesvi said:

What are those "other electronic components"? Is it like wires and connectors / resistors, or is it those two small green boards?

Yes, green boards are the main components: ESP32-CAM (the MCU), Pololu Pushbutton power switch and the DRV8835 motor driver. The complete list of materials (except for usual stuff for soldering) is here

7 hours ago, gyenesvi said:

What does the BT connect to? The ESP?

Yes, ESP32 chips have built-in support for Bluetooth. While there are smaller ESP32 boards, I've chosen the ESP32-CAM, which is a pretty old chip/board introduced back in 2016 I think, however, it is still available on marketplaces. The chip used in ESP32-CAM has support for Bluetooth Classic, so a direct connection with a gamepad can be made. Modern ESP32 usually support only Bluetooth Low Energy (BLE).

7 hours ago, gyenesvi said:

What powers/controls the PF ports, does it have a separate motor driver? Is it one of the small separate boards? Are the two PF ports separately controllable

The PF motors are powered by the DRV8835 motor driver (the smallest of the green boards), which can deliver 1.2A (1.5A peak) per channel. And yes, two ports are independent.

7 hours ago, gyenesvi said:

Why can only be 1 GeekServo used when using 2 PF motors? Is it related to power (max amps) or number of output channels?

ESP32-CAM board has very limited amount of pins that can be used for output. The board was initially designed as a camera carrier so most of MCU pins are internally used for camera connection. So, there are only 5 pins for PWM output. Each PF motor needs 2 inputs (C1/C2), so when 2x PF motors are used there is only 1 pin left for GeekServo's signal. But if you want, you can detach the motor driver and connect 5x GeekServos to these pins. There is a green version of GeekServo which is not a 360 servo, but a continious rotation motor. It can be controlled to rotate with variable speed both clockwise and counterclockwise, but it needs just one signal wire to control it.

As for power, I believe a high rated LiPo battery can easily power 5x GeekServos simultaneously.

7 hours ago, gyenesvi said:

Are the PF connectors glued to the board?

They are glued. Didn't find any smarter solution to fix them reliably.

A 3D-printed shell does not seem to be the solution either:
- this would make the DIY controller even more complicated
- I don't beleive it's possible to print the studs with adequate precision so the connection with the PF plug is reliable

Posted (edited)

Thanks for all the answers!

18 hours ago, LabManager said:

Yes, green boards are the main components: ESP32-CAM (the MCU), Pololu Pushbutton power switch and the DRV8835 motor driver. The complete list of materials (except for usual stuff for soldering) is here

This detailed process description is quite insightful, thanks!

Yes, I know about the green GeekServos, but I think having two PF motors along with 2-3 GeekServos would be quite nice for models that need steering plus gearbox maybe.

By the way, I assume that the PF ports can be used to drive PF servos as well, right?

I think the glued PF ports are quite simple and good enough solution for a DIY project like this. I like the simplicity of all the components used.

How do you power the system? I mean can the LiPo be connected directly to the ESP, or does it need some down-regulation? The motor driver gets the full input of the LiPo, right? (apart from the control signal, which is lower I guess)

One thing I wonder if this all could be made smaller a bit. Even a size that actually fits inside 9x5 (including mounting points) would be good. For example, I see that the bigger green board is the switch, from which a smaller variant also exists. Would that be sufficient? (Edit: I can see now from the list of materials that you are using the small one.) Anyway, maybe with a smaller ESP32, the whole thing could be made smaller I guess.

Edited by gyenesvi
Posted
18 hours ago, gyenesvi said:

By the way, I assume that the PF ports can be used to drive PF servos as well, right?

Sure, and if you have the original servo it will have proportional control. The trick for 3rd party servos isn't present here because it would require more components, so those servos will rotate only -90/0/+90 degrees.

18 hours ago, gyenesvi said:

How do you power the system? I mean can the LiPo be connected directly to the ESP, or does it need some down-regulation? The motor driver gets the full input of the LiPo, right? (apart from the control signal, which is lower I guess)

The whole board is powererd by 7.4V from the 2S battery:
- ESP32-CAM has an internal voltage regulator (AMS1117), which is not very efficient and should not be used to down-step 7.4V if the camera is attached, but here there's no camera, so the board needs very little power and the internal AMS1117 doesn't overheat.
- GeekServos have 3.6-6V operating voltage range, but it seems that 7.4V is also OK. I've ordered some more GeekServos, will disassemble one of them to see what's inside. Probably this will give the understanding of its real voltage tolerance
- the motor driver (DRV8835) gets 3.3V from the ESP32-CAM as logical inputs, and full 7.4V from the battery for powering motors. So C1/C2 outputs are 7.4V. It's interesting to test if the DRV8835 will tolerate 11.1V from a 3S battery, which would give significant more torque from motors, but didn't have time to do that.

 

19 hours ago, gyenesvi said:

One thing I wonder if this all could be made smaller a bit.

In fact, I'm thinking of a bigger board :classic: 

Some of the ideas for the new board are:
- use ESP32 WROOM. It's even bigger, but it has more pins which I can use for outputs (obviously the smaller modern ESP32 boards have even less pins than ESP32-CAM, and they lack BT Classic support which is a key feature)
- use the other motor driver (TB6612FNG). It also capable to output high currents (1.2A continiously or even 3.2A at peaks!), and it has higher maximum motor voltage (13.5V), so I can reliably upgrade the power supply to a 3S LiPo. The downside here is that TB6612FNG does not have any of protections that DRV8835 has (overcurrent for example). Didn't measure the stall current for a buggy motor, but perhaps its not as high as 3.2A
- since there will be more output pins, possibly 2x motor drivers for 4xPF motors + some 4-5-6 GeekServos can be controlled independently
 

Posted

This bigger board sounds a lot more like it! If it can reliably drive 4x buggy motors, then it may serve as a much needed competitor to buwizz units. Being able to use a 3s lipo is very important in my eyes, I think you should make sure its possible.

Posted
On 2/2/2025 at 6:28 PM, LabManager said:

The hardware part: the ESP32 cannot shutdown itself, but the Pololu's power switch has a nice feature: it can not only switch the power on and off with the physical pushbutton, it can also cut off the power when it gets a signal from the MCU. So when the ESP32 measures the low battery level, it can just shutdown the power supply of the whole board.

Which one do you use Pololu Power Switches

Good work !  Thank you for sharing. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...