Replies: 14 comments 33 replies
-
I also tried implementing the ESPNow and Wifi Operation section of the support for the ESP-NOW wireless protocol(https://micropython-glenn20.readthedocs.io/en/latest/library/espnow.html#espnow-and-wifi-operation) from @glenn20. Master board:
WifiNode.py
EspNowNode.py
Client board:
When I implemented that part on the docu I mentioned above Esp-Now completely stopped working. I am able to use WiFi to perform get request and I succesfuly get the response. I see the send request over Esp-Now on master, but I do not recieve the comand over on the client side. Can maybe someone spor the problem. For the reference I am using 2x ESP32 DevKit V1 boards. I must also say that I am not very experienced in microcontrollers. I have worked on this boards for the past half a year as hoby. Started with C++ and moved to micropython month ago. I am mechanical engeneer by degree and have intermediate knowlege of python, but am self tought. So the code maybe looks a bit ugly and not realy structured how it should be. |
Beta Was this translation helpful? Give feedback.
-
On the master, what does If it prints A few things to check/double-check:
A few other tips that I don't believe are related to the probelem, but are good practice:
|
Beta Was this translation helpful? Give feedback.
-
When I use wifi.py with the standard ESP32 images I have to comment-out these lines: def connect(*args, **kwargs):
sta.active(True)
disconnect()
sta.connect(*args, **kwargs)
wait_for(lambda: sta.isconnected())
# ssid, chan = sta.config("essid"), channel()
# print('Connected to "{}" on wifi channel {}'.format(ssid, chan)) because of that same message. And only put in the following : timeout = 20 # seconds
class TimeoutError(Exception):
pass
def wifi_reset()
def disconnect()
def connect()
def wait_for() |
Beta Was this translation helpful? Give feedback.
-
I've made a few updates to my utilities at micropython-espnow-utils to fix some issues due to some changes to the api as espnow has been merged into the main branch. As a diagnostic, try adding the following to your client board code (eg. at end of the code or in main()): import espnow_scan
espnow_scan.scan(peer) That will scan for the master board and set the device to operate on the correct channel. You can get espnow_scan.py at: https://github.com/glenn20/micropython-espnow-utils/blob/main/src/espnow_scan.py. |
Beta Was this translation helpful? Give feedback.
-
When I want to assign a static IP on the ESPNow devices I have been adding sta.ifconfig(()) as below: # set up the WiFi interface
sta, ap = wifi.reset()
sta.ifconfig((config.WiFi_device, '255.255.255.0', config.gateway, '8.8.8.8'))
wifi.status() # print details to confirm settings
wifi.connect(config.hotspot, config.password) I think you said this was the right place to do this in your wifi.py. Still OK? Thanks, |
Beta Was this translation helpful? Give feedback.
-
When using lightsleep one has to follow a disconnect() with a sta.active(False). On my non-ESPNow systems I have always followed a disconnect with same statement. Are there situations where one would disconnect() and not do a sta.active(False)? |
Beta Was this translation helpful? Give feedback.
-
Based on this discussion and some of the ideas given to me I have come to the solution that is working for me on my 3 ESP32 boards (Master + 2 x Clients). So for anyone starting with this problem it will be easier to get to the final result faster and maybe easier. Example is based on the wifi.py and espnow_scan.py (link) from @glenn20. Codebase is divided in to master and client part. I also divided the code to multiple files for easier possibility to expand the project. Master
espnow_node.py
wifi_node.py
Client
espnow_node.py
wifi_node.py
If the libraries get updated in the future Iam adding the codebase from this date so that the example will be relavant in the future as a good starting point. @glenn20 fell free to add any comments. Thank you once more! |
Beta Was this translation helpful? Give feedback.
-
sir how to do the reverse process in esp8266 where the master is the receiver and the client is the sender @glenn20 |
Beta Was this translation helpful? Give feedback.
-
this is the sender side code which works well for now @glenn20
and the saved files in the memory are esp_node.py, wifi.py , wifi_node.py
|
Beta Was this translation helpful? Give feedback.
-
where as on the master side which requires a different set of esp8266 codes @glenn20
espnow_node.py
this is the main code and it returns
|
Beta Was this translation helpful? Give feedback.
-
SIR @glenn20 I HAVE corrected the esp_node.py
and this my code main.py
now i am getting this error what should i to do to fix it
|
Beta Was this translation helpful? Give feedback.
-
i have sussfully received the message but the output does not loop @glenn20 |
Beta Was this translation helpful? Give feedback.
-
no its says false continously and on the server side this is the output @glenn20
|
Beta Was this translation helpful? Give feedback.
-
SIR @glenn20 here is the issue when i stop the program and run it again , at that exact moment the client returns true and master displays the output then onwartds the client side returns false and the master side gives a dead output
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem with using esp-now and WiFi together. I am able to use them both separately with success. If I enable only one of those two protocols everything works fine. I have no problem sending and receiving esp-now measages between boards and on the other hand I can execute Wi-Fi get requests succesfuly. The moment I turn them both on esp-now part is failing. I have tried researching this toppic but I am unable to understand what is wrong.
I started here
https://forum.micropython.org/viewtopic.php?t=11420
but I am unable to understand what I have to do.
I will post the code if anyone will get a sense what is the problem.
main.py
EspNowNode.py
WifiNode.py
I would really apreciate any help what I have to change in order to make it work.
Beta Was this translation helpful? Give feedback.
All reactions