รหัสสินค้า | AS20575 |
หมวดหมู่ | วัดสภาพแวดล้อมและแก๊ส Environmental / Gas |
ราคา | 11,185.00 บาท |
สถานะสินค้า | พร้อมส่ง |
จำนวน | ชิ้น |
Hardware
Software
If the power of the RS485 device is small and the required current is less than 12V-160mA, the RS485 to UART signal conversion module does not require a 12V external power supply, making wiring more convenient.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //TX,RX
uint8_t Com[8] = { 0x01, 0x03, 0x01, 0xF4, 0x00, 0x04, 0x04, 0x07 }; //Wind speed and direction
uint8_t Com1[8] = { 0x01, 0x03, 0x01, 0xF8, 0x00, 0x02, 0x44, 0x06 }; //Temperature and humidity
uint8_t Com2[8] = { 0x01, 0x03, 0x01, 0xFD, 0x00, 0x03, 0x95, 0xC7 }; //Atmospheric pressure, light
uint8_t Com3[8] = { 0x01, 0x03, 0x02, 0x01, 0x00, 0x01, 0xD4, 0x72 }; //Rainfall
float tem, hum, ws, ap;
int wd, wdangle, lux;
void setup() {
Serial.begin(9600);
mySerial.begin(4800);
}
void loop() {
readhumiture();
Serial.print("TEM = ");
Serial.print(tem, 1);
Serial.print("°C ");
Serial.print("HUM = ");
Serial.print(hum, 1);
Serial.print("%RH ");
readAtmosphericPressure_Light();
Serial.print("AP = ");
Serial.print(ap, 1);
Serial.print("Kpa ");
Serial.print("Lux = ");
Serial.print(lux);
Serial.print("(lux) ");
float Rain = readRainfall();
Serial.print("Rain = ");
Serial.print(Rain, 1);
Serial.println("mm ");
readWindSpeed_WindDirection();
Serial.print("Wind Speed = ");
Serial.print(ws, 1);
Serial.print("m/s ");
Serial.print("Wind Direction = ");
Serial.print(wd);
Serial.print(" WindDirection_Angle = ");
Serial.print(wdangle);
Serial.println("° ");
Serial.println(" ");
delay(2000);
}
void readWindSpeed_WindDirection(void) {
uint8_t Data[12] = { 0 };
uint8_t ch = 0;
bool flag = 1;
long timeStart = millis();
long timeStart1 = 0;
while (flag) {
if ((millis() - timeStart1) > 100) {
while (mySerial.available() > 0) {
mySerial.read();
}
mySerial.write(Com, 8);
timeStart1 = millis();
}
if ((millis() - timeStart) > 1000) {
Serial.println("Time out");
return -1;
}
if (readN(&ch, 1) == 1) {
if (ch == 0x01) {
Data[0] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x03) {
Data[1] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x08) {
Data[2] = ch;
if (readN(&Data[3], 10) == 10) {
if (CRC16_2(Data, 11) == (Data[11] * 256 + Data[12])) {
ws = (Data[3] * 256 + Data[4]) / 100.00;
wd = Data[7] * 256 + Data[8];
wdangle = Data[9] * 256 + Data[10];
flag = 0;
}
}
}
}
}
}
}
}
}
}
void readhumiture(void) {
uint8_t Data[10] = { 0 };
uint8_t ch = 0;
bool flag = 1;
long timeStart = millis();
long timeStart1 = 0;
while (flag) {
if ((millis() - timeStart1) > 100) {
while (mySerial.available() > 0) {
mySerial.read();
}
mySerial.write(Com1, 8);
timeStart1 = millis();
}
if ((millis() - timeStart) > 1000) {
Serial.println("Time out1");
return -1;
}
if (readN(&ch, 1) == 1) {
if (ch == 0x01) {
Data[0] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x03) {
Data[1] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x04) {
Data[2] = ch;
if (readN(&Data[3], 6) == 6) {
if (CRC16_2(Data, 7) == (Data[7] * 256 + Data[8])) {
hum = (Data[3] * 256 + Data[4]) / 10.00;
tem = (Data[5] * 256 + Data[6]) / 10.00;
flag = 0;
}
}
}
}
}
}
}
}
}
}
void readAtmosphericPressure_Light(void) {
uint8_t Data[10] = { 0 };
uint8_t ch = 0;
long timeStart = millis();
long timeStart1 = 0;
bool flag = 1;
while (flag) {
if ((millis() - timeStart1) > 100) {
while (mySerial.available() > 0) {
mySerial.read();
}
mySerial.write(Com2, 8);
timeStart1 = millis();
}
if ((millis() - timeStart) > 1000) {
Serial.println("Time out2");
return -1;
}
if (readN(&ch, 1) == 1) {
if (ch == 0x01) {
Data[0] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x03) {
Data[1] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x06) {
Data[2] = ch;
if (readN(&Data[3], 8) == 8) {
if (CRC16_2(Data, 9) == (Data[9] * 256 + Data[10])) {
ap = (Data[3] * 256 + Data[4]) / 10.00;
lux = Data[5] << 24 | Data[6] << 16 | Data[7] << 8 | Data[8];
flag = 0;
}
}
}
}
}
}
}
}
}
}
float readRainfall(void) {
uint8_t Data[10] = { 0 };
uint8_t ch = 0;
long timeStart = millis();
long timeStart1 = 0;
bool flag = 1;
float data;
while (flag) {
if ((millis() - timeStart1) > 100) {
while (mySerial.available() > 0) {
mySerial.read();
}
mySerial.write(Com3, 8);
timeStart1 = millis();
}
if ((millis() - timeStart) > 1000) {
Serial.println("Time out3");
return -1;
}
if (readN(&ch, 1) == 1) {
if (ch == 0x01) {
Data[0] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x03) {
Data[1] = ch;
if (readN(&ch, 1) == 1) {
if (ch == 0x02) {
Data[2] = ch;
if (readN(&Data[3], 4) == 4) {
if (CRC16_2(Data, 5) == (Data[5] * 256 + Data[6])) {
data = (Data[3] * 256 + Data[4]) / 10.00;
flag = 0;
}
}
}
}
}
}
}
}
}
return data;
}
uint8_t readN(uint8_t *buf, size_t len) {
size_t offset = 0, left = len;
int16_t Tineout = 500;
uint8_t *buffer = buf;
long curr = millis();
while (left) {
if (mySerial.available()) {
buffer[offset] = mySerial.read();
offset++;
left--;
}
if (millis() - curr > Tineout) {
break;
}
}
return offset;
}
unsigned int CRC16_2(unsigned char *buf, int len) {
unsigned int crc = 0xFFFF;
for (int pos = 0; pos < len; pos++) {
crc ^= (unsigned int)buf[pos];
for (int i = 8; i != 0; i--) {
if ((crc & 0x0001) != 0) {
crc >>= 1;
crc ^= 0xA001;
} else {
crc >>= 1;
}
}
}
crc = ((crc & 0x00ff) << 8) | ((crc & 0xff00) >> 8);
return crc;
}
Print the collected ultrasonic wind speed and direction values, temperature values, humidity values, atmospheric pressure values, light values, and rainfall values
When measuring wind speed and direction, the N-shaped direction on the weather station sensor should be installed facing due north to avoid errors.
The applicable range of the bottom mounting bar: 46-51mm
Note: To ensure the accuracy of the equipment, please clean the lower surface of the measuring area of the equipment regularly to keep it clean and free of dust or other foreign matter.
ชำระเงินค่าสินค้าโดยการโอนเงินเข้าบัญชีธนาคาร KBANK, SCB, BBL,TMB
กรุณาเก็บหลักฐานการโอนเงินของท่านไว้เพื่อแจ้งการชำระเงินด้วยค่ะ
ท่านสามารถแจ้งการชำระเงินผ่านระบบอัตโนมัติได้โดย Click Link ข้างล่างค่ะ
https://www.arduitronics.com/informpayment
หน้าที่เข้าชม | 15,375,197 ครั้ง |
ผู้ชมทั้งหมด | 5,878,275 ครั้ง |
เปิดร้าน | 21 พ.ค. 2556 |
ร้านค้าอัพเดท | 5 ก.ย. 2568 |