Smart Home Automation Forum

Full Version: Lesson36- remote control relay by KC868-A8S 4G module via MQTT AT command
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MQTT AT command debug for KC868-A8S:

publish message to MQTT broker:

1. AT+CMQTTSTART
2. AT+CMQTTACCQ=0,"KinCony1"
3. AT+CMQTTCONNECT=0,"tcp://iot.kincony.com:1883",120,1,"mqtt","123"
4. AT+CMQTTTOPIC=0,18
5. > relay8/12345/state
6. AT+CMQTTPAYLOAD=0,19
7. > {"relay1":{"on":1}}
8. AT+CMQTTPUB=0,1,60

this is puslish a message for update MQTT broker relay state when relay1 is ON

subscribe topic from MQTT broker:

AT+CMQTTSUB=0,16,1,1
relay8/12345/set

will receive example message:

+CMQTTRXSTART: 0,16,3
+CMQTTRXTOPIC: 0,16
relay8/12345/set
+CMQTTRXPAYLOAD: 0,3
abc
+CMQTTRXEND: 0

this is demo for receive message: abc

+CMQTTRXSTART: 0,16,19
+CMQTTRXTOPIC: 0,16
relay8/12345/set
+CMQTTRXPAYLOAD: 0,19
{"relay1":{"on":0}}
+CMQTTRXEND: 0

this is demo for receive message: {"relay1":{"on":0}}


here is arduino IDE source code: [attachment=1084]
[attachment=1085]