Pages: [1]   Go Down
Author Topic: How to activate relay with DHT 11  (Read 472 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi friends!
Im buliding a small green house and I would like to use a DHT11 to monitor the temperature and if it raises from 30 C activate a relay to turn off the heat source.
I know how to do this with the lm34dz  but I just cant seem to figure out how to do it with the DHT 11 and cant find info around the web, I hope you could please help me do
I would be extremly helpful, the temperature where I live is dropping and i eould like to keep my plants alive.
Please help me friends.
Thanks in advance  smiley

Helsingborg, Sweden
Offline Offline
God Member
Karma: 24
Posts: 570
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tutorial here:

Global Moderator
Offline Offline
Shannon Member
Karma: 221
Posts: 13855
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

- -

You must built in some hysteresis in your sketch
Code: (concept only)
int relayState = LOW;
void loop()
  temperatue = .... ; // see lib above.
  if ((temperature > 30) && (relayState == LOW)) relayState = HIGH;
  if ((temperature < 25) && (relayState == HIGH)) relayState = LOW;
  digitalWrite(RelayPin,  relayState );
  .. other code here

Rob Tillaart

Nederlandse sectie -,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: