应力应变数据采集(用到RS485八通道采集器)
本帖最后由 王大富 于 2021-7-15 20:58 编辑1.硬件
esp8266,rs485转ttl,rs485接口得8通道采集器,应变片若干
2.接线方式
桥式应变片按照红黄蓝黑接到A,B,C,D上,普通应变片接到A,B上,并将B,B+短接,D和D+短接。之后将采集器的485A和B接到rs485转ttl的A和B上,最后将485的GND,RX,TX,VCC接到ESP8266上3.实物图
4.OneNET应用管理界面
5.代码
<blockquote>#include <ESP8266WiFi.h> //esp8266wifi模块库JXBS.h函数
#define MYADRESS1 0x01//485地址
const unsigned char readcmd1={MYADRESS1,0x03,0x00,0x01,0x00,0x0A,0x94,0x0D}; //读取温湿度指令
signed int strain_1=0,strain_2=0,strain_3=0,strain_4=0,strain_5=0,strain_6=0,strain_7=0,strain_8=0;//湿度
void JXBSInit()
{Serial.begin(9600);}
unsigned char com_buf; //接收数据缓存变量
bool rec_flag=false;
bool rec_flag1=false;
bool receive_success_flag=false;
bool receive_success_flag1=false;
///////////////////////////////////////////////
void readJXBS1()
{Serial.write(readcmd1,8);//发射数据
}
void JXBSListen1()
{unsigned char com_num = 0;
while (Serial.available())
{char inChar = (char)Serial.read();
com_buf = inChar;
com_num++;
delay(2);
}
if(com_buf==MYADRESS1 && com_buf==0x03)
{strain_1=com_buf*256+com_buf;
strain_2=com_buf*256+com_buf;
strain_3=com_buf*256+com_buf;
strain_4=com_buf*256+com_buf;
strain_5=com_buf*256+com_buf;
strain_6=com_buf*256+com_buf;
strain_7=com_buf*256+com_buf;
strain_8=com_buf*256+com_buf;
}
}
工业用很好啊
页:
[1]