|
Try the below script in the AT Command Tester tool
//Script: at+smsub //The AT commands in this script are applicable for Simcom modules only //Check SIMCOM Module AT Command documentaiton //Get the support for AT+SMPUB command AT+SMSUB=? //Wait WAIT=1 //Activate the application network AT+CNACT=0,1 //Wait WAIT=1 //Set up the MQTT URL AT+SMCONF="URL","test.mosquitto.org","1883" //Wait WAIT=1 //Set up the MQTT time to connect server AT+SMCONF="KEEPTIME",60 //Wait WAIT=1 //Connect to the MQTT server AT+SMCONN //Wait WAIT=4 //Subcribe to a topic on the MQTT server AT+SMSUB="my_topic",1 //Publish to the MQTT server //Content length is 5, QoS is 1, server hold is 1 AT+SMPUB="my_topic",5,1,1 //Wait for the > prompt WAIT=1 //Send the message Hello
Output of the above script in the AT Command Tester tool
AT+SMSUB=? +SMSUB: 128,(0-2) OK AT+CNACT=0,1 OK +APP PDP: 0,ACTIVE AT+SMCONF="URL","test.mosquitto.org","1883" OK AT+SMCONF="KEEPTIME",60 OK AT+SMCONN OK AT+SMSUB="my_topic",1 OK AT+SMPUB="my_topic",5,1,1 > Hello +SMSUB: "my_topic","Hello" OK