wedopython_rpi4
Python library for controlling LEGO® WeDo 2.0 devices using Bluetooth Low Energy (BLE) via gattlib.
This library is optimized for Raspberry Pi 4 running Linux (e.g. Raspberry Pi OS Buster).
Features
- Connect to LEGO WeDo 2.0 Smart Hub
- Control motors (start, stop, power, direction)
- Read distance sensor values
- Read tilt sensor values
- Play internal piezo sound tones
- Monitor battery level
Requirements
- Raspberry Pi 4 with built-in Bluetooth or external BLE dongle
- Linux OS with BLE support (tested on Raspberry Pi OS Buster)
- Python 3.7 or higher
gattlib==0.20210616
Installation
⚠ It is strongly recommended to use a virtual environment for installing this library.
sudo apt update
sudo apt install libbluetooth-dev python3-dev
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# Install gattlib manually (may require build tools)
pip install gattlib==0.20210616
# Then install this library
pip install wedopython_rpi4
Quick Example
from wedo2python.app import WeDo2Python
device = WeDo2Python("04:EE:03:16:ED:1D") # Replace with your WeDo Hub MAC
device.connect()
# Control motor on port B
device.motor_on("B")
device.set_motor_power("B", 70)
# Read tilt sensor on port A
device.tilt_sensor("A")
print("Tilt:", device.read_tilt_value())
# Disconnect
device.disconnect()
Finding the MAC address
Run:
bluetoothctl
scan on
Look for a device named LEGO Hub or similar. The MAC address should look like: 04:EE:03:16:ED:1D
License
This project is licensed under the GNU GPL v2 License.
You are free to use, modify, and distribute it under the terms of the license.
Author
Developed by Evangelia Anastasaki
Email: eveanast@gmail.com
Notes
This library was originally developed for research and educational use.
If you are looking for Raspberry Pi 5 support using bleak, see the companion project: wedo2py-rpi5
Metadata
Release files for wedopython-rpi4 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wedopython_rpi4-1.2.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wedopython_rpi4-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.9 kB
Release files / wedopython_rpi4-1.2.0.tar.gz
| Download URL | wedopython_rpi4-1.2.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59a1320a7b4588001b31cc195fdd63703f13be2fbe0e90f2a97d71d520390cde
|
|
BLAKE2b-256 checksum How to use checksums |
a013d4a3775a5cc7d2b50366abc991accbcfbe27be3624ee0552b9637c739a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2026.
Transparency logRelease files / wedopython_rpi4-1.2.0-py3-none-any.whl
| Download URL | wedopython_rpi4-1.2.0-py3-none-any.whl |
|---|---|
| Size | 3.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b011769255c3b3cebf302750936b8c4d18eb435c39aa73c2ccaba678bc442d9
|
|
BLAKE2b-256 checksum How to use checksums |
f74b5500f1376ceb451761e0a46269d73c778a3cc52033e608faad267fd90f48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2026.
Transparency log