Smart Home Automation Forum
[Arduino source code for KC868-A16S]-06 DS18B20 - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16S (https://www.kincony.com/forum/forumdisplay.php?fid=47)
+--- Thread: [Arduino source code for KC868-A16S]-06 DS18B20 (/showthread.php?tid=2797)



[Arduino source code for KC868-A16S]-06 DS18B20 - KinCony Support - 04-14-2023

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);
}
[Arduino source code for KC868-A16S]-06 DS18B20