Sorry if what I’m asking is already explained in the documentation. I’ve been trying to find responses there but I’m still a bit confused.
I want to use the XBee Cellular 3G Embedded Modem connected to an Arduino board via UART. The idea is to connect to an external MQTT broker and start sending/receiving MQTT packets from the Arduino. Here are my questions:
- Is there any support on the 3G modem for MQTT by means of the provided AT commands?
This library seems to be providing this functionality for the Xbee 3G modem and nowhere is said that new firmware needs to be uploaded to the modem:
https://github.com/vshymanskyy/TinyGSM
- If there is no default support for MQTT, I’ve read somewhere that new Python code needs to be uploaded to the 3G modem. I guess I would be then in this scenario:
https://www.digi.com/resources/documentation/Digidocs/90001541/#tasks/t_use_mqtt.htm%3FTocPath%3DGetting%2520started%2520with%2520the%2520XBee%2520Cellular%2520Modem%2520Development%2520Kit|More%2520examples|Get%2520started%2520with%2520MQTT|_____5
If I understands correctly, I should create a MicroPython code that connects, transmits and receives via MQTT to/from the external MQTT broker and also make this code communicate with the external MCU via UART. Am I right?
Thanks for your time.
In answer to your questions, there aren’t any AT commands for MQTT.
The *0B firmware release supports a file system and modules. You can find sample code at https://github.com/digidotcom/xbee-micropython to communicate with an MQTT broker.
And then you would need to work out a method to communicate between your external MCU and your MicroPython code running on the XBee Cellular device. Note that MicroPython includes support for a secondary UART and it might be easier to use that for controlling the MQTT code in MicroPython (your MicroPython code could watch that for requests, independent of your application sending API frames on the primary serial port).
Thanks @TomCollins for your answer.
I’m not sure to have understood the point about using two UART’s. Why can’t my external MCU simply communicate with the 3G modem via a single UART? (send/receive MQTT frames and control modem)
You can communicate over the single UART. If ATAP=4 you’ll be linked to stdio of the MicroPython REPL. But if you need to communicate with the XBee firmware directly, you’d need to enter command mode (pause, +++, pause) to execute AT commands, and change the ATAP setting if you wanted to use API mode frames, or send “transparent serial” data. The alternate serial port allows for separate command streams – one talking to the XBee firmware in API or transparent mode and the other talking to your MicroPython program.
You could write a detailed MicroPython program to handle all communications, and then work out a protocol for it to communicate with your MCU and always leave the XBee configured in ATAP=4 mode.