Ö§³ÖÖÐÐÄ
USR-M300 Íø¿Ú½ÓMODBUS TCPÁ¬½ÓMQTT·þÎñÆ÷JsonÏ·¢Ê¾Àý
2024-08-02



USR-M300 Íø¿Ú½ÓMODBUS TCPÁ¬½ÓMQTT·þÎñÆ÷JsonÏ·¢Ê¾Àý

±¸×¢£º±¾°¸ÀýÊÇUSR-M300ÁªÍø£¬ºÍMQTT·þÎñÆ÷½¨Á¢Á¬½Ó£¬USR-M300µÄÍø¿ÚLAN¿Ú½ÓÍø¿Ú MODBUS TCP´Ó»ú£¬MQTT·þÎñÆ÷JSONÏ·¢Ð´´Ó»ú¼Ä´æÆ÷µØÖ·Êý¾Ý¡£°¸ÀýÓÃÁíÒ»¸öMQTTfxÈí¼þ×öMQTT¿Í»§¶ËÏ·¢JSONÃüÁîȥд¼Ä´æÆ÷Êý¾Ý¡£

Ò»¡¢×ÊÁÏÏÂÔØ

USR-M300 ˵Ã÷Ê飺/Download/1332.html

USR-M300 ¹æ¸ñÊ飺/Download/1333.html

USR-M300 Ó¦ÓÃÖ¸µ¼£º/Download/1369.html

¡¾PC¶Ëµ÷ÊÔ¹¤¾ß¡¿ÍøÂçµ÷ÊÔÖúÊÖ ´®¿Úµ÷ÊÔÖúÊÖ¶þºÏÒ»/Download/27.html

MODBUS SLAVEÈí¼þ¿ÉÒÔ×Ô¼º°Ù¶ÈÏÂÔØ¡£

MQTTfxÈí¼þ¿ÉÒÔ×Ô¼º°Ù¶ÈÏÂÔØ¡£

¶þ¡¢Ó²¼þÁ¬½Ó

1¡¢ËùÐèÎïÆ·

USR-M300 ²úÆ· 1̨

12VµçÔ´ÊÊÅäÆ÷ 1¸ö

³¬ÎåÀàÍøÏß 2¸ù

±Ê¼Ç±¾µçÄÔ 1̨

2¡¢Ó²¼þÁ¬½Ó

USR-M300 ½ÓºÃ4GÌìÏߣ¬¿ÉÒÔÄÚÖÿ¨ÉÏÍø£¬Ò²¿ÉÒÔ²åÍâÖÃSIM¿¨ÉÏÍø£¬Ò²¿ÉÒÔWAN¿ÚÓÃÍøÏß½ÓÉϼ¶Â·ÓÉÆ÷ÉÏÍø¡£

USR-M300 µÄLAN¿ÚÓÃÍøÏߺ͵çÄÔÖ±Á¬¡£

µçÔ´¶Ë×Ó½Ó12VµçÔ´ÊÊÅ䣬עÒâÕý¸º¼«²»Òª½Ó·´¡£

µçÄÔÏÂÔØ°²×°MODBUS SLAVEÈí¼þÄ£ÄâUSR-M300 LAN¿Ú½ÓµÄMODBUS TCP´Ó»úÉ豸¡£

3¡¢²é¿´µçÄÔ»ñÈ¡µÄIP

´ò¿ª¿ØÖÆÃæ°å£¬´ò¿ªÍøÂçºÍInternet£¬´ò¿ªÍøÂçÁ¬½Ó£¬²é¿´±¾µØÓÐÏßÍø¿¨×´Ì¬£¬ÏêϸÐÅÏ¢¡£±¾°¸Àý£¬µçÄÔ´ÓUSR-M300»ñÈ¡µÄIPÊÇ192.168.1.11£¬µçÄÔÄ£ÄâÍø¿ÚMODBUS TCPÉ豸µÄIPÒ²¾ÍÊÇ192.168.1.11¡£

Èý¡¢²úÆ·²ÎÊýÉèÖÃ

1¡¢µÇ½USR-M300ÍøÒ³

µçÄÔ´ò¿ªä¯ÀÀÆ÷£¬ÊäÈë192.168.1.1£¬µÇ½USR-M300ÄÚÖÃÍøÒ³£¬Óû§ÃûºÍÃÜÂ붼ÊÇadmin¡£

2¡¢Êý¾Ýµãλ£ºÌí¼Ó´Ó»úºÍµãλ

