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.
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
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?
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?