DHT11 values fly off the rails when activating 8 relays

Hello everyone. My very 1st post here.

I have a small project with an Arduino Uno R3, soft 1.6.13, 1 push button, 1 DHT11 and a strip of 8 relays.

Everything works just fine. When I press the button, the 8 relays kick in. When I release, 8 relays go to sleep.

My only problem is with the DHT. When relays disengaged, temperatures are showing 20C and humidity at 19%. When I press the button and engage the relays, the temperature increases instantly to 24C and humidity to 30%.

The ultimate goal is to trigger more and more relay as the temperature rises… 1 relay per Deg Celsius. And as I see it, I have a 4 relay problem here…

I’ve tested with a series of IFs and by blowing on the DHT11, my breath can get the temperature high enough to trigger all relays. The thing is that when I let it cool slowly… Temperature ALWAYS goes like this: 30, 29, 28, 27 (1st relay shutting down), 26 (second relay), 22 (4 relays in a snap turn off), 21, 20… I never get the range 25, 24, 23… It puzzles me.

Here is my code:

#include <dht.h>

dht DHT;

#define DHT11_PIN 11
int relayPin1 = 2;                 // IN1 connected to digital pin 2
int relayPin2 = 3;                 // IN2 connected to digital pin 3
int relayPin3 = 4;                 // IN3 connected to digital pin 4
int relayPin4 = 5;                 // IN4 connected to digital pin 5
int relayPin5 = 6;                 // IN5 connected to digital pin 6
int relayPin6 = 7;                 // IN6 connected to digital pin 7
int relayPin7 = 8;                 // IN7 connected to digital pin 8
int relayPin8 = 9;                 // IN8 connected to digital pin 9

void setup() {
  // put your setup code here, to run once:
  pinMode(12, INPUT_PULLUP);
  Serial.begin(115200);
  pinMode(relayPin1, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin2, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin3, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin4, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin5, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin6, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin7, OUTPUT);      // sets the digital pin as output
  pinMode(relayPin8, OUTPUT);      // sets the digital pin as output
  digitalWrite(relayPin1, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin2, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin3, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin4, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin5, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin6, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin7, HIGH);        // Prevents relays from starting up engaged
  digitalWrite(relayPin8, HIGH);        // Prevents relays from starting up engaged
}

void loop() {
  // put your main code here, to run repeatedly:

  const int ctrlPin=14; // use whichever pin you wish.  I have used A0 which maps to D14.
  pinMode(ctrlPin, OUTPUT);

  // READ DATA
  int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);


  if (digitalRead(12) == LOW) {
  digitalWrite(relayPin1, LOW);        // Turn relay on
  digitalWrite(relayPin2, LOW);        // Turn relay on
  digitalWrite(relayPin3, LOW);        // Turn relay on
  digitalWrite(relayPin4, LOW);        // Turn relay on
  digitalWrite(relayPin5, LOW);        // Turn relay on
  digitalWrite(relayPin6, LOW);        // Turn relay on
  digitalWrite(relayPin7, LOW);        // Turn relay on
  digitalWrite(relayPin8, LOW);        // Turn relay on
  } else {
  digitalWrite(relayPin1, HIGH);        // Turn relay off
  digitalWrite(relayPin2, HIGH);        // Turn relay off
  digitalWrite(relayPin3, HIGH);        // Turn relay off
  digitalWrite(relayPin4, HIGH);        // Turn relay off
  digitalWrite(relayPin5, HIGH);        // Turn relay off
  digitalWrite(relayPin6, HIGH);        // Turn relay off
  digitalWrite(relayPin7, HIGH);        // Turn relay off
  digitalWrite(relayPin8, HIGH);        // Turn relay off
  }    
}

Here is my serie of IFs to test it:

