Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nextion display work with KC868-A4
#1
i have removed RF433M receiver, RF433M sender and IR receiver. actually use want to use VCC,GND,RXD,TXD for Nextion display.

define RXD:GPIO23 TXD:GPIO21 by ESP32

here are some photos:
   
   
   

This just a simplest demo, use Nextion display two buttons, press button-one will send 'a' by serial port, press button-two will send 'b' by serial port.
when KC868-A4 received 'a' will turn ON relay1, when received 'b' will turn OFF relay1.

firstly create two buttons UI by Nextion Editor PC software:
   
   

here is firmware BIN file, you can download to KC868-A4 ESP32 directly to use:

.zip   nextion_KC868-A4.ino.nodemcu-32s.zip (Size: 102.25 KB / Downloads: 271)
here are source code:
Code:
String indata="";
String val="";

const int Relay1 = 2;
const int Relay2 = 15;
const int Relay3 = 5;
const int Relay4 = 4;

void setup() {
  pinMode(Relay1,OUTPUT);   //Relay1 IO2
  pinMode(Relay2,OUTPUT);  //Relay2 IO15
  pinMode(Relay3,OUTPUT);   //Relay3 IO2
  pinMode(Relay4,OUTPUT);   //Relay4 IO2
  Serial1.begin(9600,SERIAL_8N1,23,21);
  Serial.begin(9600);
}

void loop() {
  while(Serial1.available()>0)
  {
    indata+=char(Serial1.read());
    delay(2);
    if(Serial1.available()<=0)
     {
        Serial.println(indata);
     }
  } 
  if(indata.length()>0)
  {
     val=indata;  
     if(val=="a")  
       {
         digitalWrite(Relay1,HIGH);
         Serial.println("Relay1-ON OK!");
       }
     else if(val=="b")
      {
         digitalWrite(Relay1,LOW);
         Serial.println("Relay1-OFF OK!");
      }
  }
  indata=""; 
}
Reply


Messages In This Thread
Nextion display work with KC868-A4 - by admin - 09-23-2022, 02:59 AM
RE: Nextion display work with KC868-A4 - by admin - 11-06-2024, 11:40 PM
RE: Nextion display work with KC868-A4 - by admin - 11-07-2024, 11:47 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)