Home/Support/Support Forum/Xbee 3G modem via MQTT from external MCU

Xbee 3G modem via MQTT from external MCU

0 votes
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:

1. 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:


2. 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:


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.
asked Aug 7, 2018 in XBee Cellular by dberenguer New to the Community (1 point)

Please log in or register to answer this question.

2 Answers

0 votes
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).
answered Aug 8, 2018 by TomCollins Veteran of the Digi Community (2,229 points)
0 votes
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)
answered Aug 9, 2018 by dberenguer New to the Community (1 point)
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.