title: SoftwareSerial example not working as expected
body: <p>I recently bought an Arduino UNO to read the data outputted by my Smart Meter. The meter uses serial communication and I would like to see the values being outputted on my laptop screen. I figured I would need to use the SoftwareSerial library to read the incoming data and print that data on my screen using the hardware serial and the Serial Monitor in the Arduino IDE. To become familiar with (software) serial communication on the Arduino, I reviewed the documentation of the SoftwareSerial library. Problem is, I can't get the most basic example to work and I have been stuck on this for quite a while now. The example code is below, the example <a href="https://www.arduino.cc/en/Tutorial/SoftwareSerialExample" rel="nofollow noreferrer">can be found here</a></p>
  
  <pre><code>#include &lt;SoftwareSerial.h&gt;
  
  SoftwareSerial mySerial(10, 11); // RX, TX
  
  void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(57600);
    while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only
    }
  
  
    Serial.println("Goodnight moon!");
  
    // set the data rate for the SoftwareSerial port
    mySerial.begin(4800);
    mySerial.println("Hello, world?");
  }
  
  void loop() { // run over and over
    if (mySerial.available()) {
      Serial.write(mySerial.read());
    }
    if (Serial.available()) {
      mySerial.write(Serial.read());
    }
  }
  </code></pre>
  
  <p>As far as I understand this, the following should happen:
  - Type text in Serial Monitor window.
  - <code>Serial.read()</code> reads this data and writes it to the Software Serial.
  - The Software Serial reads this data and writes it back to Serial.
  - That which was written appears on the screen.</p>
  
  <p>But whatever I try, nothing happens. Among things I tried to following:
  - Change the baud rate for both software and hardware serial (9600 for instance).
  - Tried a different SoftwareSerial library (AltSoftSerial).
  - Tried different RX and TX pins for SoftwareSerial.
  - Instead of <code>Serial.write(mySerial.read());</code>, store the result in a <code>char</code> first.</p>
  
  <p>I'm probably missing something obvious. I would be grateful to anyone who could shed some light on this or offer an alternative way for me to read the data from my Smart Meter.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I had no wiring, because the example specified "There is no circuit for this example". I tried all three options suggested by @slash-dev, but none had the expected behaviour:</p>
  
  <p><code>SoftwareSerial</code> with wires connecting pin 1 to pin 10 and pin 0 to pin 11. It prints strange characters:</p>
  
  <pre><code>Goodnight moon!
  Ùniÿhtÿmoÿn!ÿ
  nihtmoÿttt
  </code></pre>
  
  <p><code>AltSoftSerial</code> with wires connecting 1-8 and 0-9. First prints <code>Goodnight moon!</code> and then it keeps printing <code>Ôë‹¹¥�¡Ñ�moon!</code>.</p>
  
  <p><code>NeoSWSerial</code> with wires connecting 1-10 and 0-11. Same as <code>AltSoftSerial</code> but keeps printing <code>Ôë‹–+ë¡Ñ�j½½¹…j</code>.</p>