user65366: I'm trying to read data from MH-Z19B sensor to NodeMCU v2 board with a simple circuit like this.

Some key points, which could be not that obvious from picture:
 - sensor has separate power supply of 4 AAs, providing ~5,5V
 - sensor's TX connected to GPIO15 (TX D2) of NodeMCU
 - sensor's RX connected to GPIO13 (RX D2) of NodeMCU    
And here is my sketch:
const byte readCommand[] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; // according to datasheet
unsigned char response[9];

void setup() {
  // according to datasheet, sensor uses 9600 baud, 8 databits and 1 stopbit
  // with parity NONE, which I believe corresponds to default config SERIAL_8N1 
  Serial.begin(9600);
}

void loop() {

    //  ... check if it is time to measure

    Serial.swap(); // switch to sensor

    Serial.write(readCommand, sizeof(readCommand));

    memset(response, 0, sizeof(response));

    int attempts = 5;
    int available = Serial.available();
    while(available < sizeof(response) && attempts > 0) {
        delay(100);
        attempts--;
        available = Serial.available();
    }

    Serial.readBytes(response, sizeof(response));

    Serial.swap(); // switch back to console

    // print out the response in hex
    for (int i = 0; i < sizeof(response); i++) {
      Serial.print(String(response[i], HEX));
      Serial.print("   ");
    }

    // ...process the response according to protocol
}


The Problem
For some reason after sending command to serial I get an answer exactly the same as command is although the structure of answer expected to be different. Of course datasheet says nothing about situations like this.
Expectation  
ff 86 .. .. 0 0 0 0 CRC

Reality (same bytes I sent as a command)
ff   1   86   0   0   0   0   0   79 

Other notes:
 - I got exactly the same when tried to use SoftwareSerial with D1 & D2 pins
 - connecting TX to RX respectively on both sensor and MCU results in reading failure
 - I tried to pull everything while available from serial, there are only my expected 9 bytes
 - my soldering skills are far from ideal, but I'm pretty sure tx/rx on the sensor are connected properly
I'm new to all this stuff, so it is completely possible that there is ridiculously silly, but crucial mistake, so would appreciate any help on this. And I understand that sensor also has additional interfaces to obtain the value, but as I mentioned I'm a newbie and wanted to familiarize myself with UART as this is something new for me.
UPD 1:
I didn't use level conversion for sensor output as datasheet says:

Assuming this I thought that sensor provides logical level conversion itself. Did I get it wrong?
UPD 2:
I got back to proper TX - RX connection just to check out what is going on exactly to describe that "reading failure" problem with more details. It seems that Serial.available() returns 0 after I send command so this loop gets stopped after 5 attempts:
while(available < sizeof(response) && attempts > 0)


user33871: It says in your description that you have the Rx connected to Rx and the Tx connected to Tx.  That's backwards.  What one transmits the other needs to receive.  When you have a conversation with someone, do you talk into their mouth and listen to their ears?  You should have Rx-Tx and Tx-Rx.  
You also need to be sure that it is OK to feed a 5V Tx into that Rx pin.  On some ESP8266 boards it is and on most it isn't.  If you don't have one of the boards that specifically has circuitry built in to handle 5V inputs then you will fry your NodeMCU

65366: <p>I'm trying to read data from MH-Z19B sensor to NodeMCU v2 board with a simple circuit like this.</p>

<p><a href="https://i.stack.imgur.com/42cKt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/42cKt.jpg" alt="enter image description here"></a></p>

<p>Some key points, which could be not that obvious from picture:<br>
 - sensor has separate power supply of 4 AAs, providing ~5,5V<br>
 - sensor's TX connected to GPIO15 (TX D2) of NodeMCU<br>
 - sensor's RX connected to GPIO13 (RX D2) of NodeMCU    </p>

<p>And here is my sketch:</p>

<pre><code>const byte readCommand[] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; // according to datasheet
unsigned char response[9];

void setup() {
  // according to datasheet, sensor uses 9600 baud, 8 databits and 1 stopbit
  // with parity NONE, which I believe corresponds to default config SERIAL_8N1 
  Serial.begin(9600);
}

void loop() {

    //  ... check if it is time to measure

    Serial.swap(); // switch to sensor

    Serial.write(readCommand, sizeof(readCommand));

    memset(response, 0, sizeof(response));

    int attempts = 5;
    int available = Serial.available();
    while(available &lt; sizeof(response) &amp;&amp; attempts &gt; 0) {
        delay(100);
        attempts--;
        available = Serial.available();
    }

    Serial.readBytes(response, sizeof(response));

    Serial.swap(); // switch back to console

    // print out the response in hex
    for (int i = 0; i &lt; sizeof(response); i++) {
      Serial.print(String(response[i], HEX));
      Serial.print("   ");
    }

    // ...process the response according to protocol
}

</code></pre>

<p><strong>The Problem</strong></p>

<p>For some reason after sending command to serial I get an answer exactly the same as command is although the structure of answer expected to be different. Of course datasheet says nothing about situations like this.<br>
Expectation  </p>

<pre><code>ff 86 .. .. 0 0 0 0 CRC
</code></pre>

<p>Reality (same bytes I sent as a command)</p>

<pre><code>ff   1   86   0   0   0   0   0   79 
</code></pre>

<p>Other notes:<br>
 - I got exactly the same when tried to use <code>SoftwareSerial</code> with D1 &amp; D2 pins<br>
 - connecting TX to RX respectively on both sensor and MCU results in reading failure<br>
 - I tried to pull everything while available from serial, there are only my expected 9 bytes<br>
 - my soldering skills are far from ideal, but I'm pretty sure tx/rx on the sensor are connected properly</p>

<p>I'm new to all this stuff, so it is completely possible that there is ridiculously silly, but crucial mistake, so would appreciate any help on this. And I understand that sensor also has additional interfaces to obtain the value, but as I mentioned I'm a newbie and wanted to familiarize myself with UART as this is something new for me.</p>

<p><strong>UPD 1</strong>:<br>
I didn't use level conversion for sensor output as datasheet says:<br>
<a href="https://i.stack.imgur.com/qoP7I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qoP7I.png" alt="enter image description here"></a><br>
Assuming this I thought that sensor provides logical level conversion itself. Did I get it wrong?</p>

<p><strong>UPD 2</strong>:<br>
I got back to proper TX - RX connection just to check out what is going on exactly to describe that "reading failure" problem with more details. It seems that <code>Serial.available()</code> returns 0 after I send command so this loop gets stopped after 5 attempts:</p>

<pre><code>while(available &lt; sizeof(response) &amp;&amp; attempts &gt; 0)
</code></pre>
 33871: <p>It says in your description that you have the Rx connected to Rx and the Tx connected to Tx.  That's backwards.  What one transmits the other needs to receive.  When you have a conversation with someone, do you talk into their mouth and listen to their ears?  You should have Rx-Tx and Tx-Rx.  </p>

<p>You also need to be sure that it is OK to feed a 5V Tx into that Rx pin.  On some ESP8266 boards it is and on most it isn't.  If you don't have one of the boards that specifically has circuitry built in to handle 5V inputs then you will fry your NodeMCU</p>
