0

This is my first project with any sort of development board and it has been a blast so far.

I am running into some issues, however, while trying to send serial data from my Uno to a NodeMCU board.

I have the following connections:

Uno Rx to NMcu Tx

Uno Tx to NMcu Rx

Uno GND to NMcu GND

microUSB from computer to power NMcu

usb from computer to power Uno

EDIT: after some suggestions, I have also tried the following.

Uno DigitalPin 5 to NMcu D6

Uno DigitalPin 6 to NMcu D5

Uno GND to NMcu GND

microUSB from computer to power NMcu

usb from computer to power Uno

With the following code:

// UNO sender Code
#include <SoftwareSerial.h>
SoftwareSerial toESP(0, 1); //Rx, Tx (also tried 5,6)

void setup()
{
  Serial.begin(115200);
  toESP.begin(9600);
}

void loop()
{
  Serial.println("sending");
  toESP.println("message from Nano");
  delay(1000);
}

// NodeMCU receiver code
#include <SoftwareSerial.h>
SoftwareSerial fromNano(3, 2); //Rx, Tx (also tried D5, D6)

void setup()
{
  Serial.begin(115200);
  fromNano.begin(9600);
}

void loop()
{
  if (fromNano.available())
  {
    char inChar = fromNano.read();
    Serial.print(inChar);
  }
  else {
    Serial.println("not available");
  }
  delay(2000);
}

I can pull up a serial monitor from both and see the UNO sending data (the TX led also blinks on the uno).

The NodeMCU code never satisfies the fromNano.available condition.

Is there anything I am overlooking that is causing this not to work? I've attached a picture of my connections as well.

enter image description here

Any help is much appreciated.

3
  • 0 and 1 are hardware Serial pins in Uno and 3 is a hardware Serial pin on NodeMcu so you should not use it for SoftwareSerial. and the wires are on pins 1 and 3 on NodeMcu (hardware Serial pins)
    – Juraj
    Dec 2, 2019 at 18:43
  • Hmm, thanks for the response. I tried using other digital pins on the arduino and nodemcu (and made sure to update the corresponding code) the other night, but didn't have any luck. I tried something like SoftwareSerial(5,6) for the sender (arduino) and SoftwareSerial(D5,D6) for the receiver (nodeMCU). Making sure that arduino digital pin 5 is connected to nodemcu D6, and vice versa. I'll try again later tonight.
    – Lamar
    Dec 2, 2019 at 18:57
  • @Juraj - After trying on digital pins 5,6 on the arduino, and D5,D6 on the nodemcu, I still cannot receive serial data. fromNano.available() is always false. I've set both to 9600 baud rate. imgur.com/a/gfVo2nt
    – Lamar
    Dec 2, 2019 at 22:38

2 Answers 2

2

Arduino UNO is using pin 0 and pin 1 to have serial with USB serial Communication. You can not use them to softserial. Change softserial to other pins. /Mikael

7
  • Thanks for the comment. Is it fine to just use any other digital pins to initialize the SoftwareSerial?
    – Lamar
    Dec 1, 2019 at 2:24
  • I tried digital pins 2 and 3 (and also 5,6) for RX,TX respectively and it didn't seem to solve the issue. Thank you for the suggestion though.
    – Lamar
    Dec 1, 2019 at 2:30
  • Why do use 2 serial conections, you only need one.
    – Carlmikael
    Dec 1, 2019 at 2:38
  • I'm only using one serial connection between the boards from my understanding. I just tried on pairs (2,3) and (5,6) independently for troubleshooting.
    – Lamar
    Dec 1, 2019 at 2:40
  • In the code you are using two.
    – Carlmikael
    Dec 1, 2019 at 3:02
0

@Carlmikael is definitely correct in his answer, I should not have been using hardware pins with softwareserial.

Besides that problem, my issue was resolved ultimately when I noticed that if I powered up the NodeMCU before powering up the Arduino, everything worked as expected.

Maybe someone can elaborate as to why this caused an issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.