|
Try the below script in the AT Command Tester tool
//Script: at+smpub //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+SMPUB=? //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 //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+SMPUB=? +SMPUB: 128,(0-512),(0-2),(0-1) 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+SMPUB="my_topic",5,1,1 > Hello OK