if (DHT.temperature > 20) {
    digitalWrite(relayPin1, LOW);
}
if (DHT.temperature > 21) {
    digitalWrite(relayPin2, LOW);
}
if (DHT.temperature > 22) {
    digitalWrite(relayPin3, LOW);
}
if (DHT.temperature > 23) {
    digitalWrite(relayPin4, LOW);
}
if (DHT.temperature > 24) {
    digitalWrite(relayPin5, LOW);
}
if (DHT.temperature > 25) {
    digitalWrite(relayPin6, LOW);
}
if (DHT.temperature > 26) {
    digitalWrite(relayPin7, LOW);
}
if (DHT.temperature > 27) {
    digitalWrite(relayPin8, LOW);
}

More research has lead me to try the relays 1 by 1. pin4 has an increased 1 DegC just by itself. And using more than 5 leads to the same issue. I tried 3 boards total. All with the same results. Tried other DHT11s. Same result.

I tried removing the jumper in the corner deactivating the solenoids. The temperature reading got back to normal and lights were working like the relays should have been. Put the jumper back in… I then tried connecting the jd-vcc from the relay board to an atx power supply’s 12v. Apart from the relays clacking harder… No change. I then proceeded into using the 5v from one of the molex… Same thing.

No matter what I do, once I’ve gotten my DHT to sense to hot to activate too many relays… I skip 3-4 degC.

It seems to be an inherent design problem with the way arduino works… the more power drawn… The more erratic the readings. Is this possible?

Doing yet more research, stumbled across this post: http://forum.arduino.cc/index.php?topic=83642.msg626948#msg626948 I’ve tried all solutions that has worked for the original OP to no avail. I’ve tried seggregating my power and ground for analog and digital pins… Without success.

I’ve run out of ideas and I’m not experienced enough to get more ideas on my own.

Can anyone help please?

"It seems to be an inherent design problem with the way arduino works... the more power drawn... The more erratic the readings. Is this possible?" certainly points to the source of the problem, but without knowing how you have things connected and what you are using for power, it's a bit hard to know.

A drawing of your connections and tell us what the power supply parameters are.

Paul

from pdf:

DHT11’s power supply is 3-5.5V DC. When power is supplied to the sensor, do not send any
instruction to the sensor in within one second in order to pass the unstable status. One
capacitor valued 100nF can be added between VDD and GND for power filtering.

Read ONCE to a variable. Test this value.
I seems you read the sensor without the needed delay between readings.
As your 5V may be unstable - try 3V3 to the sensor Ucc

Here is the complete circuit

You'll have to imagine the rightmost LEDs + power supply to replace an 8 relay strip as the tool doesn't have any.

So I tried feeding power to the relays with an outside source (the ATX PSU). I tried it with the USB cable feeding power. 9V on the 2.5 mm jack. Tried using the 5v permanent rail of a computer PSU.

In fact, the design is that when 1 of the relays kicks in, the leftmost resistor I forgot to remove on the design is to be used to trigger the ATX PSU to turn itself on to provide 12v on the standard Molex to the equipment that will be hooked to the relays.

And I have tried reading the sensor at 1000 ms, 2000 ms and 5000 ms intervals with the same results...

Where is power for the relay coils coming from? Can you post a link to (or a picture of) the relay board?

outsider:
Where is power for the relay coils coming from? Can you post a link to (or a picture of) the relay board?

I've fed it 5, 9 and 12 volts externally... as well as from the breadboard... Nothing works.

I've also used another arduino to feed 5v to the relay strip vin and the atx psu for the relay controls... Instead of a 4 degrees problem, I get a 1 deg problem.

I can see in your code how you sequentially turn the relays on but not how they turn off as the temp drops, can you post the entire program? Also need some info on the relay board, I assume the coils are 5V, is the VCC/JDD jumper removed? Do you have both VCC and GND connected to Arduino?
This:

  const int ctrlPin=14; // use whichever pin you wish.  I have used A0 which maps to D14.
  pinMode(ctrlPin, OUTPUT);

Should be in setup(), what does it do?
EDIT: I see now how the relays are turned off, not a good way.