https://github.com/cnadler86/mp_espnow_wrapper
Send and receive data between ESPs over espnow without worries
https://github.com/cnadler86/mp_espnow_wrapper
espnow micropython
Last synced: 9 days ago
JSON representation
Send and receive data between ESPs over espnow without worries
- Host: GitHub
- URL: https://github.com/cnadler86/mp_espnow_wrapper
- Owner: cnadler86
- Created: 2025-02-12T04:49:32.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2025-02-22T05:48:50.000Z (about 2 months ago)
- Last Synced: 2025-02-22T06:24:31.195Z (about 2 months ago)
- Topics: espnow, micropython
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-micropython - mp_espnow_wrapper - Send and receive data between ESPs over ESP-NOW without worries. (Libraries / Communications)
README
# Micropython espnow wrapper
Send and receive data between ESPs over espnow without worries. This library provides asynchronous message sending and receiving with support for chunked data transmission and acknowledgments.## Features
- Asynchronous ESP-NOW message handling
- Automatic chunking of large messages
- CRC32 verification for data integrity
- Optional acknowledgment (ACK) support
- Configurable timeout and cycle time
- Debugging mode for easier troubleshooting## Usage
### Initializing the ESPNowManager
```python
from mp_espnow_wrapper import ESPNowManageresp_manager = ESPNowManager(peer='AA:BB:CC:DD:EE:FF', debug=True)
esp_manager.set_callback('on_receive', lambda msg: print("Received:", msg))
esp_manager.init()
```### Sending Messages
```python
import asyncioasync def send():
message = b'Hello ESP-NOW!'
await esp_manager.send(message)asyncio.run(send())
```### Receiving Messages
The `init` method starts the message receiving process automatically.
Register a receive-callback by `set_callback('on_receive',)`. The callback needs to accept only one argument, namely the message## Configuration
- `peer`: MAC address of the target device (default: broadcast)
- `rxbuf`: Buffer size for incoming messages
- `timeout_ms`: Message receive timeout in ms
- `cycle_time_ms`: Interval between message chunks (ms). In order to run stables needs to be > 2-3 ms
- `wait_msg_ack`: Whether to wait for message acknowledgment. This includes the respective on_receive callback at the receiver.
- `send_ack_afetr_cb`: Whether to send ACK after the callback execution.
- `send_async`: Whether to send messages asynchronously.
- `debug`: Enables debug output