1

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() {
 Serial.begin(9600);
 Serial.println("");
 connectWifi();
 SoftwareSerial pinSerial(1, 3);
 pinSerial.begin(9600);
}
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) {
 delay(500);
 Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");
 Serial.println(WiFi.localIP());
 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.

asked May 17, 2019 at 5:28
4
  • you start SoftwareSerial on pins of the hardware serial. Commented May 17, 2019 at 9:02
  • oh you're right! how do I read and write to the hardware pins, not the usb port? Commented May 17, 2019 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 Commented May 17, 2019 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? Commented May 18, 2019 at 14:57

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.