Software Serial Library on NodeMCU 1.0 (ESP-12E)

Hey there,
I am using a NodeMCU 1.0 and want to connect a GPS-Module at Serial-Port (RX,TX) but at the same time use the USB-Connection to be able to upload new sketches (I am still editing a lot...) and to use a serial monitor on the PC for debugging output.
It seems to be impossible to use both, USB and TX/RX at the same time. As soon as I receive GPS-data they are outputted on my serial monitor on the PS but the output prints not anymore.
So I tried to use a software serial port for the GPS-module. Generally this works, but the Arduino <SoftwareSerial.h> library, which is also available for the NodeMCU (ESP8266), causes trouble with other things going on. In my case for example it causes problems with my Wifi connection.

Question #1:
Am i right, that USB and RX/TX are connected, so that only either USB or RX/TX can be used?

Question #2:
Are there alternative libraries for software serial connections on NodeMCU (ESP8266), which are more reliable? For Arduinos for example exists <NeoSWSerial.h>, but this doesn´t work on the NodeMCU.

Thanks!!

fauth:
Question #1:
Am i right, that USB and RX/TX are connected, so that only either USB or RX/TX can be used?

Correct. There's a work-around though.

fauth:
Question #2:
Are there alternative libraries for software serial connections on NodeMCU (ESP8266), which are more reliable? For Arduinos for example exists <NeoSWSerial.h>, but this doesn´t work on the NodeMCU.

Not that I know of.

However, you can use Serial.swap(). It swaps TX/RX to GPIO15/GPIO13. This means that you can connect your GPS module to these pins.
During programming, it uses TX/RX (GPIO1/GPIO3). These are connected to the USB connection.
When running your program, it uses TX/RX on pins GPIO15/GPIO13.

Alternatively, you could use OTA (over the air) updates. Meaning that you upload programs over WiFi instead of USB. I use it all the time, it's pretty fast and convenient.

To enable USB debugging in the swapped-serial configuration, you could use Serial1 (TX = GPIO2) and connect it to the USB connection by adding a 1 kΩ resistor between GPIO1 and GPIO2.

Pieter

Wow, that was easy! Thanks a lot, at least a minimal example without sensors and WIFI works!
Next problem now:

I wand to use SPI connection as well, but the pins are occupied now!

I would like to continue here:

I thought, if the USB port isn´t used anymore to print out debugging messages (no serial monitor open on the computer), the TX/RX pins can be used to connect to an GPS-module, even if the node NodeMCU is connected via USB for powersupply.
But they cant´t!?

But if I open the serial monitor on my computer, I can see the signal from the GPS modul I would like to read, printed out in the monitor. There isn´t any chance to read this signal with the ESP8266?

Neo6M GPS Modul from Ublox, connected TX --> TX and RX --> RX with the NodeMCU.

PieterP:
However, you can use Serial.swap(). It swaps TX/RX to GPIO15/GPIO13. This means that you can connect your GPS module to these pins.
During programming, it uses TX/RX (GPIO1/GPIO3). These are connected to the USB connection.
When running your program, it uses TX/RX on pins GPIO15/GPIO13.

Pieter

:slight_smile: A thousand thank yous Pieter! (And ++Karma)! :slight_smile:

I've just wasted a couple of hours trying to get software serial to work on an ESP8266 and was coming to the conclusion that it was a choice between serial and Wi-Fi, which kind of defeats the point of using an ESP8266 at all.