ChuckMash / ESPythoNOW

A python library for sending, receiving, and monitoring ESP-NOW messages
MIT License
42 stars 6 forks source link

ESPythoNOW

Linux/Python ESP-NOW library.


Prep the interface and set channel

sudo bash prep.sh wlp1s0 8

Send and Recieve ESP-NOW messages

from ESPythoNOW import *
import time

def callback(from_mac, to_mac, msg):
  print("ESP-NOW message from %s to %s: %s" % (from_mac, to_mac, msg))

espnow = ESPythoNow(interface="wlp1s0", callback=callback)
espnow.start()

while True:
  msg=b'\x01'
  espnow.send("FF:FF:FF:FF:FF:FF", msg)
  time.sleep(3)

Monitor/Sniff all ESP-NOW Traffic

from ESPythoNOW import *

def callback(from_mac, to_mac, msg):
  print("ESP-NOW message from %s to %s: %s" % (from_mac, to_mac, msg))

espnow = ESPythoNow(interface="wlp1s0", accept_all=True, callback=callback)
espnow.start()
input() # Run until enter is pressed

Receive encrypted ESP-NOW messages

espnow = ESPythoNow(interface="wlp1s0", callback=callback, pmk="0u4hgz7pgct3gnv8", lmk="a3o4csuv2bpvr0wu")

Note: Sending encrypted ESP-NOW messages is not currently supported.


Assorted Details


NOTE about current state, subject to change or improvements