
Handlebar Hub revB
SanjayButCodes/Aegis-Smart-Cycle-Lock
A universal-fit, zero-friction smart lock that gives any standard bicycle the premium security and convenience of high-end electric scooters.

A universal-fit, zero-friction smart lock that gives any standard bicycle the premium security and convenience of high-end electric scooters.
Armored rear hub is an open-source printed circuit board by SanjayButCodes, from the SanjayButCodes/Aegis-Smart-Cycle-Lock repository on GitHub. It is a 2-layer board of 60 × 40 mm with 32 parts on 18 nets, routed with 11 tracks and 20 vias.
It is built around the ESP32-WROOM-32U. Its parts include 9 resistors, 8 capacitors, 5 connectors, 4 ICs and 1 transistor. It belongs with the ESP32 boards of this library.
Aegis is a heavy-duty, open-source, distributed smart bicycle lock. Unlike standard commercial locks, Aegis uses a split-node architecture to physically separate the user interface from the vulnerable locking mechanism, making it highly resistant to tampering and brute-force attacks.
🏗️ System Architecture
The system consists of two custom-designed nodes connected by a weather-sealed Cat5e bridge cable:
The Handlebar Hub (User Interface): A compact, IP65-rated pod mounted to the handlebars. It contains an Arduino Nano, an NFC card reader, an RGB status LED, and a locking button. It operates purely on 5V logic.
The Armored Rear Hub (The Brain & Brawn): A heavy-duty horseshoe frame lock mounted over the rear tire. It houses the ESP32 brain, a 12V worm-gear motor, a 3S battery pack, a 110dB siren, and an IMU accelerometer for theft detection.
The "Dead-Man Loop" Tamper Trace
A continuous 3.3V continuity loop originates at the Rear Hub, travels up the Cat5e cable, and traces the exact outer physical perimeter of the Handlebar Hub PCB. If a thief cuts the communication cable or attempts to crack open the Handlebar enclosure, the circuit breaks and the Rear Hub instantly triggers the 110dB siren.
⚡ Hardware Specifications
Armored Rear Hub (Main PCB)
Microcontroller: ESP32-WROOM-32U (Requires external antenna)
Power Supply: 3S (11.1V-12.6V) 18650 Battery Pack
Charging: IP2326 3S Type-C BMS charging IC
Logic Power: MP2315 Buck Converter (Steps 12.6V down to clean 3.3V)
Motor Driver: DRV8871 H-Bridge (Handling up to 2A stall current)
Actuator: JGY370 12V Worm Gear Motor
Sensors: MPU6050 Accelerometer (Wired to ESP32 ext0 wake interrupt)
Audio: 5V Active Piezo Siren
Handlebar Hub (UI PCB)
Microcontroller: Arduino Nano (DIP-30)
Authentication: PN532 NFC/RFID Module (I2C)
User Input: 12mm Waterproof Momentary Push Button
Feedback: Common Cathode RGB LED
Communication: 9600-baud UART over Cat5e Bridge
🛠️ Mechanical & CAD Design
The physical enclosures are designed to be FDM 3D-printed in highly impact-resistant materials like PETG, ABS, or Polycarbonate.
The Deadbolt: The locking mechanism uses a 12mm hardened steel rod acting as a deadbolt.
Rack and Pinion: The JGY370 motor drives a Module 1.5 pinion gear, converting rotational torque into linear motion to slide the deadbolt across the rear tire spokes.
Limit Switches: Two KW12-3 micro limit switches are installed at the ends of the deadbolt track to cut motor power precisely when fully locked or fully unlocked, preventing gear stripping.
Weatherproofing: The enclosures utilize overlapping lap joints designed to hold TPU gaskets or silicone bead seals to protect against rain and tire splash.
💻 Firmware & Software
The codebase is split into two environments:
/firmware/handlebar_nano/: Runs a non-blocking loop polling the PN532 for authorized MIFARE tags. Upon reading a tag or button press, it transmits a clean UART string (e.g., CMD:UNLOCK:UID) down to the rear hub.
/firmware/rear_esp32/: The central state machine. It manages the DRV8871 motor phases, parses UART commands, and handles extreme power conservation.
Deep Sleep Architecture
To allow the lock to run for months on a single charge, the ESP32 enters deep sleep immediately upon locking. It consumes only ~10µA until the MPU6050 accelerometer detects physical tampering, which triggers a hardware interrupt on GPIO 25, waking the ESP32 instantly to sound the alarm.
⚠️ High-Current Safety Warning
This project drives a high-torque 12V motor capable of drawing up to 2 Amps when stalled against a jammed lock.
PCB Routing: The VBAT and MOTOR nets on the Rear Hub PCB must be routed at a minimum of 4.0mm trace width.
Battery: Only use protected 3S battery packs with an integrated BMS. Never run standard 1S cells in series without balancing protection.
🚀 Getting Started
(Instructions for ordering PCBs, flashing code, and assembling the CAD files will be added here as the final manufacturing files are released.)
| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | M3 NPTH | MountingHole:MountingHole_3.2mm_M3 | H1, H2, H3, H4 |
| 1 | 100K IMU PD | Resistor_SMD:R_0805_2012Metric | R6 |
| 1 | 100n 3V3 | Capacitor_SMD:C_0805_2012Metric | C3 |
| 1 | 100n IMU | Capacitor_SMD:C_0805_2012Metric | C5 |
| 1 | 100n USB | Capacitor_SMD:C_0805_2012Metric | C1 |
| 1 | 100n VM | Capacitor_SMD:C_0805_2012Metric | C7 |
| 1 | 10K EN PD | Resistor_SMD:R_0805_2012Metric | R5 |
| 1 | 10K RX DIV | Resistor_SMD:R_0805_2012Metric | R8 |
| 1 | 10u 3V3 | Capacitor_SMD:C_0805_2012Metric | C2 |
| 1 | 1K DEADMAN | Resistor_SMD:R_0805_2012Metric | R9 |
| 1 | 1u IMU | Capacitor_SMD:C_0805_2012Metric | C4 |
| 1 | 1u VM | Capacitor_SMD:C_0805_2012Metric | C6 |
| 1 | 20K RX DIV | Resistor_SMD:R_0805_2012Metric | R7 |
| 1 | 220uF 25V MOTOR BULK | Capacitor_THT:CP_Radial_D8.0mm_P3.50mm | C8 |
| 1 | 3S BMS BATTERY | Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical | J2 |
| 1 | 4K7 SCL | Resistor_SMD:R_0805_2012Metric | R4 |
| 1 | 4K7 SDA | Resistor_SMD:R_0805_2012Metric | R3 |
| 1 | 5K1 CC1 | Resistor_SMD:R_0805_2012Metric | R1 |
| 1 | 5K1 CC2 | Resistor_SMD:R_0805_2012Metric | R2 |
| 1 | 5V ACTIVE BUZZER | Buzzer_Beeper:Buzzer_15x7.5RM7.6 | BZ1 |
| 1 | BUZZER NMOS | Package_TO_SOT_SMD:SOT-23 | Q1 |
| 1 | CAT5e BRIDGE | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-6-5.08_1x06_P5.08mm_Horizontal | J4 |
| 1 | DRV8871 H-BRIDGE | Package_SO:SOIC-8-1EP_3.9x4.9mm_P1.27mm_EP2.29x3mm_ThermalVias | U2 |
| 1 | ESP32-WROOM-32U | RF_Module:ESP32-WROOM-32U | U1 |
| 1 | IP2326 3S CHARGER | Package_DFN_QFN:VQFN-24-1EP_4x4mm_P0.5mm_EP2.5x2.5mm | U4 |
| 1 | JGY370 MOTOR | Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical | J3 |
| 1 | MP2315 3V3 BUCK | Package_TO_SOT_SMD:TSOT-23-8 | U3 |
| 1 | MPU6050 MODULE | Connector_PinSocket_2.54mm:PinSocket_1x08_P2.54mm_Vertical | J5 |
| 1 | USB-C CHARGE INPUT | Connector_USB:USB_C_Receptacle_HRO_TYPE-C-31-M-12 | J1 |

