SoftwareSerial not sending data

I was testing the SoftwareSerial library (Built-in ver.1.0.0) connecting Uno with an ESP8266 board. I was able to confirm data reception from ESP but it looked Uno was not sending data. Off course I put logic level converter between TX (Uno) and RX (ESP).

To confirm the issue, I isolated Uno board and connected TX pin (D11) to digital input (D2) to monitor TX line. The following code writes an incremental byte to the software serial port every second. However, the monitor input constantly shows HIGH level. I also assigned TX to different pins but the result was same.

include <SoftwareSerial.h>


SoftwareSerial mySerial(10, 11);  //RX,TX
unsigned long ms;
byte data = 0;


void setup() {
  mySerial.begin(1200);  
  Serial.begin(115200);
  while(!Serial);
  pinMode(2, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  ms = millis();
}


void loop() {
  Serial.println(digitalRead(2));    
  if (millis() - ms > 1000)
  {
    mySerial.write(data++);
    digitalWrite(LED_BUILTIN, data%2);
    ms = millis();
  }
}

To confirm the issue, I isolated Uno board and connected TX pin (D11) to digital input (D2) to monitor TX line.

Sure, above code will never see any change as the bits are sent inside an interrupt, so loop() code will not see any level change.

Connect the output pin to a scope or logic analyzer and report results.

If you don't have access to such a device, post a wiring diagram of your setup with the ESP and post the code you use in that setup.

Software Serial was not invented last year nor the last decade. It was invented in the last century, you could even say in the last millennium.

Unless you have a business plan that saves you a lot of money by using this old Arduino Uno (not likely), get yourself a modern microcontroller with some hardware peripherals. This is your hobby you deserve some fun. :slight_smile:

Have a look at the Arduino Nano 33 IoT. Cheaper than an Uno and WiFi build in. And there are plenty of other options you can use with your ESP8266.

You connect everything and the project starts working -- have you gained anything as a learner? Let the project be no-functional; as a result, the poster will have the opportunity trying various options in the search of finding the fault.

The following setup worked for me even without the use of level sifters. Do you want codes?

uartespUNO-2.png

uartespUNO-2.png