Using DHT22 output to activate pins

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

thanks guys

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

  if (myReading >= threshold)
    digitalWrite(D7, HIGH);
    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.

I’m using the PietteTech library, cant see any sample stuff to do what im after but thanks, seems not so hard :slight_smile:

I am pretty experienced with power, i’ve worked with 3 phase data centre PDUs and lived to tell the tale. Microcontrollers are a different story.

Thanks for your help