Start a new topic

Initialization problem on a ESP8266 based arduino (WeMos D1)


I have a D1 (an ESP8266 based arduino compatible board) and a Nextion HMI.

Nextion HMI have a multipage setup and works perfectly BUT 

If I boot Nextion at the same time with my Wemos D1, system does not work.

Manual workarounds are :

Unplug Grnd or RX of Nextion connections (TX on the arduino board) (1 of 4 in both cases) until you get IP, replug the connections, everythings works perfect.

Software workarounds were to change the order of  nexInit() with WiFi.begin (or ESP related functions), WiFi is connected but Nextion fails or Nextion initiates good or WiFi fails.

I know how to use NexConfig.h (Serial assignments and debug and so on). 

I also know that Arduino Uno based replica boards lack a lot on Tx/Rx comms,

after all my experience, trial and error, modify lib code, nothing worked. I could not make it work to boot nextion and a ESP8266 board at the same time. (If ESP works fine, nextion does not work, if Nextion [should] work fine, ESP does not work)

I know that it is a matter of TX pin on the arduino design but I`m stuck.

Any help is HIGHLY appreciated.

Thank you

Hi Kivanc,

Would the command: com_star can help you.

greeting Vic

Hi Vic,

After throwing out everything for 5 days, I returned back to my problem.

I`ve tried multiple com_star, code_c, com_stop combinations. And it didn`t work.

It is most probably because of : com_stop does not really stop communication with the microcontroller. It just stops executing serial commands and stores them in buffer.

I think there is a board design / firmware problem that causes the conflict. The firmware should initialice Nextion better.

Will now switch to NodeMCU. If I can solve the D1 problem, I`ll inform you here.

thanks for reply, 

greetings 2K

Thx :-)

Hi Vic, 

Finally the problem is solved.

The trick is to use Serial.swap() , which is included in ESP8266 Arduino library.

Another trick is to use Wemos D1 pins D7 and D10 (!!!! Not D9) as 

Wemos D1 mcu D7 pin -> Nextion TX

Wemos D1 mcu D10 pin -> Nextion RX

Wemos D1 pinout is at

and Serial.swap() function is in

Be careful when to use Serial.swap() . I used mine at the end of setup(){} , after Wifi init and nexInit().

Also keep in mind to check your code to care of the buffer.

As you can see in NexHardware.cpp, it sends commands during nexInit() and read about bkcmd in Nextion Instruction Set :

Any bad values or unwanted execution concerning serial buffer, your execution order may get affected so simplify your test code before trying Serial.swap().

Now will try the solution at NodeMCU because same thing happened in NodeMCU also. Hopefully this time I won`t get bugged at pins.

greetings 2K

2 people like this

NodeMCU works exactly the same way too.

Pins are D7, D8 on NodeMCU (gpio13 and gpio15)

1 person likes this

Thx :-)  Thx :-)

Hello friends I'm new to developing with esp8266, I'm trying to connect both an RFID reader rc522 and screen nextion 2.4 "in a NodeMCU 1.0, using arduino IDE v 1.6.11 to read an RFID tag and display the UID in Nextion 2.4 screen ".

I managed to connect and work with each separately, but I can not make them work together.

when the connections operate separately in NodeMCU v 1.0 are the following:

Nextion 2.4 "||| MCU Node 1.0

5V-------------- 5V
RX ------------ (D7) - GPIO13 - RXD2 - HMOSI
TX ------------ (D8) - GPIO15 - TXD2 - HCS
GND ----------GND

RC522 ||| MCU Node 1.0

3.3V------ 3.3V
RST ------ (D2) - GPIO4
GND------- GND 
IRQ -----
MISO -------(D6) - GPIO12 - HMISO
MOSI -------(D7) - GPIO13 - RXD2 - HMOSI
SCK --------(D5) - GPIO14 - HSCLK
SS ----------(D4) - GPIO2 - TXD1

Both devices need to use the pin D7 (RXD2), I would like to use both at the same time, I read that I use UART but do not understand how to apply.

any help is welcome
thank you very much

I can not go deep into this question with you on NodeMCU

UART is serial over an RX/TX pair as you have successfully applied when connecting with the Nextion.

It appears if you are using MISO MOSI SCK in the RC522, that one is using SPI communications.

I am not certain if it is possible for you to create either a software serial or software SPI such that you don't have a pin out conflict using unused gpio pins. Perhaps keep the RC522 on the SPI as you already have it configured, and move your RX/TX for the Nextion to utilize your software serial on two unused gpio pins.  I certainly do not have any code to assist you with it at this time, but perhaps exploring this direction will lead you to your solution.

Hi Patrick

thank you very much for your answer, it is a good clue!

I'll try and write again my results

Greetings and thank you very much

Hello Patrick I'm trying to connect NodeMCU + RC522 (spi) + Nextion Display, but I have no success ....the rx / tx pins on the motherboard do not match (1/3), tx / rx works well in gpio 13 / gpio 15, but gpio13 is necessary to rc522.

You have any idea to solve this problem?I tried to swap () to exchange the GPIO1 / GPIO3 (tx / rx) pins, I flashed NodeMCU, to verify that the pins are accurate. but I have no results.

thanks for your help and good workregards

Perhaps try SoftwareSerial from the Arduino library.  I know that another user is having great successes with ESP-8266 using the SoftwareSerial.  I haven't had as much time to play with my modules as of yet (ESP-8285)

Hi Patrick, I'm using serial software, I have my display nextion 2.4 connected to tx, rx (gpio 1.3), but I can not display text on the screen.

part of my code, I connected on pins rc522



D1 (SS)

D2 (RST)

D5 (SCK)



SoftwareSerial nextion (1.3); // Nextion TX and RX

Nextion myNextion (nextion, 115200);

void setup () {

   myNextion.init ();

   Serial.begin (115200);

   SPI.begin (); // Init SPI bus



I have not managed to send message to my screen using the pin 1/3.

you know if it is possible to do this?

I am attentive

thank you very much for your suggestion


Perhaps see this link

to get some ideas from how indev2 is configuring his serial and handling his code.

At this point, without getting more time on my modules, I don't have code to offer.

(Also my modules pin out differently begin the ESP-8285)

thank you very much for your valuable help;) will try again and write the results


Login or Signup to post a comment