I am attempting to write a program using the humidity/temp sensor. The objective is to have the program turn on(close relay) if less than 40% humidity on initial start up. If there is a sensor error at any time, leave relay open. Then I want to try and make a loop with the sensor reading to stay on if under 50% and turn off if over 50%. Then circle back to the under 40% again so the relay isn't constantly going on and off. I can't find anything similar to this anywhere to model off of. Can someone please help me. Here is what I have so far.
Your "schematic" has at least one errors I hope your real wiring does not duplicate.
How do you detect a sensor that "isn't reading"? At this point the only interface to the sensor is to analogRead() the value - what reading would allow you to conclude that the sensor was off?
Hi,
What humidity/temperature sensor are you using.
Can you post a link to specs/data please?
If it is a DHT11 or similar, you cannot read humidity directly off the output pin with analogRead.
Your connections to the relay are not correct.
You should have the Vcc pin of the relay module connected to 5V.
You should have the IN pin of the output pin9 of the UNO.