Start a new topic

One way communication

I'm fighting with Nextion display and WeMos D1 R2 (ESP8266) since 3 days. I have 50% of success - I can send command to display and it's working very well. I connected it to D4 (TX for Serial1 in ESP8266 -> to RX in Nextion) and to D9 (RX for both serials in ESP8266 -> to TX in Nextion).
After long time of fighting with all sort of libraries I realised that I tried to use Latest ITEADLIB which won't work with ESP8266. After changing it to latest stable 0.7.0 version I reached small success. Exaple code "CompButton" now is compiling without errors and seems to work in one way. I see button and "1" digit on it. And in debug window I see:

RetCommandFinished err
recvRetCommandFinished err
setup done

It's long story - tried everything (softwareserial, external power supply (yes - I know about common GND), checked resistance of blue wire (Nextion TX)). Tried to send command: 'bkcmd=3' and 'page' to see if something will came from Nextion. Without success. Also tried another libraries.

I also realised that my brand new Nextion display has default baud rate 115200 so because of it I had to modify NexHardware.cpp in lines 225 and 226:



Finally, I bought USB2RS232 (CH340) converter and tomorrow I'll check display with Nextion Editor. But I suppose that this battle will be lost.

So, in case if I'll fail, what about guarantion?

In case you bought from Itead ...
in case it will fail, you surely can send your display back on own cost. Itead will test it, and in case of any factory based manufactoring issue Itead will surely refund all.


I'd also recommend opening in Free Chat for discussion on coding aspect.

I made it! Conclusion is that Wemos wont work with Nextion using hardware serial (Serial1) - I have no idea why. I used software serial ( and modified NexConfig.h file:


 * Define nexSerial for communicate with Nextion touch panel.
#include <SoftwareSerial.h>
extern SoftwareSerial HMISerial;
#define nexSerial HMISerial
//#define nexSerial Serial1

 and here is modified example sketch CompButton.ino:


 * @example CompButton.ino
 * @par How to Use
 * Show how to use API of class NexButton.  
 * @author  Wu Pengfei (email:<>)
 * @date    2015/7/10
 * @copyright 
 * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.

#include <SoftwareSerial.h>
#include "Nextion.h"

SoftwareSerial HMISerial(4, 5); // D1-yellow,D2-blue

NexButton b0 = NexButton(0, 1, "b0");

char buffer[100] = {0};

NexTouch *nex_listen_list[] = 

void b0PopCallback(void *ptr)
    uint16_t len;
    uint16_t number;
    NexButton *btn = (NexButton *)ptr;
    memset(buffer, 0, sizeof(buffer));
    btn->getText(buffer, sizeof(buffer));
    number = atoi(buffer);
    number += 1;

    memset(buffer, 0, sizeof(buffer));
    itoa(number, buffer, 10);

void setup(void)
    b0.attachPop(b0PopCallback, &b0);
    dbSerialPrintln("setup done"); 

void loop(void)

I hope that my experience will save someone against going-gray hair :)

How an MCU handles hardware or software serial is NOT a Nextion bug.

But the user should dig into the documentation of their MCUs.

The 8266 and 8285 chips have 2 Hardware serial ports on board.

- it is true that RX of one is typically used for SPI flash on the 8266.

But this definitely leaves a hardware serial port free

Software Serial is never as good as Hardware, I'd recommend Hardware

but the ESP may certainly have enough brute force to push through.

Bug Report is not the place for this.

Recommending a library like bborncr is also not proper.

- this is an unsupported piece of code the users used to make a demo.

- the authors do not support it, or update as Nextion changed.

I have removed the link to it for this reason: it causes more issues than it solves.

Can I add to this thread, to save any confusion for other users of ESP8266 who are trying to configure working connections to a Nextion.

ESP8266 has 2 hardware Serial TX ports, they are commonly named Serial and Serial1 when referring to then in typical C++ source code. You can connect to Nextions RX port from either of these ports.

However there is no corresponding RX port for Serial1, so if you wish to make a Nextion connection with Serial1 TX and Serial RX, your library, or indeed custom code has to accommodate for this. Trying to read a non-existent Serial1 RX for now obvious reason, will not work :)

I can confirm that setups using Serial1 TX, paired to Serial RX, do work properly as long as both Serial.begin() and Serial1.begin() are called properly along with matching baud rates of your choice. I have used such setups successfully in several ESP<>Nextion projects.    


So to confirm

  When using Serial1 TX and Serial RX paired

  Serial1.print and ... but not  Serial.print and

I think you also offered a solution in an UNO thread that went with

   using SoftwareSerial for debug, but hardware serial for the Nextion

   that way, when project is ready and debug no longer needed

   Nextion is still using the hardware port in a completed project


Yes that is correct. And yes indeed SoftwareSerial, can be a useful debug tool just as you state.

Again I have used it in similar configurations, and confirm it works right up to 115200 baud on an ESP, even as a Nextion connection.


Can you provide working sample of working sketch with Serial and Serial1? I'd like to check why this won't work for me. I tried, of course, with the same baud rate on both serial ports but without success.

Reminder that coding questions are Free Chat.

@Grzegorz Fitrzyk

Please try the demo I have posted for you in this link

Login or Signup to post a comment