Issue with UART on BLE Nano 2 with MH-Z16


#1

Hello, I’m trying to connect to a MH-Z16 sensor using UART. The sensor is running on an external 5V power supply and the Nano is powered by the DAPLink. This is how I setup RX and TX.

Serial.begin(9600);

pinMode(D0, INPUT);
pinMode(D1, OUTPUT);

I send the measuring command to the sensor like this:

uint8_t cmd_measure[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79};
for (uint8_t i=0;i<9;i++) {
   Serial.write(cmd_measure[i]);
}

But when I check Serial.available() it is false. Looking forward to your help!


#2

Hi @wasserglas,

I’m afraid that the UART pins being also connecting with DAPLink will influence the communication between BLE Nano2 and the MH-Z16.

Please try disconnecting the UART connection between Nano 2 and the DAPLink and make sure the GND of the Nano 2 and MH-Z16 are connected as well.

Best regards,
Guohui


#3

Connecting the sensor’s power directly to the nano instead of an external power source fixed the issue.