[Arduino source code for KC868-A2]-05 RS485 - KinCony Support - 03-02-2023
Code: //A2
#define A2_RS485RX 35
#define A2_RS485TX 32
void setup() {
Serial.begin(115200);
Serial2.begin(115200,SERIAL_8N1,A2_RS485RX,A2_RS485TX);
Serial2.println("RS485 SEND is OK!!");
Serial2.println("******************");
}
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-A2]-05 RS485 - ktmustafa - 07-11-2024
(03-02-2023, 06:54 AM)KinCony Support Wrote: Code: //A2
#define A2_RS485RX 35
#define A2_RS485TX 32
void setup() {
Serial.begin(115200);
Serial2.begin(115200,SERIAL_8N1,A2_RS485RX,A2_RS485TX);
Serial2.println("RS485 SEND is OK!!");
Serial2.println("******************");
}
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);
}
Hello there
I used this example to send "ON" and "OFF" strings to Arduino Uno via TTL to RS485 module. The Arduino Uno code as below.. However, I received nothing.. Can you please help me solve this issue
Code: #include <SoftwareSerial.h>
#define MCB_ID 1
#define RS_RO 6
#define RS_DI 7
#define RS_DE_RE 8
SoftwareSerial RS_MCB(RS_DI, RS_RO);
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RS_DE_RE, OUTPUT);
Serial.begin(9600);
RS_MCB.begin(9600);
digitalWrite(RS_DE_RE, LOW);
Serial.print("RS_MCB is ready...");
}
// the loop function runs over and over again forever
void loop() {
if (RS_MCB.available() > 0)
{
String command = "";
while (RS_MCB.available()){
command += char(RS_MCB.read());
}
Serial.flush();
Serial.print("RS_MCB command = ");
Serial.println(command);
if(command == 'ON')
{
Serial.println("LED ON");
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
}
else if(command == 'OFF')
{
Serial.println("LED OFF");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
}
}
delay(1000); // wait for a second
}
RE: [Arduino source code for KC868-A2]-05 RS485 - admin - 07-12-2024
if our code work well, you can modify code based on our code.
RE: [Arduino source code for KC868-A2]-05 RS485 - ktmustafa - 07-12-2024
(07-12-2024, 12:06 AM)admin Wrote: if our code work well, you can modify code based on our code.
I used the KC868 A2 as a master. With your code, I send "ON" or "OFF" to the Arduino Uno which connects to the KC868 A2 by using TTL to RS485 module. Arduino Uno has to receive these strings and turn the built-in LED On or Off.. However, the Uno received nothing...
RE: [Arduino source code for KC868-A2]-05 RS485 - admin - 07-12-2024
you can use USB-RS485 cable to debug. whether KC868-A2 have sent out string, use PC serial port debug tool to monitor.
RE: [Arduino source code for KC868-A2]-05 RS485 - powerup - 03-08-2025
(07-11-2024, 05:51 PM)ktmustafa Wrote: (03-02-2023, 06:54 AM)KinCony Support Wrote: Code: //A2
#define A2_RS485RX 35
#define A2_RS485TX 32
void setup() {
Serial.begin(115200);
Serial2.begin(115200,SERIAL_8N1,A2_RS485RX,A2_RS485TX);
Serial2.println("RS485 SEND is OK!!");
Serial2.println("******************");
}
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);
}
Hello there
I used this example to send "ON" and "OFF" strings to Arduino Uno via TTL to RS485 module. The Arduino Uno code as below.. However, I received nothing.. Can you please help me solve this issue
Code: #include <SoftwareSerial.h>
#define MCB_ID 1
#define RS_RO 6
#define RS_DI 7
#define RS_DE_RE 8
SoftwareSerial RS_MCB(RS_DI, RS_RO);
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RS_DE_RE, OUTPUT);
Serial.begin(9600);
RS_MCB.begin(9600);
digitalWrite(RS_DE_RE, LOW);
Serial.print("RS_MCB is ready...");
}
// the loop function runs over and over again forever
void loop() {
if (RS_MCB.available() > 0)
{
String command = "";
while (RS_MCB.available()){
command += char(RS_MCB.read());
}
Serial.flush();
Serial.print("RS_MCB command = ");
Serial.println(command);
if(command == 'ON')
{
Serial.println("LED ON");
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
}
else if(command == 'OFF')
{
Serial.println("LED OFF");
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
}
}
delay(1000); // wait for a second
}
you need to change your pins for rx/tx
#define A2_RS485RX 35
#define A2_RS485TX 32
>
#define RS_RO 6
#define RS_DI 7
|