
USR-M300Á¬½ÓMQTT·þÎñÆ÷Ï·¢Ö¸Áî¿ØÖÆDOʾÀý
±¸×¢£º±¾°¸ÀýÊÇUSR-M300ÄÚÖÿ¨ÁªÍø£¬Á¬½ÓMQTT·þÎñÆ÷£¬JSONÏ·¢¿ØÖÆDO1ºÍDO2¶Ï¿ªºÍ±ÕºÏ¡£
Ò»¡¢×ÊÁÏÏÂÔØ
USR-M300 ˵Ã÷Ê飺/Download/1332.html
USR-M300 ¹æ¸ñÊ飺/Download/1333.html
USR-M300 Ó¦ÓÃÖ¸µ¼£º/Download/1369.html
¡¾PC¶Ëµ÷ÊÔ¹¤¾ß¡¿ÍøÂçµ÷ÊÔÖúÊÖ ´®¿Úµ÷ÊÔÖúÊÖ¶þºÏÒ»/Download/27.html
MQTTfxÈí¼þ£¬¿ÉÒÔ°Ù¶È×ÔÐÐÏÂÔØ
¶þ¡¢Ó²¼þÁ¬½Ó
1¡¢ËùÐèÎïÆ·
USR-M300 ²úÆ· 1̨
12VµçÔ´ÊÊÅäÆ÷ 1¸ö
USB-RS485´®¿ÚÏß 1Ìõ
³¬ÎåÀàÍøÏß 1¸ù
±Ê¼Ç±¾µçÄÔ 1̨
2¡¢Ó²¼þÁ¬½Ó
USR-M300 ½ÓºÃ4GÌìÏߣ¬µçÔ´¶Ë×Ó½Ó12VµçÔ´ÊÊÅ䣬עÒâÕý¸º¼«²»Òª½Ó·´¡£
USR-M300 µÄ´®¿Ú1µÄ485½ÓUSB-RS485£¬A½ÓA£¬B½ÓB£¬USB¿Ú½ÓµçÄÔUSB¿Ú¡£
USR-M300 µÄLAN¿ÚÍøÏßÖ±Á¬µçÄÔ¡£
½ÓºÃÏßÖ®ºó£¬²úÆ·½Ó12VµçÔ´ÊÊÅäÆ÷Éϵ硣
3¡¢¶Ë¿ÚºÅ
µã»÷µçÄÔ¼ÆËã»ú£¬ÓÒ»÷µã»÷¹ÜÀí£¬µã»÷É豸¹ÜÀíÆ÷£¬µã»÷¶Ë¿Ú£¬È·ÈÏUSB-RS485´®¿ÚÏßµÄCOM¿ÚºÅÊÇCOM10¡£
Èý¡¢²úÆ·²ÎÊýÉèÖÃ
1¡¢µÇ½USR-M300ÍøÒ³
µçÄÔ´ò¿ªä¯ÀÀÆ÷£¬ÊäÈë192.168.1.1£¬µÇ½USR-M300ÄÚÖÃÍøÒ³£¬Óû§ÃûºÍÃÜÂ붼ÊÇadmin¡£
2¡¢Êý¾Ýµãλ£º²é¿´DOµãλÃû
µã¿ªÊý¾Ýµã룬µã»÷´Ó»úÏÂÃæµÄLocal_IO£¬ÔÚ´Ó»ú-µãλÁÐ±í£¬²é¿´DO01µãλÃû³ÆÊÇDO01£¬DO02µãλÃû³ÆÊÇDO02¡£
3¡¢±ßÔµÍø¹Ø£º´®¿Ú¹ÜÀí--´®¿Ú01ÉèÖÃ
´®¿Ú01£¬»ù´¡ÉèÖ㬲¨ÌØÂÊ9600£¬Êý¾Ýλ,8£¬Í£Ö¹Î»1£¬Ð£ÑéλNONE¡£
ʵ¼ÊÓ¦Ó㬴®¿Ú²ÎÊýÐèÒªºÍËù½Ó485É豸µÄ´®¿Ú²ÎÊýÒ»Ö£¬Èç¹ûÐÞ¸ÄUSR-M300´®¿Ú²ÎÊýÖ®ºó£¬µã»÷Ó¦Óá£
4¡¢±ßÔµÍø¹Ø£ºÍ¨ÐÅÁ´Â·--Á´Â·1--MQTT²ÎÊýÉèÖÃ
£¨1£©µã»÷Á´Â·1£¬´ò¿ªÁ´Â·1¿ª¹Ø¡£
£¨2£©»ù´¡ÉèÖÃ
ͨÐÅÐÒ飺MQTT
ÐÒéÑ¡Ôñ£ºMQTT-3.1.1
·þÎñÆ÷µØÖ·£ºÌîUSR-M300 Á¬½ÓµÄMQTT·þÎñÆ÷µØÖ·IP
¿Í»§ID£º×Ô¶¨ÒåÌî1234567890£¬±ÜÃâºÍÆäËûÁ¬½ÓMQTT·þÎñÆ÷µÄ¿Í»§¶ËIDÖظ´³åÍ»¡£
Ô¶³Ì¶Ë¿Ú£ºÌîUSR-M300 Á¬½ÓµÄMQTT·þÎñÆ÷µÄ¶Ë¿Ú
ÆäËû²ÎÊý±£³ÖĬÈÏ¡£
µã»÷Ó¦Óá£
£¨3£©·¢²¼ÉèÖÃ
µã»÷·¢²¼ÉèÖ㬵ã»÷±à¼£¬Ö÷ÌâÃû³ÆÌî/USR-M300/update
QOS£ºÑ¡ÔñQOS0£¬µã»÷È·¶¨£¬µã»÷Ó¦Óá£
£¨4£©¶©ÔÄÉèÖÃ
µã»÷¶©ÔÄÉèÖ㬵ã»÷±à¼£¬Ö÷ÌâÃû³ÆÌî/USR-M300/get
QOS£ºÑ¡ÔñQOS0£¬µã»÷È·¶¨£¬µã»÷Ó¦Óá£
5¡¢ÐÒéת»»ÉèÖÃJson
£¨1£©µã»÷ÐÒéת»»£¬µã»÷Json,¿ªÆôJson
£¨2£©¿ªÆôJsonÖ®ºóµã»÷Ìí¼Ó
£¨3£©Á´Â·Ñ¡ÔñÁ´Â·1£¬·¢²¼Ö÷Ìâ/USR-M300/update£¬¶©ÔÄÖ÷Ìâ/USR-M300/get
6¡¢×îºóÍøÒ³µã»÷ÖØÆô£¬µÈ´ýUSR-M300ÖØÆôÍê³É¡£
ËÄ¡¢MQTTfxÈí¼þÉèÖÃ
1¡¢´ò¿ªMQTTfxÈí¼þ
2¡¢½¨Ò»¸öеÄÅäÖÃÎļþ×öÁíÒ»¸öMQTT¿Í»§¶Ë
£¨1£©ÅäÖÃÎļþÃû×Ô¶¨ÒåÓÃMQTT
£¨2£©·þÎñÆ÷µØÖ·ÌîºÍUSR-M300Á¬½ÓµÄͬһ¸öMQTT·þÎñÆ÷µØÖ·
£¨3£©¶Ë¿ÚÌîMQTT·þÎñÆ÷¶Ë¿Ú1883
£¨4£©Client ID£¨¿Í»§¶ËID£©¿ÉÒÔµã»÷ºóÃæµÄGenerate×Ô¶¯´´½¨£¬×¢ÒâºÍUSR-M300µÄ¿Í»§¶ËID²»ÒªÒ»Ñù£¬Èç¹ûÏàͬ»á³åÍ»¡£
£¨5£©µã»÷User Credentials£¬User NAMEÊäÈëMQTT·þÎñÆ÷µÄÓû§Ãû£¬PasswordÊäÈëMQTT·þÎñÆ÷µÄÃÜÂë¡£
£¨6£©ËùÓвÎÊýÉèÖÃÍê³ÉÖ®ºó£¬µã»÷ApplyÓ¦Óá£
3¡¢MQTT.fxÈí¼þÑ¡Ôñн¨µÄ¿Í»§¶ËMQTT£¬µã»÷ConnectÁ¬½Ó
Îå¡¢MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO
µÇ½USR-M300ÍøÒ³£¬IO¹ÜÀí£¬IO״̬£¬¿ÉÒԲ鿴DO01¡¢DO02µÄ״̬¡£
±¸×¢£º2·DO£¬3 ÏßÖÆ£¬Ä¬Èϳ£±Õµã£¨NC£©±ÕºÏ£¬³£¿ªµã£¨NO£©¶Ï¿ª¡£
1¡¢MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO¶Ï¿ª
£¨1£©MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO1¡¢DO2¶Ï¿ª
MQTTfxÈí¼þ£¬µã»÷Publish£¬ÊäÈëÖ÷Ìâ/USR-M300/get£¬
·¢ËÍÇø°´ÕÕ¸ñʽÊäÈëÏ·¢JSON¸ñʽÃüÁдDO01²ÎÊý1£¬Ð´DO02²ÎÊý1£¬¿ØÖÆDO¶Ï¿ª¡£
{
"rw_prot": {
"Ver": "1.0.1",
"dir": "down",
"id": "12345",
"r_data": [{
"name": "DO01"
},
{
"name": "DO02"
} ] ,
"w_data": [{
"name": "DO01",
"value": "1"
},
{
"name": "DO02",
"value": "1"
} ]
}
}
£¨2£©MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO1¡¢DO2¶Ï¿ª£¬MQTT·þÎñÆ÷ÊÕµ½»Ø¸´
MQTTfxÈí¼þ£¬µã»÷Subscribe£¬ÊäÈëÖ÷Ìâ/USR-M300/update£¬µã»÷Ö÷ÌâºóÃæµÄSubscribe½ÓÊջظ´Êý¾Ý¡£
»Ø¸´JSON¸ñʽÄÚÈÝ£º
{
"rw_prot": {
"dir": "up",
"Ver": "1.0.1",
"id": "12345",
"w_data": [{
"name": "DO01",
"value": "1",
"err": "0"
}, {
"name": "DO02",
"value": "1",
"err": "0"
}],
"r_data": [{
"name": "DO01",
"value": "1",
"err": "0"
}, {
"name": "DO02",
"value": "1",
"err": "0"
}]
}
}
2¡¢MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO±ÕºÏ
£¨1£©MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO1¡¢DO2±ÕºÏ
MQTTfxÈí¼þ£¬µã»÷Publish£¬ÊäÈëÖ÷Ìâ/USR-M300/get£¬
·¢ËÍÇø°´ÕÕ¸ñʽÊäÈëÏ·¢JSON¸ñʽÃüÁдDO01²ÎÊý0£¬Ð´DO02²ÎÊý0£¬¿ØÖÆDO±ÕºÏ¡£
{
"rw_prot": {
"Ver": "1.0.1",
"dir": "down",
"id": "12345",
"r_data": [{
"name": "DO01"
},
{
"name": "DO02"
} ] ,
"w_data": [{
"name": "DO01",
"value": "0"
},
{
"name": "DO02",
"value": "0"
} ]
}
}
£¨2£©MQTT·þÎñÆ÷JSONÏ·¢¿ØÖÆDO1¡¢DO2±ÕºÏ£¬MQTT·þÎñÆ÷ÊÕµ½»Ø¸´
MQTTfxÈí¼þ£¬µã»÷Subscribe£¬ÊäÈëÖ÷Ìâ/USR-M300/update£¬µã»÷Ö÷ÌâºóÃæµÄSubscribe½ÓÊջظ´Êý¾Ý¡£
»Ø¸´JSON¸ñʽÄÚÈÝ£º
{
"rw_prot": {
"dir": "up",
"Ver": "1.0.1",
"id": "12345",
"w_data": [{
"name": "DO01",
"value": "0",
"err": "0"
}, {
"name": "DO02",
"value": "0",
"err": "0"
}],
"r_data": [{
"name": "DO01",
"value": "0",
"err": "0"
}, {
"name": "DO02",
"value": "0",
"err": "0"
}]
}
}
±àдÈË£º½ðÖ¾·½ ±àдÈÕÆÚ£º2024-07-17
ÉóºËÈË£º½ðÖ¾·½ ÉóºËÈÕÆÚ£º2024-07-17
¶©Õý°æ±¾£ºV1.0 ¶©ÕýÄÚÈÝ£º³õ¸å