SanjayButCodes/Aegis-Smart-Cycle-Lock
A universal-fit, zero-friction smart lock that gives any standard bicycle the premium security and convenience of high-end electric scooters.

sudomesh/disaster-radio
A (paused) work-in-progress long-range, low-bandwidth wireless disaster recovery mesh network powered by the sun.

freeDSP/freeDSP-aurora
freeDSP ADAU1452 with 8 analog input, 8 analog outputs, S/P-DIF I/O, ADAT I/O, USB Audio Class2, WiFi, Bluetooth

peterkrull/quad
Firmware, hardware and documentation for my autonomous quad copter project



evezor/tobor_v00
Tobor (robot spelled backwards), was built to be the most versatile open-source robotics system

pablozg/freeds
Derivador de energía solar excedente creado por Pablo Zerón, Diseño PCB por Amcalo, Tester original por Aeizoon, Wiki por Zoilo Mora

AlessandroAU/Chorus32-ESP32LapTimer
This is an ESP32 port of the popular Chorus RF Laptimer
It measures 60 × 40 mm and has 2 copper layers, 1.6 mm thick.
32 parts, built around the ESP32-WROOM-32U. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the SanjayButCodes/Aegis-Smart-Cycle-Lock repository on GitHub, at the commit this page was made from: the board is LockWithPCB/Electrical/MainPCB/armored_rear_hub.kicad_pcb and its schematic LockWithPCB/Electrical/MainPCB/armored_rear_hub.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask SanjayButCodes before reusing the design.