
USR-M300Á¬½ÓMQTT·þÎñÆ÷JsonÏ·¢Ð´Êý¾ÝʾÀý
±¸×¢£º±¾°¸ÀýÊÇUSR-M300ÄÚÖÿ¨ÁªÍø£¬Á¬½Ó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¸ö
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¡¢Êý¾Ýµãλ£ºÌí¼Ó´Ó»úºÍµãλ
£¨1£©µã¿ªÊý¾Ýµã룬ÔÚ´Ó»úÒ»À¸£¬µã»÷Ìí¼Ó¡£
£¨2£©´Ó»úÃû³Æ£ºdevice1£¬²É¼¯ÐÒ飺Modbus_RTU£¬£¬´Ó»ú¿ª¹Ø´ò¿ª£¬´Ó»úµØÖ·£º1¡£
µã»÷È·¶¨£¬µÈÉèÖÃÍêËùÓвÎÊý£¬×îºóÍøÒ³ÖØÆôUSR-M300¡£
£¨3£©´Ó»ú--µãλÁÐ±í£¬µã»÷Ìí¼Ó
£¨4£©µãλÃû³Æ£ºdata1(ºÍºóÃæÉϱ¨Êý¾Ý¶¼µãλÃû³Æ±£³ÖÒ»Ö£©£¬¼Ä´æÆ÷¹¦ÄÜÂë04£¬¼Ä´æÆ÷µØÖ·1£¨¶ÔӦʵ¼ÊÊ®½øÖƼĴæÆ÷µØÖ·0£©£¬¶Áд״̬¶Áд£¬µã»÷È·¶¨¡£
£¨5£©ÔÙÌí¼ÓµÚ¶þ¸öµã룬µãλÃû³Æ£ºdata2(ºÍºóÃæÉϱ¨Êý¾ÝµÄµãλÃû³Æ±£³ÖÒ»Ö£©£¬¼Ä´æÆ÷¹¦ÄÜÂë04£¬¼Ä´æÆ÷µØÖ·1£¨¶ÔӦʵ¼ÊÊ®½øÖƼĴæÆ÷µØÖ·0£©£¬¶Áд״̬¶Áд£¬µã»÷È·¶¨¡£
£¨6£©Ìí¼ÓÍ꣬¿ÉÒÔÁбí¼ì²é
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Á¬½Ó
Îå¡¢MODBUS SLAVEÈí¼þÉèÖÃ
1¡¢MODBUS SLAVEÈí¼þÉèÖÃ
£¨1£©ÔÚµçÄÔÉÏ°²×°Modbus SlaveÈí¼þ£¬µã»÷Setup
Slave ID£º1£¨´Ó»úµØÖ·²âÊÔÓÃ1£©
Function: 03£¨¶Á¼Ä´æÆ÷¹¦ÄÜÂ룩
Address£º0£¨¼Ä´æÆ÷ÆðʼµØÖ·ÓÃ0£©
Quantity£º2£¨´ÓÆðʼµØÖ·¿ªÊ¼¼Ä´æÆ÷µØÖ·ÊýÁ¿£©
£¨2£©Modbus SlaveÈí¼þ£¬µã»÷Connection£¬Ñ¡ÔñSerial Port£¬Ñ¡Ôñ¶ÔÓ¦µÄCOM¿ÚCOM10£¬¶ÔÓ¦USR-M300µÄ´®¿Ú²ÎÊý²¨ÌØÂÊ9600£¬×îºóµã»÷OK¡£
Áù¡¢MQTT·þÎñÆ÷JSONÏ·¢Ð´Êý¾Ý
1¡¢MQTT·þÎñÆ÷JSONÏ·¢Ð´¼Ä´æÆ÷µØÖ·0Êý¾Ý10£¬Ð´¼Ä´æÆ÷µØÖ·1Êý¾Ý20
MQTTfxÈí¼þ£¬µã»÷Publish£¬ÊäÈëÖ÷Ìâ/USR-M300/get£¬·¢ËÍÇø·¢ËÍJSON¸ñʽÃüÁ¸Ä±äMODBUS SLAVEÈí¼þµÄ¼Ä´æÆ÷µØÖ·Êý¾Ý¡£
·¢ËÍÇø°´ÕÕ¸ñʽÊäÈëÏ·¢JSON¸ñʽÃüÁ
{
"rw_prot": {
"Ver": "1.0.1",
"dir": "down",
"id": "12345",
"r_data": [{
"name": "date1"
},
{
"name": "date2"
} ] ,
"w_data": [{
"name": "date1",
"value": "10"
},
{
"name": "date2",
"value": "20"
} ]
}
}
2¡¢MQTT·þÎñÆ÷JSONÏ·¢Ð´¼Ä´æÆ÷µØÖ·Êý¾ÝÖ®ºó£¬MQTT·þÎñÆ÷ÊÕµ½»Ø¸´
MQTTfxÈí¼þ£¬µã»÷Subscribe£¬ÊäÈëÖ÷Ìâ/USR-M300/update£¬µã»÷Ö÷ÌâºóÃæµÄSubscribe½ÓÊջظ´Êý¾Ý¡£
»Ø¸´JSON¸ñʽÄÚÈÝ£º
{
"rw_prot": {
"dir": "up",
"Ver": "1.0.1",
"id": "12345",
"w_data": [{
"name": "date1",
"value": "10",
"err": "0"
}, {
"name": "date2",
"value": "20",
"err": "0"
}],
"r_data": [{
"name": "date1",
"value": "10",
"err": "0"
}, {
"name": "date2",
"value": "20",
"err": "0"
}]
}
}
±àдÈË£º½ðÖ¾·½ ±àдÈÕÆÚ£º2024-07-17
ÉóºËÈË£º½ðÖ¾·½ ÉóºËÈÕÆÚ£º2024-07-17
¶©Õý°æ±¾£ºV1.0 ¶©ÕýÄÚÈÝ£º³õ¸å