Wiring
This page is for wiring the loader at home, then turning it on for the first time without frying anything. The most common mistakes (a buck converter that isn’t set, an encoder on 5 V, a servo that can’t take the battery’s voltage) damage parts in the very first second, so take the time to go through the checklist in order.
ESP32 pinout
Section titled “ESP32 pinout”The board is an ESP32-C3 SuperMini. This table follows firmware/src/config.h: if the two ever
disagree, config.h wins.
| GPIO | Function | Good to know |
|---|---|---|
| 0 | Battery voltage (analog input) | Through a 100 kΩ / 20 kΩ voltage divider, with a 100 nF capacitor to ground. |
| 1 | IR phototransistor | 10 kΩ pull-up resistor to 3.3 V. The signal goes high when a BB breaks the beam. |
| 3 | Servo signal (PWM) | Only the control wire: the servo is powered straight from the battery. |
| 4 | GO button | A plain contact between GPIO 4 and GND, nothing else. Fully disconnected from the old 12 V circuit. |
| 5 | KY-040 encoder, CLK | The module’s + goes to 3.3 V, never 5 V. |
| 6 | KY-040 encoder, DT | |
| 7 | KY-040 encoder, SW (click) | Goes low when pressed. |
| 10 | OLED, SDA (I2C) | SSD1306 128×64 screen, address 0x3C (sometimes 0x3D). |
| 20 | OLED, SCL (I2C) | Free to use because the serial port goes through the chip’s native USB. |
Leave these free:
- GPIO 2, 8 and 9 are strapping pins: their level at power-on decides how the chip boots. Pin 8 also drives the board’s LED.
- GPIO 4 to 7 are also used for JTAG debugging. That’s no problem as long as you go through USB (the built-in USB debugging doesn’t use them), but an external JTAG probe would clash with the button and the encoder.
Wiring diagram
Section titled “Wiring diagram”This is a schematic: where a pin sits on the drawing has nothing to do with where it is on the board. Red wires carry the battery voltage (7.4 V, up to 8.4 V when full), the orange wire the converter’s 5 V, and the green flags the 3.3 V from the ESP32’s 3V3 pin. All the ground symbols are connected together.
Part by part
Section titled “Part by part”| Part | Connections |
|---|---|
| 2S LiPo battery | + to the main switch, − to the common ground. |
| Servo | + on the battery after the switch (not on the 5 V), − to ground, signal on GPIO 3. A 470 µF 16 V capacitor between + and ground, as close to the servo as you can, with its + leg on the battery side. |
| 5 V converter (MP1584) | Input on the battery after the switch, 5.0 V output (checked with a multimeter) into the ESP32’s 5V pin, common ground. |
| Battery voltage divider | Battery → 100 kΩ → GPIO 0 → 20 kΩ → ground. A 100 nF capacitor between GPIO 0 and ground. At 8.4 V the pin sees 8.4 × 20 / 120 = 1.40 V. Don’t swap in a 47 kΩ: the pin would see about 2.7 V, too high for the C3’s ADC to measure well. |
| 940 nm IR LED | 3.3 V → 220 Ω → LED anode, cathode to ground. It stays on all the time (about 10 mA). |
| 940 nm phototransistor | Collector on GPIO 1, with a 10 kΩ resistor from GPIO 1 to 3.3 V. Emitter to ground. Facing the LED, across the tube. |
| KY-040 encoder | CLK → GPIO 5, DT → GPIO 6, SW → GPIO 7, + → 3.3 V, GND → ground. |
| SSD1306 OLED screen | SDA → GPIO 10, SCL → GPIO 20, VCC → 3.3 V, GND → ground. |
| GO button | One wire on GPIO 4, the other to ground. No other wire: disconnected from the old 12 V circuit. |
First power-up
Section titled “First power-up”Do these in order, before connecting anything else. Write down every value you measure in the measurements table below.
- Measure (and if it’s adjustable, set) the converter’s output to 5.0 V with a multimeter, ESP32 unplugged. A fixed 5 V version has nothing to set, but measure it anyway. An adjustable one often comes out of the factory at some random voltage, sometimes close to the battery’s, which would kill the ESP32.
- Check the servo’s maximum voltage against the 8.4 V of a full battery. It’s wired straight to the battery, and many “35 kg” servos top out at 6.8 V and die above that. If it’s rated for less than 8.4 V, it needs its own regulator (a BEC or a second converter) that can supply its stall current, which is what it draws when it’s forced to a standstill.
- Check whether there is a diode between USB 5 V and the SuperMini’s 5V pin. Without one, plugging in USB while the battery powers the board puts the converter and your computer’s USB port head to head. Until you’ve checked: never USB with the battery on (switch open, or battery unplugged, when flashing).
- Connect the KY-040’s
+to 3.3 V, never to 5 V. The module has its own pull-up resistors to its+: on 5 V, it would push 5 V into ESP32 pins that only take 3.3 V. - Cut the GO button off from the old 12 V circuit completely. It must only touch GPIO 4 and ground: the slightest bit of 12 V left on that wire fries the pin.
- Put the 470 µF capacitor as close to the servo as you can. When it starts, the servo draws a lot of current all at once; the capacitor keeps the voltage from dropping so far that the ESP32 reboots.
- Put the 100 nF capacitor between GPIO 0 and ground. It smooths the battery reading, which the 100 kΩ resistors make sensitive to noise from the servo.
- Connect all the grounds together. Without a common ground, the servo, button and sensor signals have no reference and the board reads garbage.
- Flash the
simfirmware first and read the serial log, servo unplugged. This firmware fakes the BBs: you check that the board boots and that the screen, encoder, button and battery reading respond, before putting the mechanics at risk.
To flash and read the serial log, see the
firmware README
(pio run -e sim -t upload, then pio device monitor).
Measurements
Section titled “Measurements”| Measurement | Value | Decision or note |
|---|---|---|
| Converter output, no load | to measure | |
| Servo: model | to note | |
| Servo: maximum voltage (datasheet) | to note | Straight on the battery, or a BEC / second converter? |
| Diode between USB 5 V and the SuperMini’s 5V pin | yes / no | Update the USB warning in the README to match. |
| Battery: voltage on the multimeter | to measure | |
Battery: voltage read by the board (? on serial) |
to measure | BATT_CALIBRATION = multimeter ÷ board reading. |
See also
Section titled “See also”- BLE protocol: what the board exchanges with the app.
firmware/src/config.h: the reference for pins and default settings.