I'm trying to connect my NodeMCU to wifi. It isn't finishing because software serial is interrupting it.

Sort of like Software serial conflict with WiFi on ESP8266.

Here's my code:

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

const char* ssid     = "mywifi";
const char* password = "password123";

void setup() {


        SoftwareSerial pinSerial(1, 3);

void loop() {
    // send data received from serial port

// in separate function so I can reconnect in the loop 
bool connectWifi() {
        WiFi.begin(ssid, password);
        while (WiFi.status() != WL_CONNECTED) {
        Serial.println("WiFi connected");
        if( WiFi.status() == WL_CONNECTED) {
                return true;
        } else {
                Serial.println("wifi connection failed");

The console outputs the periods as it's connecting but never prints the IP and instead prints the serial data it received while trying to connect.

Can I delay the activation of the software serial port? Should I use another serial library?

Please don't focus on basic code errors, I'm still learning.

  • you start SoftwareSerial on pins of the hardware serial. – Juraj May 17 at 9:02
  • oh you're right! how do I read and write to the hardware pins, not the usb port? – thunder May 17 at 15:47
  • the USB chip of NodeMcu is wired to pins io 1 and io 3 of the esp8266 and you write and read it over Serial – Juraj May 17 at 18:26
  • SoftwareSerial pinSerial(1, 3); in setup() is strange as it 1) uses the hardware serial pins, 2) is never used other than begin(), and 3) is destructed when returning. What are you trying to do exactly? – Mikael Patel May 18 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.