I have been trying to publish to MQTT using my Nicla Vision from OpenMV, but I seem to only be able to connect to “test.mosquitto.org” when running the mqtt_pub.py example for the Nicla Vision. I get the traceback exception attached below whenever I try to connect to any other broker. This seems to only be an issue within OpenMV since I can publish to them from my Nicla Vision when using the Arduino IDE. I have tried running OpenMV on three different devices, and get the same error each time.
Traceback (most recent call last):
File "<stdin>", line 28, in <module>
File "mqtt.py", line 134, in connect
sdio_transfer_cmd53: timeout wr=1 len=128 dma=1 buf_idx=0 STA=00000040 SDMMC=00000000:00000c22 IDMA=00000001
[CYW43] send_ethernet failed: -110
bad RESP1: 53 2800
sdio_transfer_cmd53: error=ffffffff wr=0 len=4 dma=0 buf_idx=0 STA=00400000 SDMMC=00000000:00000c60 IDMA=00000001
I would greatly appreciate some help, thank you!
Hi, the example isn’t robust enough for with sockets. You’ll need to update the script.
I went through the RTSP library and improved the code to a point where it’s robust: openmv/scripts/libraries/rtsp.py at master · openmv/openmv · GitHub
You’ll need to modify the MQTT library to use sockets in the same way as the RTSP script: openmv/scripts/libraries/mqtt.py at master · openmv/openmv · GitHub. Then you can replace the file on the OpenMV Cam and it should override the built-in MQTT library.
if hasattr(socket, "SO_REUSEADDR"):
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Needs to be enabled with the cy4343 driver. This wasn’t required for the WINC1500 we use on our other cameras.
Then, you need to use the sendall() method versus send in the library. E.g.
struct.pack(">BBH", 0x24, self.__client_rtp_channel, len(data)) + data
And a large timeout needs to be set:
I don’t have time to fix this issue myself right now. But, if you make a github ticket on it I will update the script. In the mean-time. I can confirm that the wifi comms are rock sloid and do not fall over with the rtsp script which really punishes the driver. So, if you update the socket code in the mqtt library with how I do it in the rstp code it will work without any issues.
Note though, the rtsp code is tcp server. Mqtt is a tcp client. So, you can’t use the code verbatim. But, it’s close.
Thank you for your response! I will try to edit the MQTT program following the RTSP example, and also create a github ticket for it. Thanks again!
Hi, how can you publish on mqtt with Aruduino IDE and Open MV? I’ve tryed so much with Nicla Vision but I can only create the queue and see some messages but nothing been saved on the queue, only with VSC and python I’ve made it.
@arduinoNicla Were you able to get your issue solved? I haven’t had time to robustify that code yet.
I haven’t resolved this issue yet. Although, iabdalkader closed the original github ticket and mentioned that it was a different problem: Arduino Nicla Vision unable to make MQTT connections · Issue #1871 · openmv/openmv · GitHub. Should I put in a new ticket for robustifying mqtt.py?
Sure, that’s fine as just a todo item for me.