microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
44 stars 25 forks source link

radio does not work well duplexing #145

Open rhubarbdog opened 1 year ago

rhubarbdog commented 1 year ago

I have client.py on one microbit and server.py on the second. The server counts received packets and replies, 161 packets were dropped out of 2000.

client.py.txt server.py.txt

rhubarbdog commented 1 year ago

i also experience similar with https://github.com/rhubarbdog/microbit-hands-up.

i log pupil.py responses 1 second appart, but when i come to send them out and pupil.py is receiving and teacher.py sending packets are lost

microbit-carlos commented 1 year ago

If you comment out radio.send("Reply" + message) from server.py, do you still lose packets? I'm guessing the issue here is when the server is broadcasting at the same time as the client is broadcasting and that can cause interference, similarly to what is discussed in https://github.com/microbit-foundation/micropython-microbit-v2/issues/144#issuecomment-1359609143

rhubarbdog commented 1 year ago

but in the second example https://github.com/rhubarbdog/microbit-hands-up broadcasts from pupil.py and teacher.py are a second apart

martinwork commented 1 year ago

The server seems to always report "2000 0" for me. I tried with V1->V2, V2->V1 and V2->V2.

If I reduce the sleep in the client to 5ms, I see around 100 messages dropped. Surprisingly, after removing the 10ms sleep from the server, it's OK again. I modified the server to use display rather than print. Here are the Python Editor hex files. clientserver.zip

What could be different about my setup? What version micro:bits are involved and how are they powered? Does it help to set the radio group?

microbit-carlos commented 1 year ago

Yes, using two micro:bit V2 with the code provided on the initial comment (not even commenting out the radio.send() from the server), and I also always get 2000 0 reported by the server, so 0 errors.

@rhubarbdog could you let us know exactly what version of micro:bits were you using for your test, distance between them, power mode (USB, battery?) and an exact copy of the Python code you used?

It's also possible other 2.4GHz signals (WiFi, Bluetooth), in your environment might be interfering. If you think that might also be an issue, you could maybe try to run the same test in area without as many wireless networks around?

rhubarbdog commented 8 months ago

one microbit was on battery, the other on usb power the distance between microbits was less than 1 metre they were version 2 microbits with micropython 2.0.0. beta.5

it's inconvenient to try less wifi and bluetooth. i could switch my wifi off, but i live in a flat and have 5 near neighbors 12 in total. i would have to go to the park with my laptop and microbits and that ain't gonna happen until say april when the weather is better.

martinwork commented 8 months ago

Perhaps try a more recent micropython version? https://github.com/microbit-foundation/micropython-microbit-v2/releases/tag/v2.1.2