TCP WiFi bidirectional communication issues with Nicla Vision

Hello,

I’m trying to send data from a Nicla Vision to a PC and simultaneously send a few bytes of commands from the PC to the Nicla Vision over WiFi, using OpenMV on the Nicla side. The setup is based on your send_data_via_wifi.py example. On the Nicla, I send ToF distance, IMU data, and images, while the PC sends small command packets.

I’m using a single TCP socket for both directions. In previous tests using the same WiFi example, I could reach ~100 meters. However, with the bidirectional setup, I experience serious stalls or stops in TCP transmission at distances well under 10 meters.

I suspect this may be related to TCP buffering or the way data is chunked and sent, but I’m not sure how to adjust it on the Nicla Vision. Are there known limitations with TCP communication in this kind of bidirectional scenario, or recommended approaches to improve reliability?

Thank you for your help!

Please see this script: openmv/scripts/libraries/rtsp.py at master · openmv/openmv · GitHub - it handles bidirectional comms.

Note that we need to rewrite a lot of these scripts with asyncio: micropython-async/v3/docs/TUTORIAL.md at master · peterhinch/micropython-async · GitHub

If you ask any AI coder, it will help you write asyncio code for micropython that uses tcp sockets correctly.