How to use 2 serial ports or more in NodeMCU
I recently made a mini car, using GPS module and 433m wireless module.
Blynk recently added GPS capabilities to the app.
But the serial port does not seem to share, I hope to add a new serial port for GPS module.
This is a simple wiring diagram
Who can help me?
Try Google… since what you are asking has nothing to do with Blynk
EDIT - for example… https://github.com/esp8266/Arduino/blob/master/doc/reference.rst#serial
(There’s only one full UART on the NodeMCU. The second UART is transmit only. The pin labelling is confusing, but is designed to make sense if you use the serial.swap function.
In normal circumstances (without the swap), I think that Serial is pins GPIO1 and 3 and Serial1 (tx only) is pins GPIO2 and Ground.
When you’re using this setup, you shouldn have a computer plugged into the USB socket otherwise the serial port gets confused.
You could also try using software serial to give a full second serial port, but personally I’ve not had reliable results going down that route.
Don’t forget that you have to declare Serial and Serial1 seperatly and define both baud rates (which can be different).
Pete.
This is the method we use and it’s very reliable.
I was doing some stuff with a Nextion display connected by software serial to a Wemos and the display wasn’t as responsive as I’d expected. Switched to hardware serial and the problems disappeared.
I’d also had some issues with SoftwareSerial on an Arduino when using a Sim900. Switched to a Mega with an additional hardware serial and used that and once again the issues disappeared.
I’m sure lots of people have better success with SoftwareSerial, but that’s not been the case for me.
Pete.
@PeteKnight hardware serial will be better than software serial for MCU’s that have the extra ports but as you have pointed out ESP’s only have 1.5 ports.
Sorry, I thought Blynk wrote a virtual pin and wrote a virtual serial port as well
。
I was wrong, I also try Google search, such a problem encountered. His tips make a lot of sense
I will try to solve this problem. Because I’m not very demanding on the second serial port, maybe just sending is enough