Hi,
I got a DHT22 + cheapy ebay 5v arduino relays.
Anyhow, I’ve made a thermostat that turns an AC on at a set temp and off at a target temperature.
The temperature sends values in serial.
The relay is connected to the 5v and ground on the Arduino, the trigger is set to pin 9.
The code works perfectly when the relay is not connected, but when the relay is connected to pin 9, my temperature sensor will show a NAN value for a brief time after the relay is on.
When the AC reaches the target temperature, the relay turns off and this is where my temp sensor fails to work altogether unless i close and open the serial monitor.
Has anyone experienced a similar problem like this? Is there supposed to be a resistor somewhere like a push button needs?
My code is pretty simple.
int fan = 0; // 0 meanning off, 5 meaning on
int OnTemp = EEPROM.read(100); // gets last setting from the EEPROM
int OffTemp = EEPROM.read(101);
void setup() {
dht2.begin();
Serial.begin(9600);
pinMode(EvRelay, OUTPUT); // pin the relay is plugged into.
}
How is your relay connected? You are driving the coil with a transistor? The relay is NOT powered by the Arduino? The relay coil has a kikckback diode? Why are you asking a hardware question without supplying a schematic?
Why didn't you read the "how to use the forum" stickies?
On the bus on my phone atm,
I have an external power supply plugged into the arduino. It's an Uno. I will try using a separate 5v for the relay and connect the grounds ( ground from arduino GRND and the external 5v supplies negative terminal I hope you meant).