当前位置: 首页 > news >正文

modbus slave 设备通过 网关thingsboard-gateway 将数据上传到thingsboard云平台

   搭建thingsboard物联网云平台花了大量时间,从小白到最后搭建成功,折磨了好几天,也感谢网友的帮助,提供了思路最终成功搞定,特此记录。

 一、thingsboard环境搭建(Ubuntu20.04LTS)

        参考官方文档,按部就班操作即可

        http://www.ithingsboard.com/docs/user-guide/install/ubuntu/

      

二、thingsboard-gateway环境搭建

      也是参考官方文档,直接安装

      Step 1. Download the deb file

wget https://github.com/thingsboard/thingsboard-gateway/releases/latest/download/python3-thingsboard-gateway.deb

Step 2. Install the gateway using apt

Install ThingsBoard IoT Gateway as package and run it as daemon use the following command:
 

sudo apt install ./python3-thingsboard-gateway.deb -y

The deb package will automatically install the necessary libraries for the IOT Gateway to work:

  1. System libraries: libffi-dev, libglib2.0-dev, libxml2-dev, libxslt-dev, libssl-dev, zlib1g-dev, python3-dev, python3-pip.
  2. Python modules: importlib, importlib-metadata, jsonschema, pymodbus, lxml, jsonpath-rw, paho-mqtt, pyserial, PyYAML, simplejson, pyrsistent.

Step 3. Check gateway status

systemctl status thingsboard-gateway

修改配置文件:/etc/thingsboard-gateway/config/tb_gateway.json

{"thingsboard": {"host": "127.0.0.1","port": 1883,"remoteShell": false,"remoteConfiguration": true,"statistics": {"enable": true,"statsSendPeriodInSeconds": 3600,"configuration": null},"deviceFiltering": {"enable": false,"filterFile": "list.json"},"maxPayloadSizeBytes": 1024,"minPackSendDelayMS": 200,"minPackSizeToSend": 500,"checkConnectorsConfigurationInSeconds": 60,"handleDeviceRenaming": true,"security": {"type": "accessToken","accessToken": "ke6h88w6f0fssjaq4s9e"},"qos": 1,"checkingDeviceActivity": {"checkDeviceInactivity": false,"inactivityTimeoutSeconds": 200,"inactivityCheckPeriodSeconds": 500},"ts": 1721138363329},"storage": {"type": "memory","read_records_count": 100,"max_records_count": 100000,"data_folder_path": "./data/","max_file_count": 10,"max_read_records_count": 10,"max_records_per_file": 10000,"data_file_path": "./data/data.db","messages_ttl_check_in_hours": 1,"messages_ttl_in_days": 7,"ts": 1721138363329},"grpc": {"enabled": false,"serverPort": 9595,"keepaliveTimeMs": 10000,"keepaliveTimeoutMs": 5000,"keepalivePermitWithoutCalls": true,"maxPingsWithoutData": 0,"minTimeBetweenPingsMs": 10000,"minPingIntervalWithoutDataMs": 5000,"keepAliveTimeMs": 10000,"keepAliveTimeoutMs": 5000},"connectors": [{"type": "modbus","name": "MODBUS CONNECT","configuration": "modbus_serial.json"}]
}

 mqtt_modbus.json配置

{"master": {"slaves": [{"type": "serial","method": "rtu","port": "/dev/ttyS1","baudrate": 9600,"timeout": 35,"stopbits": 1,"bytesize": 8,"byteOrder": "BIG","wordOrder": "BIG","retries": true,"retryOnEmpty": true,"retryOnInvalid": true,"pollPeriod": 5000,"unitId": 1,"deviceName": "Modbus Temperature Sensor","sendDataOnlyOnChange": false,"connectAttemptTimeMs": 5000,"connectAttemptCount": 5,"waitAfterFailedAttemptsMs": 300000,"attributes": [{"tag": "16int","type": "16int","functionCode": 4,"objectsCount": 2,"address": 3}],"timeseries": [{"tag": "temperature","type": "16uint","functionCode": 4,"objectsCount": 1,"address": 1},{"tag": "humidity","type": "16uint","functionCode": 4,"objectsCount": 1,"address": 2}],"attributeUpdates": [{"tag": "shared_attribute_write","type": "32int","functionCode": 6,"objectsCount": 2,"address": 29}],"rpc": [{"tag": "setValue","type": "16int","functionCode": 6,"objectsCount": 1,"address": 1},{"tag": "getValue","type": "16int","functionCode": 3,"objectsCount": 1,"address": 2}]}]},"id": "19c7e3fa-bfd8-4edb-9590-1fd570902b35"
}

