Softwareserial read

Hello here

I'm trying to read my smart electricity meter' p1 port with a nodemcu. I know it uses serial communication and found tutorials on internet, and based my code on that. It didn't work so cropped my code until there was only serial.read left, and there was the problem.

So this is my very basic code:

#include <SoftwareSerial.h>
#define SERIAL_RX     5 // pin for SoftwareSerial RX
SoftwareSerial mySerial(SERIAL_RX, -1, true); // (RX, TX. inverted, buffer)
void setup() {
  Serial.begin(115200);
  mySerial.begin(115200);
}
void loop() {
  Serial.write(mySerial.read());
}

and the output:

So the problem is that there are still 20 lines to come but it always turns into question marks.
Is it because my arduino can't follow or something?
Or does the serial monitor slow everything down? Can fix it by storing the char's temporary?

Think about what happens if there is no character ready for mySerial.read() when you use it.

Here's a tutorial:
https://www.arduino.cc/en/Tutorial/BuiltInExamples/SerialPassthrough

yeah tried an available method too, but then it's the same without question markst

#include <SoftwareSerial.h>
SoftwareSerial mySerial(5, -1, true); // (RX, TX. inverted, buffer)

void setup() {
  Serial.begin(115200);
  mySerial.begin(115200);

}

void loop() {
  if (mySerial.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(mySerial.read());   // read it and send it out Serial (USB)
  }
}

SoftwareSerial isn't very reliable at such high baud rates. If you must use 115200, you'll do better with an Arduino with another hardware UART.

You should have told us about that. I mean, in detail, not just "I cropped"..

sorry, but now you know :wink:
So there is no way to receive the data without special board?

Can you change the baud rate that the meter uses?

Why not use the hardware serial port on the NodeMCU?

euh no i can't change the baud range. And @anon57585045, how do I use that port?

Which NodeMCU do you have? There are many. Links or documents please...

I don't have documents, but it's nodemcu 1.0

How can you use it without any documents? How do you know which pins to connect to?

Is is this?:
https://www.google.com/search?client=firefox-b-d&q=nodemcu+1.0

google images :laughing:

You can paste images in the forum, it's the preferred method. Do you see RXD2 and TXD2 there?

yeah I see, I knew they were for serial communication. But how can I use them like I did with softwareserial?

By researching it, like everyone else does. You will find that the ESP core supports it as another serial device, like for example, 'Serial1'.

is it UART, like described here?

I don't believe you should require such elaboration. "Serial1" should be available, right out of the box. Go directly to the core documentation. Tutorials are fine but can lead you in wrong directions.
https://docs.espressif.com/projects/arduino-esp32/en/latest/
That one is for ESP32 but you should find ESP8266 somewhere around there...