This post is intended to help readers to use the SIM7600 4G GSM Modem with the Arduino for sending and receiving messages using MQTT protocol. The MQTT protocol facilitates easy deployment of internet-connected devices and makes the data flow of the Internet Of Things, simple and hassle-free.
SIM7600 MQTT AT Commands
The SIM7600 GSM Modem is having MQTT stack builtin. This enables us to use simple AT commands to connect to an MQTT broker and publish messages. The MQTT topics can also be subscribed for receiving messages from other MQTT client. See the following table showing usage of various MQTT related AT commands.
For more information, consult the MQTT application document.
Download link: https://www.elementzonline.com/downloads/SIM7600/SIM7500_SIM7600%20Series_MQTT_ATC_V1.01.pdf
AT command manual:
Components Required
- Arduino Uno
- SIM7600 GSM Modem with TTL interface
- SIM with 4G/3G/2G internet connectivity
- LED
- Resistor
- BreadBoard
- Switch
Connection Diagram
The SIM7600 RX-TX pins cannot be directly connected to Arduino Uno, as these pins are only 1.8Volt tolerant. You need to use a level shifter for this purpose. The board in the following link already have the level shifters on board, so that you can start using the AT command port straightaway.
https://www.elementzonline.com/sim7600e-4g-gsm-ttl-usb-modem-with-sma-antenna
If you don’t have a board with the level shifter, the following circuitry can be used for interfacing GSM RX-TX pins with Arduino Uno.
Sample Code
How to run the code
- Download the code from here
- Open Arduino IDE and copy-paste the below code
- Select board and port to upload the code
Code explanation
LED connected to Digital Output pin D7 can be controlled using switch which is connected to PIN 5 and through MQTT subscription at the same time.
In the setup loop, the required topic is subscribed after connecting to the MQTT server.
When a switch press is detected, the LED status is toggled. Also, the LED status is published to the publish topic.
Also when a data is sent to the subscribed topic by another client, the data is received and the LED logic is changed according to the message received. In the code, when the message “a” is received, LED will be turned on and when the message “b” is received, LED is turned off.
Purchase link: https://www.elementzonline.com/sim7600e-4g-gsm-ttl-usb-modem-with-sma-antenna
Video Demo: https://www.youtube.com/watch?v=v42pwvVjII4