Software Serial not recieving data

im using software serial for my nano and esp32 to communicate and send some data, for some reason i get 0 when checking for available bytes in the serial and i dont why that could be happening..

esp32 code

#define BUFFER_SIZE 32

#include "BluetoothSerial.h"
#include "SoftwareSerial.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run make menuconfig to and enable it
#endif

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;
SoftwareSerial shieldSerial(12, 13);// Rx then TX pins
BluetoothSerial SerialBT;

void setup() {
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
  Serial.begin(115200);
  shieldSerial.begin(9600);
  SerialBT.begin("Gesture2Speech");
}

void loop() {
  String data = "";
  recvWithEndMarker();
  showNewData();
  delay(500);
}

void recvWithEndMarker() {
    static byte ndx = 0;
    char endMarker = '\n';
    char rc;
    Serial.println(shieldSerial.available() > 0);
    while (shieldSerial.available() > 0 && newData == false) {
        rc = shieldSerial.read();
        if (rc != endMarker) {
            receivedChars[ndx] = rc;
            ndx++;
            if (ndx >= numChars) {
                ndx = numChars - 1;
            }
        }
        else {
            receivedChars[ndx] = '\0'; // terminate the string
            ndx = 0;
            newData = true;
        }
    }
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
        if (receivedChars != "") {
          SerialBT.println(receivedChars);
        }
    }
}

nano code

#include <SoftwareSerial.h>

SoftwareSerial SUART(2,3);

void setup() {
  Serial.begin(9600);
  SUART.begin(9600);
  pinMode(A0,INPUT_PULLUP);
}

void loop() {
  int _1 = map(analogRead(A0),0,1023,0,255);
  Serial.println(_1);
  SUART.print(String(_1));
  delay(100);
}


and heres the pin diagram of the esp32 im using, when i print out the data being recieved in the esp i get 0

how did you connect the 2 boards?
why do you use SoftwareSerial on the ESP32 ? it has multiple hardware UARTs

yeah i used hardware UART's now,but i get weird symbols when printing readString in serial2

Im using pin 16 and 17 now

post your codes using code tags and a picture of your circuit drawing including power supplies (and confirm Serial monitor settings)

esp

#include "BluetoothSerial.h"
#include "SoftwareSerial.h"
#include "HardwareSerial.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run make menuconfig to and enable it
#endif

void setup() {
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
  Serial.begin(115200);
  Serial2.begin(9600,SERIAL_8N1, 16,17);
  SerialBT.begin("Gesture2Speech");
}

void loop() {
  Serial.println(Serial2.readString());
  delay(500);
}

nano

#include <SoftwareSerial.h>

SoftwareSerial SUART(2,3);

void setup() {
  Serial.begin(9600);
  SUART.begin(9600);
  pinMode(A0,INPUT_PULLUP);
}

void loop() {
  int _1 = map(analogRead(A0),0,1023,0,255);
  Serial.println(_1);
  SUART.print(String(_1));
  delay(100);
}

the MCU's are connected to my pc

your ESP is a 3.3V device and your Nano is a 5V device. You need to adjust the voltage in between the two.

GNDs also need to be connected

how would i do the voltage adjusting part?

a couple of resistor or a voltage shifter circuit

see How to Level Shift 5V to 3.3V | Random Nerd Tutorials

huh, softwareSerial worked some time ago though :thinking:, thats why i didnt use the built-in UART's

softwareSerial is not very reliable. Don't use it if you have a hardware based UART

the level shifting as well as the GND interconnection is needed. if not you risk damaging the ESP's Rx pin by exposing it to 5V when the spec says to not go over 3.3V. It can possibly take a bit of abuse until it does not any more...

alr, but why does my esp have a 5V input?

because USB is providing 5V. There is a regulator on the board that transforms it into 3.3V which is needed for the ESP to work. But there is not voltage adaptor for the pins.