04-14-2023, 02:47 AM
(This post was last modified: 04-14-2023, 03:10 AM by KinCony Support.)
Code:
#include <DS18B20.h>
#define A16S_RS485_RX 32
#define A16S_RS485_TX 33
#define DL 0
DS18B20 ds(14);
void setup() {
Serial.begin(115200);
Serial2.begin(115200,SERIAL_8N1,A16S_RS485_RX,A16S_RS485_TX); //A16S
Serial2.println("A16S RS485 SEND OK");
pinMode(DL,INPUT);
Serial2.print(ds.getTempC());
Serial2.println(" C");
}
void loop() {
if(digitalRead(DL)==LOW)
{
delay(20);
if(digitalRead(DL)==LOW)
{
Serial2.println("Download key ok");
Serial2.print(ds.getTempC());
Serial2.println(" C");
}
}
while(Serial2.available()>0)
{
Serial2.print((char)Serial2.read());//print rs485 receive
}
delay(200);
}