Made for Lane Tech IoT PCL IoT project.Inspiration
My room is in a space where the temperature inside can fluctuate rapidly, which can make the room a bit uncomfortable at times. To address this, I decided to make a temperature sensor that can alert me through email when the room temperature goes outside the ideal level. This way, as long as I have my phone on me, I can tell if I need to do something to fix the room temperature.
The DHT I used has a backboard with a built-in 10kΩ resistor (the flat black part of this DHT11). If there's no backboard but still 3 pins, put a resistor somewhere on the power line so that the circuit doesn't short. If there are 4 pins, the same thing applies as 3 pins without resistor, but the 2nd pin from the right is not used. The rest of this explanation is made with the assumption that this is a DHT11 with a backboard. Make adjustments as necessary.
The wiring is pretty simple, it's just 3 wires running from a 3 pin DHT11 to a microcontroller connected to my PC. (see full schematics below)
- Left Pin (Signal) on the DHT11 to a Digital Pin
- Center Pin (+) on the DHT11 to a 5V Pin
- Right Pin (-) on the DHT11 to Ground
(credits to Adafruit and the DHT library they made)
These few lines are how you set up the DHT according to the DHT Library that was imported. DHTPIN is the digital pin you are connecting the DHT to. DHTTYPE is the model of DHT, in this case the DHT 11.
This check in the if loop checks so that numbers that are absurdly high due to voltage spikes aren't posted.
The code, (included below but here's some screenshots)
- publishes the temperature once every minute in Fahrenheit to the Particle console when connected.
int cycle = 60000
(60000 ms per minute)
- uncommenting lines 32-37 and commenting lines 25-30 will do the same but return degrees Celsius.
- It also prints the temperature to a serial monitor should you feel the need to.
I then created 2 alerts on IFTTT, one to measure if the temperature went below a certain value and one to measure if the temperature went above. In my case I chose 65 and 80 degrees Fahrenheit, respectively. Should either of these be triggered, I would get an email.
Here's an email alert from when I left my window open one day.
And here's one from when I left the sensor on top of my heater for a bit.
IFTTT can be really inconsistent with when the alerts come out. They can come late sometimes, or they can come perfect in 1 minute intervals. IFTTT is just like that sometimes.Conclusion
This is a simple, perhaps crude, beginner temperature sensor that comes with alerts to boot.