PyBLE: A Bluetooth LE MicroPython IDE for ESP32
PyBLE is an open-source IDE for MicroPython that communicates over Bluetooth LE. It runs on tablets and iPads, with no wires and no cloud. The user writes code, runs it, and sees the console directly on the touchscreen. The project is designed for low-cost boards such as the ESP32-C3 and ESP32-S3. The project specification describes a protocol called PBLE/1, designed to be lightweight and reliable.
The Bluetooth LE MicroPython IDE is not a simple app. It includes a GATT service with base UUID 7079626c, which in ASCII means pybl. The characteristics are RX, TX, and INFO. The client sends commands, and the device responds. The connection uses a standard procedure, so it works with any modern tablet.
The PBLE/1 protocol in detail
Communication uses structured frames. Each frame has a header with version, type, opcode, ID, and length. Then comes the payload and finally a CRC32 to check integrity. The MTU is 247 bytes. The maximum payload per packet is MTU minus 3 bytes of ATT header, minus 1 byte of fragmentation. That leaves 243 usable bytes per packet.
Messages larger than the MTU are fragmented. A fragmentation header tells the receiver how to reassemble the message. In addition, the protocol supports resuming interrupted transfers. File transfer uses dedicated opcodes such as FILE_LIST, FILE_STAT, FILE_GET, and FILE_PUT. Each file is verified with CRC32. If something goes wrong, the transfer resumes from where it stopped.
After connection, the client sends HELLO. The device responds with DEVICE_INFO. This negotiates version and capabilities. The protocol version is 0x01. IDs range from 1 to 255. The length is a uint16 little-endian, so up to 65535 bytes. The CRC32 is the standard IEEE one.
Running code and managing the console
Code execution uses the RUN opcode. You can send a file or inline source code. To stop everything, there is STOP. To reset the MicroPython virtual machine, there is SOFT_REBOOT. The console is managed with CONSOLE_DATA and CONSOLE_INPUT. In practice, the Bluetooth LE MicroPython IDE becomes a full terminal.
Security is not left to chance. The protocol provides basic pairing and encryption. Only one writer is active at a time. Furthermore, there is no telemetry or collection of personal data. The protocol is clean and minimal, suitable for devices with limited resources.
- MTU 247, payload 243 bytes per packet
- Base UUID 7079626c, ASCII encoding pybl
- IDs from 1 to 255, LEN uint16 little-endian
- CRC32 IEEE for every frame
- Label max 24 bytes UTF-8
- IDENTIFY blink at 5 Hz, default duration 2 seconds
Why PyBLE matters to makers
PyBLE is designed for constrained targets like the ESP32-C3. The protocol is small enough to run without issues. It is also versioned and has capability negotiation. This means it can evolve in the future without breaking compatibility. For makers, it is a new way of working, without USB cables and without a PC.
To try PyBLE, you need suitable boards. For example, the ESP32-C6-Zero IoT Development Kit is a compact and modern choice. Alternatively, the Arduino NANO ESP32 with Wi-Fi and Bluetooth offers a classic form factor. The ESP32 Development Board with Wi-Fi, Bluetooth, and USB Type-C connector also works well. All of them support MicroPython and have the necessary Bluetooth LE.
The project is still young, but the direction is clear. A Bluetooth LE MicroPython IDE opens up interesting scenarios. You can program a board mounted on a robot without disassembling anything. You can update firmware from an iPad in the lab. Finally, you can teach MicroPython in the classroom, with inexpensive tablets instead of PCs.
Source: https://github.com/PyBLE-dev/PyBLE/blob/main/docs/specifications/protocol.md