MH-Z19 not working with Arduino Uno R3 and ESP8266



  • Hi,

    I want to get the CO2 value from my MH-Z19 sensor. According to datasheet, the sensor need 5V (not 3.3V), but when I used the 5V of Arduino, the card disconnect. while using ESP8266, there is a smell like something is burning. I am connecting both card via USB port to visualize the output:
    for Arduino: pin A0--> TX, pin A1-->RX, GND --> GND, 5V-->Vin , pin 10 (for PWM)
    for ESP8266: pin D0-->TX, pin D1 --> RX, GND-->GND, 5V-->Vin, pin D4 (for PWM)



  • @nearby-satoripop said in MH-Z19 not working with Arduino Uno R3 and ESP8266:

    Hi,

    I want to get the CO2 value from my MH-Z19 sensor. According to datasheet, the sensor need 5V (not 3.3V), but when I used the 5V of Arduino, the card disconnect. while using ESP8266, there is a smell like something is burning. I am connecting both card via USB port to visualize the output:
    for Arduino: pin A0--> TX, pin A1-->RX, GND --> GND, 5V-->Vin , pin 10 (for PWM)
    for ESP8266: pin D0-->TX, pin D1 --> RX, GND-->GND, 5V-->Vin, pin D4 (for PWM)

    Let's leave esp8266 for now.
    Firstly, PWM requires 3.3V. For now just forget it.
    (or try to use 3.3V Arduino pro mini or something)

    Connect the sensor as follows to the Uno:
    TX/RX to A0/A1, VIN to 5V, Gnd to Gnd. That's it.

    and this is the sketch:

    #include <SoftwareSerial.h>;
    
    SoftwareSerial mySerial(A0, A1); // A0 - к TX сенсора, A1 - к RX
    
    byte cmd[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79}; 
    unsigned char response[9];
    
    void setup() {
      Serial.begin(9600);
      mySerial.begin(9600);
    }
    
    void loop() 
    {
      mySerial.write(cmd, 9);
      memset(response, 0, 9);
      mySerial.readBytes(response, 9);
      int i;
      byte crc = 0;
      for (i = 1; i < 8; i++) crc+=response[i];
      crc = 255 - crc;
      crc++;
    
      if ( !(response[0] == 0xFF && response[1] == 0x86 && response[8] == crc) ) {
        Serial.println("CRC error: " + String(crc) + " / "+ String(response[8]));
      } else {
        unsigned int responseHigh = (unsigned int) response[2];
        unsigned int responseLow = (unsigned int) response[3];
        unsigned int ppm = (256*responseHigh) + responseLow;
        Serial.println(ppm);
      }
      delay(10000);
    }
    


  • hi
    what could be the A0 and A1 pins on wemos d1?
    i can only see A0 and D0, which are even on the opposite sides...
    and if i use some arduino apps via IDE, then what could be the Pin number of the A0 on the wemos board?
    its just way too weird that i cant get any information about this even from their own website....:
    https://wiki.wemos.cc/products:d1:d1
    or can i actually use the JP connectors somehow via the built-in usb to ttl adapter function ? (by connecting the reset and ground?)
    https://wiki.wemos.cc/_media/products:d1:d1_v2.0.0.pdf
    and is A1 below A0 then and i should connect the sensor(mhz14a) pins in there?
    and would the z19 code work with z14a sensor too?

    and of course.... what pins should i use on the sensor itself? like there seems to be atleast 3 different pin sets for rx+tx+gnd+v, and each of them have a different amount of double pins? like the 1-12 pin set has 3 ground pins and the 13-19 pin set has 2 Vin pins and also 2 rx and tx pins?:
    http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z14a_co2-manual-v1_01.pdf
    so which ones should i use when i dont want to use the small Uart(ttl?) port and its thin wires...



  • so.. the main question here is.... do i need the wemos board in the Tristate/TTLadapter mode at all?
    and this page here gives 3,3volts to the sensor?
    https://www.14core.com/wiring-the-nondispersive-infrared-mh-z14-carbon-dioxide-gas-sensor-on-microcontroller/
    and i basically soldered some connectors to the same exact pins.
    but is the code for arduino ide at all? and if it is, then i basically do not need to use the Tristate/TTLadapter mode at all?
    ....
    and the wiring guide and sensor schematics images do not match at all on that page ????????
    so what the heck do i need to do to get some readings out of it......................



  • so maybe pins 13-19 are 3,3 volts on the z14 and pins 1-12 are 5volts?


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 1
  • 10
  • 2
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts