好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

PM2.5传感器Modbusrtu通讯协议.doc

4页
  • 卖家[上传人]:ss****gk
  • 文档编号:281150626
  • 上传时间:2022-04-23
  • 文档格式:DOC
  • 文档大小:70.50KB
  • / 4 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • PM2. 5传感器Modbus rtu通讯协议-、标准modbus协议说明1、串口设置波特率9600,无校验,数据位8,停止位1力能通讯命令16进制:00 03 00 00 00 01 85 DB (不清楚设备地址可用此找冋) 2、接口说明请接入GND (地\电源负极),TX (模组串口发对应串口线收),RX (模组串口收对应串 口线发)对应接口调试不通请交换串口线再试4、CRC16校验计算函数(请确认单片机人端编程还是小端)返回 short int参数data【】数组、Ion数组长度例子:datax [8] ={01, 03, 00, 00, 00, 01, 00, 00} 16 进制 unsigned short int x=CRC_16(datax, 6);得到 x=0x840a;six xlx /吓、XT% ZJX Iunsigned short int CRC_16(unsigned char *data, int len)unsigned char *buf;unsigned short int * CRC;unsigned short int crch,crcl; short int i;short int j;char err;buf= & data[len];CRC=(unsigned short int *)buf;buf[0]=0xff;buf[l]=0xff;for (i=0;i>8;crcl=*CRC«8;*CRC=crch+crcl;return(*CRC);/******************函数 CRC_16 () *********小端返回 short int参数data【】数组、len数组长度例子:datax [8] ={01, 03, 00, 00, 00, 01, 00, 00} 16 进制 unsigned short int x=CRC_16(datax,6);得到 X二0x840a;unsigned short int CRC_16(unsigned char *data, int len) { unsigned char *buf;unsigned short int * CRC;unsigned short int crch,crcl;uchar p;uchar j;char err;buf= & data[len];CRC= (unsigned short int *)buf; buf[0]=0xff;//lsbbuf[l]=0xff;//msbfor (p=0;p

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.