Hubs
Hub — board-level peripherals (status LED, user button) for each supported MCU devkit.
Concrete hubs:
ESP32DevkitHub— ESP32 DevKitC-V4: blue LED on GPIO 2.ESP32S3DevkitHub— ESP32-S3 DevKitC-1: onboard WS2812 RGB LED on GPIO 48.
Both hubs expect two momentary pushbuttons, each wired between a GPIO and GND:
bluetooth_button_pin(default GPIO 5) — short-press toggles BLE on/off. Watched byopenbricks.bluetooth_button.BluetoothToggleButtonwhich the hub auto-wires whenbluetooth=True(the default).The program button (default GPIO 4) — short-press starts or stops
/program.py. Watched byopenbricks.launcherdirectly, which the frozen defaultmain.pystarts vialauncher.run().
Two pins → no duration-based dispatch. Each button does one thing on every short press.
We deliberately avoid GPIO 0 (BOOT) for either role: holding it during reset puts the ESP32 into the ROM bootloader, so sharing that pin with an application button would turn an accidental power-glitch into a flash-mode drop.
Both hubs auto-wire the BLE toggle button by default (bluetooth=True):
constructing a hub restores the persisted BLE state, installs a
short-press handler on the bluetooth_button_pin, and — on the S3 —
paints the WS2812 blue (BLE on) or yellow (BLE off). Put
hub = ESP32S3DevkitHub() in your main.py to turn that on;
omit the call (or pass bluetooth=False) to keep the button free
for your own use.
External I2C components like SSD1306 OLEDs are not part of the hub
— they’re wired to any I2C bus the user chooses, instantiated directly
from openbricks.drivers.ssd1306 or similar, and used alongside the
hub rather than through it.
- class openbricks.hub.StatusLED[source]
Bases:
objectA user-visible status LED on the hub.
Plain single-colour LEDs implement
on/off. Addressable RGB LEDs (WS2812 and friends) additionally implementrgb.
- class openbricks.hub.Hub[source]
Bases:
objectBoard-level peripherals baked into a specific MCU devkit.
- led = None
- bluetooth_button = None
- class openbricks.hub.SimpleLED(pin, active_high=True)[source]
Bases:
StatusLEDSingle-colour LED driven by one digital pin.
- class openbricks.hub.NeoPixelLED(pin, brightness=0.2)[source]
Bases:
StatusLEDSingle-pixel WS2812 / NeoPixel driver — the onboard LED on ESP32-S3 DevKitC-1 and most modern ESP32-S3 compact boards.
Unlike
SimpleLEDthis one implementsrgb(r, g, b)too, which is what the Bluetooth-toggle button uses for blue / yellow feedback.brightnessscales every channel on write (0.0 – 1.0). 0.2 is a comfortable indoor default — the raw WS2812 at full brightness is dazzling.
- class openbricks.hub.PushButton(pin, active_low=True)[source]
Bases:
ButtonDigital pushbutton with configurable active level and internal pull.
- class openbricks.hub.ESP32DevkitHub(led_pin=2, bluetooth_button_pin=5, bluetooth=True)[source]
Bases:
HubESP32 DevKitC-V4 onboard hub: blue LED on GPIO 2, BLE-toggle button on GPIO 5.
bluetoothdefault True wires the button to a long-press BLE toggle and restores the persisted state at boot (seeopenbricks.bluetooth_button/openbricks.bluetooth). The onboard LED is single-colour so no colour feedback, just the toggle. Passbluetooth=Falseto skip the wiring entirely, orbluetooth_button_pin=<N>to use a different GPIO. Wire the button between the chosen GPIO and GND; an internal pull-up is enabled.
- class openbricks.hub.ESP32S3DevkitHub(led_pin=48, bluetooth_button_pin=5, brightness=0.2, bluetooth=True)[source]
Bases:
HubESP32-S3 DevKitC-1 onboard hub: WS2812 RGB LED on GPIO 48, BLE-toggle button on GPIO 5.
led_pindefaults to 48 (the DevKitC-1 onboard WS2812). Passled_pin=Noneto disable the LED entirely, or any other GPIO for a WS2812 wired elsewhere.brightness(0.0 – 1.0) scales channel values on write; default 0.2 is comfortable indoors.bluetooth_button_pindefaults to 5 — a safe, free pin on the DevKitC-1. Wire a momentary switch between GPIO 5 and GND; the pin is configuredPin.INwithPULL_UPso no external resistor is needed. Override viabluetooth_button_pin=<N>.