DHT 11 sensor interfering with other sensors

DHT 11 sensor I use cause my MQ3 sensor to spike. So I tried a few tests, it seems every time the arduino does the:
dht.readHumidity();
dht.readTemperature();

My MQ3 signal spikes.
So if I change the frequency these two lines happen, the spike would change to those frequencies.

If I remove these two lines from happening or simply pull out the wire for the DHT 11 sensor (return nan), the spike stop.

Don't know why it happens. I mean I could just make the MQ sensor skip those readings, but I want to know why.

Hi, @abcp0i
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Can you post your code?

A copy of your circuit diagram would also be of assistance.

Thanks. Tom... :grinning: :+1: :coffee: :australia:

I tried to only run these two so here is the code. basically only dht and mq3 .
If I run it at a low enough frequency (like 2 sec) then the spike won't happen. That seems (pure guess) like to be the refresh rate of the dht sensor.

#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

}

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.... :grinning: :+1: :coffee: :australia:

The button part is just a part of the code that I didn't delete when I copy some lines of code for testing. It shouldn't have anything to do with the sensors?

Hi,

How are you powering your project especially the MQ3?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

with the Arduino 5V supply, both connected to the power rail of a breadboard.

My guess is that it is the way you have wired the sensors to the Arduino.

Do you have a single wire from an Arduino GND pin that goes to both sensors?

If so there will be a voltage drop across that wire that will change when the digital sensor is commanded to take a reading (and draw a higher current than in it's standby condition).
This will cause the voltage on the GND pin of the MQ3 to rise by a few millivolts. The output of the MQ3 will rise by the same amount. It is this raised output voltage that the Arduino sees as a "spike".

You need to run two separate GND wires from the Arduino, one going to each sensor.

I think you answered my question whilst I was writing my reply - you have a single wire from the Arduino GND pin to the breadboard, with both sensors connected, on the breadboard to that wire.

There are usually several GND pins on an Arduino you could use a separate GND pin for each sensor.

Yea I believe that is it. Thank you, and do you mind if I ask:
so if I have more sensors on top of this, and they all read at the same frequency. Then the reading would not spike but the reads will be changed by a little bit. You can tell by now I have no clue whatsoever, so if this is true is this something you would just ignore because the offset is small?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.