pdf-icon

Micropython Guide

ESP-NOW

Use ESP-NOW technology to wirelessly transmit data to other ESP32 master devices.

import espnow

#  Initialization
espnow.init()

#  Set channel

#  Get local mac_addr
espnow.get_mac_addr()

#  Broadcast
espnow.broadcast(data='Hello')

#  Set peer list
espnow.add_peer(slave_mac_addr, id)

#  Send message
espnow.send(id, data='World')

#  Send message callback
def send_cb(flag):
  if flag:
    print('succeed')
  else:
    print('Failed')

espnow.send_cb(send_cb)

#  Receive message callback
def recv_cb():
    #  Get data
    sender_address, _, receive_data = espnow.recv_data(encoder='str')

espnow.recv_cb(recv_cb)
On This Page