Ö§³ÖÖÐÐÄ
USR-G771£¨Çá±ßÔµ£©Á¬½ÓMQTT·þÎñÆ÷Json×é°üÉϱ¨Ê¾Àý
2024-07-02



USR-G771£¨Çá±ßÔµ£©Á¬½ÓMQTT·þÎñÆ÷Json×é°üÉϱ¨Ê¾Àý


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

USR-G771&G780sʹÓÃ˵Ã÷Ê飨Çá±ßÔµ£©Á´½Ó£º/Download/1435.html

USR-G771&G780s±ê×¼ATÖ¸Á£¨Çá±ßÔµ£©Á´½Ó£º/Download/1437.html

USR-CAT1 ÉèÖÃÈí¼þ(Çá±ßÔµ£©Á´½Ó£º/Download/1438.html

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

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

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

1¡¢ËùÐèÎïÆ·

USR-G771 ²úÆ· 1̨

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

USB-RS485´®¿ÚÏß 1Ìõ

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

2¡¢Ó²¼þÁ¬½Ó

USR-G771 µÄ485´®¿Ú½ÓUSB-RS485´®¿ÚÏßµ½µçÄÔUSB¿Ú£¬È»ºó²úÆ·½Ó12VµçÔ´ÊÊÅäÆ÷Éϵç¡£

µçÄÔÏÂÔز¢´ò¿ª USR-CAT1 ÉèÖÃÈí¼þ(Çá±ßÔµ£©£¬°²×°MODBUS SLAVEÈí¼þ¡¢MQTTfxÈí¼þ¡£

3¡¢²é¿´¶Ë¿ÚºÅ

µçÄÔÊó±êµã»÷¼ÆËã»ú¾­Óª£¬ÓÒ»÷£¬µã¿ªÉ豸¾­ÓªÆ÷£¬µã»÷¶Ë¿Ú£¬²é¿´½ÓUSR-G771µÄUSB-RS485´®¿ÚÏßCOM¿ÚºÅ£¬COM10¡£

Èý¡¢USR-G771²ÎÊýÉèÖÃ

1¡¢´ò¿ªUSR-G771µÄÉèÖÃÈí¼þ

2¡¢µã»÷½øÈëÅäÖÃ״̬

3¡¢µã»÷»ñÈ¡µ±Ç°²ÎÊý£¬²éѯ¹Ì¼þ°æ±¾ºÅ

±¸×¢£º¹Ì¼þVER:V2.4.01.000000.0000¼°ÒÔÉÏ°æ±¾Ö§³ÖModbusÂÖѯ¡£

4¡¢ÅäÖÃͨµÀÒ»²ÎÊý

ͨµÀÒ»£º

¹¤×÷ģʽ£ºMQTTģʽ

MQTTClientÁ¬½Ó£º¹´Ñ¡Í¨ÓÃMQTT

·þÎñÆ÷µØÖ·ºÍ¶Ë¿Ú£ºÌîдҪÁ¬½ÓµÄMQTT·þÎñÆ÷µØÖ·ºÍ¶Ë¿Ú

¿Í‘ôÃûºÍÃÜÂ룺ÌîдҪÁ¬½ÓµÄMQTT·þÎñÆ÷µÄ¿Í‘ôÃûºÍÃÜÂë

¹Ë¿Í¶ËID£ºÉèÖò»ÒªºÍMQTTfx¼°ÆäËûMQTT¹Ë¿Í¶ËÒ»Ñù¡£ÕâÀï×Ô¶¨ÒåдÁË1234567890¡£

MQTT´®¿Ú´«ÊäģʽÉèÖãºÍ¸´«Ä£Ê½

¶©ÔÄÖ÷Ì⣺¹´Ñ¡Ö÷Ìâ1£¬ÉèÖÃ/USR-G771/get

ÍÆËÍÖ÷Ì⣺¹´Ñ¡Ö÷Ìâ1£¬ÉèÖÃ/USR-G771/update

5¡¢ÅäÖÃMODBUSÂÖѯ²É¼¯²ÎÊý

MODBUSÂÖѯ²É¼¯£º

Æô¶¯ModbusÂÖѯ£º¹´Ñ¡

ÂÖѯÉϱ¨·½Ê½£ºÑ¡ÔñJSON×é°üÉϱ¨

ModbusÂÖѯ²É¼¯µãλÅäÖýçÃ棺Ìí¼Ó3¸ö±äÁ¿¡£

No1 ±äÁ¿Ãû1£¬´Ó»úµØÖ·1£¬¹¦ÄÜÂ루±£³Ö¼Ä´æÆ÷¹¦ÄÜÂë03£©£¬¼Ä´æÆ÷µØÖ·0£¬Êý¾ÝÀàÐÍ16λÎÞ·ûºÅ£¬±¶ÂÊ1£¬Éϱ¨·½Ê½£¨Ö±½ÓÉϱ¨£©

No1 ±äÁ¿Ãû2£¬´Ó»úµØÖ·1£¬¹¦ÄÜÂ루±£³Ö¼Ä´æÆ÷¹¦ÄÜÂë03£©£¬¼Ä´æÆ÷µØÖ·1£¬Êý¾ÝÀàÐÍ16λÎÞ·ûºÅ£¬±¶ÂÊ1£¬Éϱ¨·½Ê½£¨Ö±½ÓÉϱ¨£©

No1 ±äÁ¿Ãû1£¬´Ó»úµØÖ·1£¬¹¦ÄÜÂ루±£³Ö¼Ä´æÆ÷¹¦ÄÜÂë03£©£¬¼Ä´æÆ÷µØÖ·2£¬Êý¾ÝÀàÐÍ16λÎÞ·ûºÅ£¬±¶ÂÊ1£¬Éϱ¨·½Ê½£¨Ö±½ÓÉϱ¨£©

±¸×¢£º

£¨1£©ÕâÀïÌí¼ÓµÄ´Ó»ú¼Ä´æÆ÷µØÖ·ºÍ±äÁ¿£¬ÐèÒªºÍMODBUS SLAVEÄ£ÄâµÄ´®¿Ú´Ó»ú¼Ä´æÆ÷µØÖ·ºÍ±äÁ¿±£³ÖÒ»Ö¡£

£¨2£©Ê¹ÓÃJSONÏ·¢ÃüÁÀïÃæµÄ±äÁ¿ÃûÐèÒªºÍÕâÀïµÄ±äÁ¿ÃûÒ»Ò»¶ÔÓ¦¡£

6¡¢µã»÷ÉèÖò¢±£´æËùÓвÎÊý

ËÄ¡¢MQTTfx²ÎÊýÉèÖÃ

1¡¢´ò¿ªMQTTfxÈí¼þ

2¡¢½¨Ò»¸öеÄÅäÖÃÎļþ×öÁíÒ»¸öMQTT¹Ë¿Í¶Ë

£¨1£©ÅäÖÃÎļþÃû×Ô¶¨ÒåÓÃMQTT

£¨2£©·þÎñÆ÷µØÖ·ÌîºÍUSR-G771Á¬½ÓµÄͬһ¸öMQTT·þÎñÆ÷µØÖ·

£¨3£©¶Ë¿ÚÌîMQTT·þÎñÆ÷¶Ë¿Ú1883

£¨4£©Client ID£¨¹Ë¿Í¶ËID£©¿ÉÒÔµã»÷ºóÃæµÄGenerate×Ô¶¯´´½¨£¬×¢ÒâºÍUSR-G771µÄ¹Ë¿Í¶ËID²»ÒªÒ»Ñù£¬Èç¹ûÏàͬ»á³åÍ»¡£

£¨5£©µã»÷User Credentials£¬User NAMEÊäÈëMQTT·þÎñÆ÷µÄ¿Í‘ôÃû£¬PasswordÊäÈëMQTT·þÎñÆ÷µÄÃÜÂë¡£

£¨6£©ËùÓвÎÊýÉèÖÃÍê³ÉÖ®ºó£¬µã»÷ApplyÓ¦Óá£

3¡¢MQTT.fxÈí¼þÑ¡Ôñн¨µÄ¹Ë¿Í¶ËMQTT£¬µã»÷ConnectÁ¬½Ó

Î塢ͨѶ²âÊÔ

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

£¨1£©µã»÷Setup£¬Slave ID´Ó»úµØÖ·ÓÃ1£¬Function¹¦ÄÜÂëÓÃ03£¬Address¼Ä´æÆ÷ÆðʼµØÖ·ÓÃ0£¬Quantity¼Ä´æÆ÷µØÖ·ÊýÁ¿ÓÃ3¡£

¾ÍÊÇÄ£Äâ´Ó»úµØÖ·1£¬²É¼¯3¸ö¼Ä´æÆ÷µØÖ·0¡¢µØÖ·1¡¢µØÖ·2µÄÊý¾Ý¡£

£¨2£©µã»÷Connection,Ñ¡Ôñ´®¿Ú£¬¶ÔÓ¦USR-G771Ëù½ÓUSB-RS485´®¿ÚÏßµÄCOM¿ÚºÅ£¬´®¿Ú²ÎÊýºÍUSR-G771´®¿Ú²ÎÊý±£³ÖÒ»Ö¡£ ModeÑ¡ÔñRTU£¬Ä£ÄâMODBUS RTUЭÒé´®¿Ú¡£

£¨3£©¼Ä´æÆ÷µØÖ·0ÌîÊý¾Ý10£¬¼Ä´æÆ÷µØÖ·1ÌîÊý¾Ý20£¬¼Ä´æÆ÷µØÖ·3ÌîÊý¾Ý30¡£

2¡¢Json×é°üÉϱ¨£¬MQTT.fxÈí¼þ¶©ÔÄ

Íø¹Ø»á°´ÕÕÉ趨µÄÂÖѯ¹æÔò£¬Ö÷¶¯²É¼¯´Ó»úµÄÊý¾Ý£¬²¢ÒÔJSON¸ñʽÉϱ¨Êý¾Ý¸øMQTT·þÎñÆ÷¡£ÐèÒª½ÓÊÕÊý¾ÝµÄMQTT¹Ë¿Í¶Ë¶©ÔÄÁªÍøÄ£¿éµÄ·¢²¼Ö÷Ìâ¾ÍÄÜÊÕµ½É豸µÄÉϱ¨ÐÅÏ¢¡£

£¨1£©MQTT.fxÈí¼þµã»÷Subscribe£¬ÊäÈë/USR-G771/update£¬µã»÷ºóÃæµÄSubscribe¡£

£¨2£©µã»÷MQTT.fxÈí¼þµÄÿһÌõ/USR-G771/update£¬¿ÉÒÔ¿´µ½Ã¿Ò»ÌõJSONÉϱ¨ÐÅÏ¢¡£

²É¼¯¼Ä´æÆ÷µØÖ·0Êý¾Ý10£¬¼Ä´æÆ÷µØÖ·1Êý¾Ý20£¬¼Ä´æÆ÷µØÖ·2Êý¾Ý30¡£

{"params":{"dir":"up","id":"00601924061200038538","r_data":[{"name":"1","value":"10","err":"0"},{"name":"2","value":"20","err":"0"},{"name":"3","value":"30","err":"0"}]}}

3¡¢MQTT.fxÈí¼þÍÆËÍ£¬JsonÏ·¢ÃüÁî

MQTT·þÎñÆ÷¿ÉÒÔÍùÁªÍøÄ£¿é¶©ÔĵÄÖ÷Ìâ·¢ËÍÃüÁîÀ´ÊµÏÖ½»»¥£¬ÀýÈçÍù´Ó»úдÊý¾Ý¡£¿ÉÒÔ¿´µ½slave´Ó»úÊÕµ½Ö¸Áî½øÐÐÁ˻ظ´£¬Í¬Ê±²ÎÊý·¢ÉúÁ˸ıä¡£

£¨1£©JsonÏ·¢ÃüÁîÈçÏ£¬È¥Ð޸Ĵӻú1£¬¼Ä´æÆ÷µØÖ·0µÄÊý¾Ý¸üÐÂ100£¬¼Ä´æÆ÷µØÖ·1µÄÊý¾Ý¸üÐÂ200£¬¼Ä´æÆ÷µØÖ·3µÄÊý¾Ý¸üÐÂ300¡£

{

"rw_prot": {

"Ver": "1.0.1",

"dir": "down",

"id": "00601924061200038538",

"r_data": [{

"name": "1"

},

{

"name": "2"

},

{

"name": "3"

} ] ,

"w_data": [{

"name": "1",

"value": "100"

},

{

"name": "2",

"value": "200"

},

{

"name": "3",

"value": "300"

} ]

}

}

£¨2£©MQTT.fxÈí¼þµã»÷Publish£¬ÊäÈë/USR-G771/get£¬ÔÚÏÂÃæµÄ·¢ËÍ¿òÊäÈëJsonÏ·¢ÃüÁµã»÷Publish·¢Ë͸øUSR-G771´®¿Ú£¬Íù´Ó»úдÊý¾Ý¡£¿ÉÒÔ¿´µ½slave´Ó»úÊÕµ½Ö¸Áî½øÐÐÁ˻ظ´£¬Í¬Ê±²ÎÊý·¢ÉúÁ˸ıä¡£¼Ä´æÆ÷µØÖ·0дÊý¾Ý100£¬¼Ä´æÆ÷µØÖ·1дÊý¾Ý200£¬¼Ä´æÆ÷µØÖ·2дÊý¾Ý300¡£

£¨3£©¸üкóµÄÊý¾Ý£¬ÔÙÉϱ¨²É¼¯¡£¼Ä´æÆ÷µØÖ·0дÊý¾Ý100£¬¼Ä´æÆ÷µØÖ·1дÊý¾Ý200£¬¼Ä´æÆ÷µØÖ·2дÊý¾Ý300¡£

4¡¢Ê¹ÓÃJSONÏ·¢ÃüÁ

idÊÇÐÅÏ¢IDºÅ£¬ÓÉ·þÎñÆ÷Ï·¢£¬É豸»Ø¸´±£³ÖÒ»Ö¼´¿É¡£Èç·þÎñÆ÷²»Ï·¢£¬ ÔòºöÂÔ¡£Éϱ¨ÖУ¬Ä¬ÈϲÉÓÃÉ豸SN×÷ΪID¡£





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

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

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



¹Ø×¢galaxyÒøºÓ¹ú¼Ê΢ÐŹ«ÖÚºÅ
Á˽â¸ü¶àÐÅÏ¢

sitemap¡¢µØͼ