Close

Wemos test with DHT and MQ9

A project log for Wearable CO monitor

A wearable CO monitor that uses an ESP8266

rahoon-goawayRahoon GOAWAY 01/26/2019 at 09:060 Comments

I used a simple test code to test the Wemos with the DHT and the MQ9.

An Arduino Uno is used to power the MQ9 at 1.5V with a voltage divider on the 5V pin. Another voltage divider cuts the MQ9's output voltage into 2/3 its original to  avoid damaging the ADC of the Wemos.

Circuit:

Code:

#include "DHTesp.h"


DHTesp dht;

void setup()
{
  Serial.begin(115200);
  Serial.println();
  
  dht.setup(12, DHTesp::DHT11);   // Connect DHT sensor to GPIO 17
}

void loop()
{
  delay(500);

  float humidity = dht.getHumidity();
  float temperature = dht.getTemperature();

 
  Serial.print(humidity, 1);
  Serial.print("\t\t");
  Serial.print(temperature, 1);
  Serial.print("\t\t");
  Serial.println(analogRead(A0));
 
}

Discussions