Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5294

MicroPython • Re: Convert WiFi codebase from CircuitPython - mDNS issue

$
0
0
ESP-NOW looks way easier...
Possibly. I am not familiar with ESP-NOW but it appears to work by sending raw packets over the wireless link formatted such that compatible devices can send and receive those, understand what is received. And everything is simple if you just have 'Send(msg)" and "msg = Receive()" functions provided by a library.

I believe ESP-NOW is similar to what the BBC micro:bit used for peer-to-peer communications, and similar to ZigBee.

That cuts down on complexity in not needing a network stack, but doesn't provide the flexibility of having a network stack, and that stack is not a great overhead on things like an RP2040 which can support that.

I believe UDP packets serve just as well as raw data packets and TCP is even better. The only thing ESP-NOW seems to offer is a simple API. Something similar can be created for the Pico W. I have proof of concept for that -

Code:

import netzerobutton = Pin(0, Pin.IN, Pin.PULL_DOWN)while True:  if button.value() == 1:    Send("Led", "Toggle")

Code:

import netzeroled = Pin("LED", Pin.OUT)while True:  if Receive("Led") == "Toggle":    led.toggle()
The "Led" server declares itself and waits for a message to be received simply by using 'Receive'. The 'Send' will determine the IP Address of the "Led" server and then send the message. Yes, there should be some button debouncing and it should only send on rising edge, new button push, but otherwise as simple as above.

Everything is handled under the hood; network connection, then naming, advertising, discovery, send and receive, using just UDP. It is a 'trimmed down to the ground' MQTT, with no mDNS, SSDP, etc, required. It is in fact a reinvention of all that, but worth it to simplify the API and not have it dependent on anything else other than the network stack. It's "ZeroConf" to the extreme.

That should be just as easy to use as ESP-NOW, it may even be easier. It was intended to be as simple as possible for the user to use.

Statistics: Posted by hippy — Sat May 11, 2024 10:32 am



Viewing all articles
Browse latest Browse all 5294

Trending Articles