ESP-Now support for ESP32 (and ESP8266)

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
davef
Posts: 134
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Fri Jan 08, 2021 6:56 pm

Following on from your example if I then try to bring up the network interface:

Code: Select all

>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
True
>>> sta_if.ifconfig(('192.168.10.99', '255.255.255.0', '192.168.10.1', '8.8.8.8'))
>>> sta_if.isconnected()
False
>>> 
I will now check the official image.

User avatar
Roberthh
Posts: 2276
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: ESP-Now support for ESP32 (and ESP8266)

Post by Roberthh » Fri Jan 08, 2021 8:16 pm

I do not see a call to sta_if.connect(). Without that, the module will not connect,

davef
Posts: 134
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Fri Jan 08, 2021 8:29 pm

Ah, let me focus a bit harder!

Sorry, my previous post was incorrect ... it did not reflect that I was actually doing a re-connect in the code I was testing. I have gone through the process as Peter suggested, line by line, and the re-connection works.

Also, my program now works at home-base, maybe because it is a different wireless router. I will re-check at the remote location.

Thank you for the support guys.

Dave

davef
Posts: 134
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Sat Jan 16, 2021 7:28 pm

As I get the odd init() and add_peer() errors I thought I would
put in some error-trapping, but it looks like the error test is not
even being run.

For example:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "local.py", line 21, in <module>
AttributeError: 'function' object has no attribute 'init'

Code: Select all

retval = e.init() # line 21
if (retval != None):
    print('init() did NOT work')
    machine.reset()

Any suggestions?

Post Reply