Smart Home Automation Forum
[Arduino IDE demo source code for KC868-A6]--#09-RS485_code - 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-A6 (https://www.kincony.com/forum/forumdisplay.php?fid=22)
+--- Thread: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code (/showthread.php?tid=1867)

Pages: 1 2


RE: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code - admin - 08-19-2024

there have code.
   


RE: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code - sistemasyusa - 09-10-2024

buen dia estoy probando el rs485 , puedo usar este codigo donde pongo los pines de manera dinamica

este es el fragmento de mi codigo


#define RXD2 16
#define TXD2 19
const int ledPin = 22;

void setup() {

delay(10);

// Conectar WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
delay(500);


// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
Serial.begin(9600);
//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);


RE: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code - admin - 09-10-2024

what problem?


RE: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code - sistemasyusa - 09-10-2024

Que no me funciona, ya edita el archivo HardwareSerial.cpp envío la imagen


RE: [Arduino IDE demo source code for KC868-A6]--#09-RS485_code - admin - 09-10-2024

Code:
#define RXD2 16
#define TXD2 19
const int ledPin = 22;
const char* ssid = "your-ssid";        // WiFi SSID
const char* password = "your-password"; // WiFi password

void setup() {
  pinMode(ledPin, OUTPUT);  // Set ledPin as an output

  delay(10);

  // Connect to WiFi
  WiFi.begin(ssid, password);
 
  // Wait until WiFi is connected
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }

  // Setup serial communication
  Serial.begin(9600);  // Begin Serial communication for monitoring
  //Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2); // Uncomment if Serial1 is used
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);  // Begin Serial2 communication
}

void loop() {
  // Control the LED to blink
  digitalWrite(ledPin, HIGH);  // Turn the LED on
  delay(1000);                 // Wait for 1 second
  digitalWrite(ledPin, LOW);   // Turn the LED off
  delay(1000);                 // Wait for 1 second
}