The first electronic autonomous robots with complex behavior were created by William Grey Walter of the Burden Neurological Institute at Bristol, England in 1948. It was a three-wheeled tortoise robot capable of find their way to a recharging station when it ran low on battery power.
Inspired by this story, I decided to modify the Arduino Alvik to add a very basic self-charging system—using only the built-in sensors to locate the charging base.
By default, the Arduino Alvik comes with a Li-ion 18650 battery that charges via a USB-C port on the ESP32 mounted on the upper chassis. Physically attaching a cable to that USB-C connector seemed overly complex due to the precision and pressure required. After considering alternatives like a negative contact plate and a suspended wire for the positive terminal, I landed on using a 5V/1A wireless charger based on resonant magnetic coupling. These chargers have a transmitter and receiver that work over short distances. The transmitter is powered by 12V and outputs 5V to the receiver. In theory, the maximum working distance is 10mm but for my case it was 6mm.
I soldered the wireless charger receiver to the VBUS and GND pins on the Arduino Nano ESP32. (Thanks Giovanni for the support about this) Now, if Arduino Alvik is turned off, a red blinking light will show that the battery is charging. With the Alvik turned on, this read light wont indicate charging status but the battery will be safely charged anyway.
Note: this hack involves soldering and it could invalidate the warranty. Please be sure to know what are you doing and make sure also that soldering does not short the pins.
DockingWith wireless charging solved, the next challenge was docking. How do we check the battery level? And once it's below a threshold, how does Alvik locate the charger and align itself?
Checking the battery level is simple—it’s already built into the Alvik API. Just call a function. As for locating the charging base, there are many possible methods: Bluetooth beacons, IR, LiDAR, AI cameras, etc. But the idea here was to not add any external sensors.
So I came up with this approach: Alvik will autonomously roam the area using its distance sensor to avoid obstacles. When the battery drops below a threshold, it will enter “base search” mode. In this mode, if it encounters a black line, it will follow it—because that line leads to the charger. Once it's on the correct path, the charging base will help guide the robot into place. Alvik will stop, recharge until reaching an upper battery limit, undock, and resume its navigation.
Some of the Alvik API functions used are the following.
For obstacle avoidance, alvik.get_distance()
.To detect the charger path line, alvik.get_line_sensors()
.To detect final docking position, alvik.get_color_label()
.
Software complexity
The software grew on complexity since at testing phase some issues appeared. Charging path line was not always followed right, so I have added proportional controls. Sometimes, Alvik crossed the charging path line, so I have added a function to locate it by turning. Sometimes it got stuck in a loop so I have added a loop verification. I also added a secondary tape color to let Alvik knows that charging path was over opposing to a missing line.
Required Parts- Arduino Alvik
- 1A 5V Wireless charger
- 12V DC power supply (input 12v, output 5v)
- 3D printed charging base
- Glue pistol
Alvik operates using subprograms:
standardNavigation()
: Handles normal movement while avoiding obstacles.chargingStationPath()
: Follows the black line to the charging stationSearchPath()
: if Alvik misses the charging path line it will try to find it
The charging base is 3D printed in PLA. The wireless charger’s transmitter is hot-glued to the internal face of the base. The receiver is also hot-glued to the Alvik, but you could design a cleaner solution using a bracket and M3 screws.
Software ConfigurationOpen the autocharge20.py file and edit the settings
safeDistance=10
kp = 50.0
lineSpeed = 15
standardSpeed=30
lineLimit=250
batteryLimit=20
alwaysCharge=0
testMode=0
Then upload the file to Alvik using the Arduino Lab for MicroPython software. Finally edit main.py and leave import autoCharge20.py Save, disconnect and start Alvik.
Sometimes it could be required also to press the reset button on top of the Arduino Nano ESP32 to start.
DemonstrationFinal Notes
This upgrade gave Alvik a notable boost in autonomy by letting it manage its own charging. Even though the setup is simple, there’s something satisfying about watching the robot dock and undock from its charging station.
Files and linksContact
Roni Bandini Instagram X.com
Comments