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: 257)
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
#2
Hello, put a 3V3 converter so that the RX and TX ports (io12 io13) communicate correctly with nextion to the 5V converter, which could damage the board you produced with so much affection. Note that the communication failed because I need to remove the wire connected to the RX and then plug it in for my project to work. how do i solve this?

Thanks!
Reply
#3
why damage? your Nextion display connect to KC868-A6's pin directly is ok, just do as photo. Nextion display serial port support 3.3v level.
Reply
#4
To turn on the nextion monitor, it was necessary to feed it with 5V. These pins of the kincony A6 board would ideally receive 3.3V

Why was there no concern with the voltage applied to make an RX TX communication from the monitor to pins A12 and A13 of the kincony A6 board?

The communication of both is being 5V. Correct me if I reached the wrong conclusion.
Reply
#5
we alreeady have post the photo, it's work fine. your question is no problem.
Reply
#6
Hi, sorry to bother you again. I'm using the Nextion library #include <Nextion.h> but it's giving an error when communicating. What are the necessary modifications that I need to make in the serial?

Thanks
Reply
#7
what error information?
you need to define your serial port RXD, TXD pin firstly.
Reply
#8
And it's happening! What procedure needs to be done? Which port do I switch to?
Reply
#9
i don't understand your problem.
Reply
#10
The error is in the serial communication failure. I need to swap the RX and TX pins. How would you solve it? it helps me!
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)