Smart Home Automation Forum
[Arduino source code for KC868-A8M]-06 RS485 - 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-A8M (https://www.kincony.com/forum/forumdisplay.php?fid=48)
+--- Thread: [Arduino source code for KC868-A8M]-06 RS485 (/showthread.php?tid=2803)



[Arduino source code for KC868-A8M]-06 RS485 - KinCony Support - 04-14-2023

[Arduino source code for KC868-A8M]-06 RS485
Code:
#define A8M_RS485_RX 15
#define A8M_RS485_TX 13
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A8M_RS485_RX,A8M_RS485_TX);//A8M
  Serial2.println("A8M RS485 SEND is OK!!"); 
}

void loop() {
  /*print the received data of RS485 port*/
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//Read rs485 receive data  and print it
   }
  delay(200);
}



RE: [Arduino source code for KC868-A8M]-06 RS485 - Aiot - 07-06-2023

(04-14-2023, 03:19 AM)KinCony Support Wrote: [Arduino source code for KC868-A8M]-06 RS485
Code:
#define A8M_RS485_RX 15
#define A8M_RS485_TX 13
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A8M_RS485_RX,A8M_RS485_TX);//A8M
  Serial2.println("A8M RS485 SEND is OK!!"); 
}

void loop() {
  /*print the received data of RS485 port*/
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//Read rs485 receive data  and print it
   }
  delay(200);
}
I want to use serial to show income data but no luck. Serial is empty. Do I need to add code to print in computer serial?


RE: [Arduino source code for KC868-A8M]-06 RS485 - KinCony Support - 07-07-2023

(07-06-2023, 06:10 AM)Aiot Wrote:
(04-14-2023, 03:19 AM)KinCony Support Wrote: [Arduino source code for KC868-A8M]-06 RS485
Code:
#define A8M_RS485_RX 15
#define A8M_RS485_TX 13
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200,SERIAL_8N1,A8M_RS485_RX,A8M_RS485_TX);//A8M
  Serial2.println("A8M RS485 SEND is OK!!"); 
}

void loop() {
  /*print the received data of RS485 port*/
  while(Serial2.available()>0)
   {
    Serial2.print((char)Serial2.read());//Read rs485 receive data  and print it
   }
  delay(200);
}
I want to use serial to show income data but no luck. Serial is empty. Do I need to add code to print in computer serial?

set like this:
   
   


RE: [Arduino source code for KC868-A8M]-06 RS485 - Menhem - 11-28-2023

Hello I'm trying to read registers of a rs485 device but this code isn't working, how you re assigning rx 15 and tx 13 for serial2 in esp32?
serial2 has the tx pin 17 and rx 16, so I'm confused is there any solution to read the rs485 registers using the KC868-A8M board?


RE: [Arduino source code for KC868-A8M]-06 RS485 - admin - 11-28-2023

our demo code can't work well?


RE: [Arduino source code for KC868-A8M]-06 RS485 - Menhem - 11-28-2023

(11-28-2023, 10:08 AM)admin Wrote: our demo code can't work well?
Thx for Your fast reply,
No I tried to connect the KC868-A8M to a sensor, to read data via RS485 and  I didn't get any result using the demo code


RE: [Arduino source code for KC868-A8M]-06 RS485 - admin - 11-28-2023

you need modify code according to your sensor's protocol.