Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nextion display work with KC868-A6
#1
i have used on board extend serial port. actually use want to use VCC,GND,RXD,TXD for Nextion display.

define RXD:GPIO13 TXD:GPIO12 by ESP32

weld Vcc 5V from LM1117 output pin.

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:
[Image: attachment.php?aid=1429]   
[Image: attachment.php?aid=1430]   

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


.zip   nextion_KC868-A6.ino.nodemcu-32s.zip (Size: 108.86 KB / Downloads: 261)
here are source code:
Code:
#include "PCF8574.h"

String indata="";
String val="";

// Set i2c address
PCF8574 pcf8574(0x24);

void setup() {

  Serial1.begin(9600,SERIAL_8N1,13,12);
  Serial.begin(9600);
  pcf8574.pinMode(P0, OUTPUT);
  pcf8574.pinMode(P1, OUTPUT);
  pcf8574.pinMode(P2, OUTPUT);
  pcf8574.pinMode(P3, OUTPUT);
  pcf8574.pinMode(P4, OUTPUT);
  pcf8574.pinMode(P5, OUTPUT);

  Serial.print("Init pcf8574...");
  if (pcf8574.begin()){
    Serial.println("OK");
  }else{
    Serial.println("KO");
  } 
  pcf8574.digitalWrite(P0, HIGH);
  pcf8574.digitalWrite(P1, HIGH);
  pcf8574.digitalWrite(P2, HIGH);
  pcf8574.digitalWrite(P3, HIGH);
  pcf8574.digitalWrite(P4, HIGH);
  pcf8574.digitalWrite(P5, HIGH);
}

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")   
       {
         pcf8574.digitalWrite(P0, LOW);
         Serial.println("Relay1-ON OK!");
       }
     else if(val=="b")
      {
         pcf8574.digitalWrite(P0, HIGH);
         Serial.println("Relay1-OFF OK!");
      }
  }
  indata=""; 
}
Reply


Messages In This Thread
Nextion display work with KC868-A6 - by admin - 09-27-2022, 05:34 AM
RE: Nextion display work with KC868-A6 - by admin - 03-25-2023, 04:01 AM
RE: Nextion display work with KC868-A6 - by admin - 03-25-2023, 02:05 PM
RE: Nextion display work with KC868-A6 - by admin - 04-01-2023, 01:03 AM
RE: Nextion display work with KC868-A6 - by admin - 04-03-2023, 10:29 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)