Hi, i’ve got a dht22 giving me temperature data via a photo in my house. What im trying to do is set up a relay into a heater so that it turns on when a certain temperature threshold is reached.
I can do the hardware side of this no worries but i have no idea how to use serial data as a trigger in code. If anyone could point me to a project similar or offer any help
What library are you using for the DHT22?
These libs usually come with sample code too.
When you get a reading of your sensor, just use the value of that reading to check against your threshold value
e.g.
if (myReading >= threshold)
digitalWrite(D7, HIGH);
else
digitalWrite(D7, LOW);
But for temerature control you’d need to apply some hysteresis.
and if you are dealing with mains power
Don’t temper with mains unless you are actually educated and allowed to do this! Otherwise you might harm yourself or others and risk loosing insurance coverage.