Connecting M5Stack to an MQ-2 smoke/gas sensor



  • I am trying to port my ESP8266 project to M5Stack but for the life of me I could not figure out how to connect the wires between M5Stack and the analog MQ-2 gas sensor.

    This is my wiring for ESP8266 that perfectly works:

     MQ-2 Sensor    ->    ESP8266
         A0         ->      A0
         D0         ->      D0
         VCC        ->      VIN (5.5V)
         GRD        ->      GRD
    

    This is what I have tried in M5Stack but did not work. The sensor's D0 LED and power LED do not even lit on.

     MQ-2 Sensor    ->      M5Stack
         A0         ->        Pin 36 (I also have tried 35)
         D0         ->        Pin 21 (I also have tried 16)
         VCC        ->        5V
         GRD        ->        G
    

    How do I wire the analog MQ-2 sensor To M5Stack? Is it doable? Any guidance please?



  • @suntzu Hi Suntu,

    Try sourcing the 5V from the positive terminal on the Grove connector.



  • @JimiT I will try that when I get back home from the office. And I will make sure to keep you updated.

    Thank you so much, Jimi.



  • @jimit 在 Connecting M5Stack to an MQ-2 smoke/gas sensor 中说:

    @suntzu Hi Suntu,

    Try sourcing the 5V from the positive terminal on the Grove connector.

    It worked like a charm! Thank you again. It's time to rewrite my sketches for M5Stack.



  • @suntzu Glad to hear it worked !!!!

    And you used pins 36 and 21 ?

    Now I will have to order some of these MQ-2 sensors !! Thank you for the tip.

    If you are open to posting a link to your code or a screenshot when done, that would be interesting to see.



  • @JimiT Yes, I used Pin 36 and 21.

    Absolutely, I will post the finish product and pictures in the Projects section.



  • I am been able to read the ADC on pin 35. This corresponds to ADC1_CH7 BUT I cannot get ADC on pin 36 to work. I think this is ADC1-CH0. Anybody has any sample code ? Thanks.