三、modbus slave配置

在命令行重启网关:

sudo  systemctl restart thingsboard-gateway.service

云平台就会出现Modbus Temperature Sensor这个设备

四、新建调试界面,对设备进行调试

终于通信成功!!!!!

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 基于ListBox制作一个好看的侧边菜单导航栏
  • 【Agent】信息提取场景
  • 深入理解Android中的缓存与文件存储目录
  • IDEA的工程与模块管理
  • Laravel与现代前端:Vue.js与React的无缝集成
  • 如何定位Milvus性能瓶颈并优化
  • FPGA-ROM IP核的使用
  • 【数据结构】排序算法——Lessen1
  • 【味蕾盛宴】嘴尚绝健康与美味的完美融合
  • 服务器借助笔记本热点WIFI上网
  • 7月21日,贪心练习
  • 掌控视界:WebKit与CSS视口单位的卓越支持
  • 开源模型应用落地-FastAPI-助力模型交互-进阶篇-中间件(四)
  • 【LeetCode】对称二叉树
  • Android 10.0 Launcher3拖拽图标进入hotseat自适应布局功能实现一
  • 【399天】跃迁之路——程序员高效学习方法论探索系列(实验阶段156-2018.03.11)...
  • 77. Combinations
  • canvas 绘制双线技巧
  • Docker 笔记(1):介绍、镜像、容器及其基本操作
  • es的写入过程
  • Java Agent 学习笔记
  • js继承的实现方法
  • nodejs:开发并发布一个nodejs包
  • 紧急通知:《观止-微软》请在经管柜购买!
  • 前端攻城师
  • 前端知识点整理(待续)
  • 区块链共识机制优缺点对比都是什么
  • 数组大概知多少
  • 新手搭建网站的主要流程
  • ​​​​​​​ubuntu16.04 fastreid训练过程
  • #{}和${}的区别?
  • #define MODIFY_REG(REG, CLEARMASK, SETMASK)
  • (c语言)strcpy函数用法
  • (纯JS)图片裁剪
  • (附源码)ssm捐赠救助系统 毕业设计 060945
  • (介绍与使用)物联网NodeMCUESP8266(ESP-12F)连接新版onenet mqtt协议实现上传数据(温湿度)和下发指令(控制LED灯)
  • (强烈推荐)移动端音视频从零到上手(下)
  • (亲测有效)推荐2024最新的免费漫画软件app,无广告,聚合全网资源!
  • (十二)python网络爬虫(理论+实战)——实战:使用BeautfulSoup解析baidu热搜新闻数据
  • (十一)c52学习之旅-动态数码管
  • (算法二)滑动窗口
  • (限时免费)震惊!流落人间的haproxy宝典被找到了!一切玄妙尽在此处!
  • (一)RocketMQ初步认识
  • (转)linux下的时间函数使用
  • (转)机器学习的数学基础(1)--Dirichlet分布
  • (自用)网络编程
  • * 论文笔记 【Wide Deep Learning for Recommender Systems】
  • ****三次握手和四次挥手
  • .a文件和.so文件
  • .NET / MSBuild 扩展编译时什么时候用 BeforeTargets / AfterTargets 什么时候用 DependsOnTargets?
  • .net mvc actionresult 返回字符串_.NET架构师知识普及
  • .NET Standard 的管理策略
  • .net 简单实现MD5
  • .NET 解决重复提交问题
  • .NET/C# 使用 ConditionalWeakTable 附加字段(CLR 版本的附加属性,也可用用来当作弱引用字典 WeakDictionary)