Hi,
If you read post #2 and its link, this how your code appears;
#include "DHT.h"
#define buttonPIN 3
#define MQ3PIN 3
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
float count = 0;
float timeinterval = .5;//in seconds
int buttonState = 0;
float MQ3reading;
void setup()
{
pinMode(buttonPIN, INPUT);
Serial.begin(9600);
dht.begin();
}
void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (buttonState == HIGH)
{
count = 0;
}
MQ3reading = analogRead(MQ3PIN);
Serial.print(count);
Serial.print(' ');
Serial.print(h);
Serial.print(' ');
Serial.print(t);
Serial.print(' ');
Serial.print(MQ3reading);
Serial.print('\n');
count = count + timeinterval;
delay(timeinterval * 1000); //interval
}
When do you read the button?
if (buttonState == HIGH)
{
count = 0;
}
How does this work?
A circuit diagram would be nice.
Tom....
![]()