£¨1£©µã¿ªÊý¾Ýµã룬ÔÚ´Ó»úÒ»À¸£¬µã»÷Ìí¼Ó¡£

£¨2£©´Ó»úÃû³Æ£ºdevice1£¬²É¼¯Ð­Ò飺Modbus TCP£¬IPÌîLAN¿Ú½ÓµÄÍø¿ÚMODBUS TCP´Ó»úIP£º192.168.1.11£¬¶Ë¿ÚºÅÌî102£¬´Ó»úµØÖ·1£¬µã»÷È·¶¨£¬µÈÉèÖÃÍêËùÓвÎÊý£¬×îºóÍøÒ³ÖØÆôUSR-M300¡£

£¨3£©´Ó»ú--µãλÁбí£¬µã»÷Ìí¼Ó

£¨4£©µãλÃû³Æ£ºdata1(ºÍºóÃæÉϱ¨Êý¾Ý¶¼µãλÃû³Æ±£³ÖÒ»Ö£©£¬¼Ä´æÆ÷¹¦ÄÜÂë04£¬¼Ä´æÆ÷µØÖ·1£¨¶ÔӦʵ¼ÊÊ®½øÖƼĴæÆ÷µØÖ·0£©£¬¶Áд״̬¶Áд£¬µã»÷È·¶¨¡£

£¨5£©ÔÙÌí¼ÓµÚ¶þ¸öµã룬µãλÃû³Æ£ºdata2(ºÍºóÃæÉϱ¨Êý¾ÝµÄµãλÃû³Æ±£³ÖÒ»Ö£©£¬¼Ä´æÆ÷¹¦ÄÜÂë04£¬¼Ä´æÆ÷µØÖ·1£¨¶ÔӦʵ¼ÊÊ®½øÖƼĴæÆ÷µØÖ·0£©£¬¶Áд״̬¶Áд£¬µã»÷È·¶¨¡£

£¨6£©Ìí¼ÓÍ꣬¿ÉÒÔÁбí¼ì²é

3¡¢±ßÔµÍø¹Ø£ºÍ¨ÐÅÁ´Â·--Á´Â·1--TCP²ÎÊýÉèÖÃ

£¨1£©µã»÷Á´Â·1£¬´ò¿ªÁ´Â·1¿ª¹Ø¡£

£¨2£©ÔÚ»ù´¡ÉèÖã¬

ͨÐÅЭÒ飺MQTT

ЭÒéÑ¡Ôñ£ºMQTT-3.1.1

·þÎñÆ÷µØÖ·£ºÌîUSR-M300 Á¬½ÓµÄMQTT·þÎñÆ÷µØÖ·IP

¿Í»§ID£º×Ô¶¨ÒåÌî1234567890£¬±ÜÃâºÍÆäËûÁ¬½ÓMQTT·þÎñÆ÷µÄ¿Í»§¶ËIDÖظ´³åÍ»¡£

Ô¶³Ì¶Ë¿Ú£ºÌîUSR-M300 Á¬½ÓµÄMQTT·þÎñÆ÷µÄ¶Ë¿Ú

¿ªÆôÁ¬½ÓÑéÖ¤£¬ÌîдÁ¬½ÓMQTT·þÎñÆ÷µÄÓû§ÃûºÍÃÜÂ룬Èç¹ûMQTT·þÎñÆ÷ûÓÐÓû§ÃûºÍÃÜÂ룬¿ÉÒÔ²»ÓÿªÆôÁ¬½ÓÑéÖ¤¡£

ÆäËû²ÎÊý±£³ÖĬÈÏ¡£

µã»÷Ó¦Óá£

£¨3£©·¢²¼ÉèÖÃ

µã»÷·¢²¼ÉèÖ㬵ã»÷±à¼­£¬Ö÷ÌâÃû³ÆÌî/USR-M300/update

QOS£ºÑ¡ÔñQOS0£¬µã»÷È·¶¨£¬µã»÷Ó¦Óá£

£¨4£©¶©ÔÄÉèÖÃ

µã»÷¶©ÔÄÉèÖ㬵ã»÷±à¼­£¬Ö÷ÌâÃû³ÆÌî/USR-M300/get

QOS£ºÑ¡ÔñQOS0£¬µã»÷È·¶¨£¬µã»÷Ó¦Óá£

4¡¢±ßÔµÍø¹Ø£ºÐ­Òéת»»--Json

£¨1£©µã»÷ЭÒéת»»£¬µã»÷Json,¿ªÆôJson

£¨2£©¿ªÆôJsonÖ®ºóµã»÷Ìí¼Ó

£¨3£©Á´Â·Ñ¡ÔñÁ´Â·1£¬·¢²¼Ö÷Ìâ/USR-M300/update£¬¶©ÔÄÖ÷Ìâ/USR-M300/get

£¨4£©µã»÷Ó¦ÓÃ

5¡¢×îºóÍøÒ³µã»÷ÖØÆô£¬µÈ´ýUSR-M300ÖØÆôÍê³É¡£

ËÄ¡¢MODBUS SLAVEÈí¼þÉèÖÃ

1¡¢MODBUS SLAVEÈí¼þÉèÖÃ

£¨1£©ÔÚµçÄÔÉÏ°²×°Modbus SlaveÈí¼þ£¬µã»÷Setup

Slave ID£º1£¨´Ó»úµØÖ·²âÊÔÓÃ1£©

Function: 03£¨¶Á¼Ä´æÆ÷¹¦ÄÜÂ룩

Address£º0£¨¼Ä´æÆ÷ÆðʼµØÖ·ÓÃ0£©

Quantity£º2£¨´ÓÆðʼµØÖ·¿ªÊ¼¼Ä´æÆ÷µØÖ·ÊýÁ¿£©

£¨2£©Modbus SlaveÈí¼þ£¬µã»÷Connection£¬Ñ¡ÔñModbus TCP/IP¡£Ñ¡ÔñPort 102£¬¶ÔÓ¦USR-M300 Ìí¼Ó´Ó»úʱÌîдµÄ¶Ë¿ÚºÅ102¡£×îºóµã»÷OK¡£

Îå¡¢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Ï·¢Ð´Êý¾Ý

1¡¢MQTT·þÎñÆ÷JSONÏ·¢Ð´¼Ä´æÆ÷µØÖ·0Êý¾Ý666£¬Ð´¼Ä´æÆ÷µØÖ·1Êý¾Ý888

MQTTfxÈí¼þ£¬µã»÷Publish£¬ÊäÈëÖ÷Ìâ/USR-M300/get£¬·¢ËÍÇø·¢ËÍJSON¸ñʽÃüÁ¸Ä±äMODBUS SLAVEÈí¼þµÄ¼Ä´æÆ÷µØÖ·Êý¾Ý¡£

·¢ËÍÇø°´ÕÕ¸ñʽÊäÈëÏ·¢JSON¸ñʽÃüÁ

{

"rw_prot": {

"Ver": "1.0.1",

"dir": "down",

"id": "12345",

"r_data": [{

"name": "data1"

},

{

"name": "data2"

}

],

"w_data": [{

"name": "data1",

"value": "666"

},

{

"name": "data2",

"value": "888"

}

]

}

}

2¡¢MQTT·þÎñÆ÷JSONÏ·¢Ð´¼Ä´æÆ÷µØÖ·Êý¾ÝÖ®ºó£¬MQTT·þÎñÆ÷ÊÕµ½»Ø¸´

MQTTfxÈí¼þ£¬µã»÷Subscribe£¬ÊäÈëÖ÷Ìâ/USR-M300/update£¬µã»÷Ö÷ÌâºóÃæµÄSubscribe½ÓÊջظ´Êý¾Ý¡£

{

"rw_prot": {

"dir": "up",

"Ver": "1.0.1",

"id": "12345",

"w_data": [{

"name": "data1",

"value": "666",

"err": "0"

}, {

"name": "data2",

"value": "888",

"err": "0"

}],

"r_data": [{

"name": "data1",

"value": "666",

"err": "0"

}, {

"name": "data2",

"value": "888",

"err": "0"

}]

}

}

»Ø¸´JSON¸ñʽÄÚÈÝ£º




±àдÈË£º½ðÖ¾·½ ±àдÈÕÆÚ£º2024-08-02

ÉóºËÈË£º½ðÖ¾·½ ÉóºËÈÕÆÚ£º2024-08-02

¶©Õý°æ±¾£ºV1.0 ¶©ÕýÄÚÈÝ£º³õ¸å   



¹Ø×¢¿­·¢¡¤k8¹ú¼Ê΢ÐŹ«ÖÚºÅ
Á˽â¸ü¶àÐÅÏ¢

sitemap¡¢µØͼ