Simple Arduino Temperature, Moisture and Light Monitor
Recently I planted some succulent seeds indoors, and had to put them in a miniature greenhouse so that they could sprout. I wanted a way to keep an eye on the temperature, moisture and ambient light in the greenhouse, so I whipped this up. It outputs realtime measurements to an LCD. If you’ve seen my ProGrow project, this is a simplified version without any data storage or relays.
Parts
I used an old scrap 3D print for the frame; it’s just a block of plastic that I screwed everything to. The electronic parts used are:
- Arduino Nano – AliExpress Link
- Arduino Nano expansion board ( optional ) – AliExpress Link
- FC113 + LCD Module – AliExpress Link
- DHT11 Temperature/Humidity Sensor – Aliexpress Link
- Photoresistor Module – Aliexpress Link
A quick overview of each component and why I’m using it:
- Arduino Nano
- Extremely low cost (<$3)
- Ready to go ATMega328p board with voltage regulators and USB
- Lots of expansion opportunities
- Arduino Expansion Board
- Makes life easier for prototyping/wiring with the Nano
- FC-113 + 16×2 LCD
- Cheap and easy to use LCD combo
- Only requires two analog pins for communication, easy to set up
- Photoresistor module
- Works just like a photoresistor with an analog signal, but it also has a digital output
- Has an indicator LED and potentiometer for the digital output
- DHT11 Temperature/Humidity Module
- Very cheap, easy to use and decently accurate
- DHT22 is a better version with higher accuracy, but is more expensive
- BME280 is far superior to DHT11/DHT22, but is more expensive
Connecting everything to the Arduino
The DHT11 module has 4 pins, but only three are used:
- Vcc to +5V
- Signal to Digital Pin 5
- Gnd to Gnd
The photoresistor module I am using also has 4 pins, and only three are used. The analog output of the module is used over the digital output. You can get the same functionality with just a resistor and a photoresistor.
- Vcc to +5V
- Aout to Analog pin 1
- Gnd to Gnd
The LCD module is connected to the FC 113. The FC 113 is connected in the following manner:
- Vcc to +5V
- SCL to Analog pin 5
- SDA to Analog pin 4
- Gnd to Gnd
The arduino nano can be powered through USB with 5V, or through the Vin pin with 7V-12V.
Programming
Programming the Arduino for this is pretty straightforward. All the Arduino has to do is take a measurement from the DHT11 and photoresistor, and then output them to the display.
There are libraries available for the DHT sensor, and the FC 113 module, so the whole process is straightforward.
Before starting
You need two libraries to make things easier, one for the DHT11 and one for the FC 113.
You can download the DHT library I used at:
https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib
You can download the FC 113 library I used at:
https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
How to install libraries:
https://www.arduino.cc/en/Guide/Libraries
Before Setup
//Temp/Humidity/Light Monitor V0.1
#include //Import LcrystalI2C for FC 113 + LCD module
#include //Import DHT for DHT11 temperature/humidity sensor
int tempSensor = 5; //Digital pin 5 for temperature sensor
int lightSensor = A1; //Analog pin 1 for light sensor
dht DHT; //Sets up dht11 as DHT
First I include the required libraries.
Then, I establish pin 5 for the temperature sensor and analog pin 1 for the light sensor.
Finally, I set up an object called DHT to handle data from the DHT11 sensor.
Setup
void setup(){
Serial.begin(9600); //Establishes serial at 9600
lcd.init(); //Initialize the lcd
lcd.backlight(); //Initialize LCD backlight
lcd.clear(); //Clear LCD
Serial.print(analogRead(lightSensor)); //Print currently photoresistor value to serial; for troubleshooting purposes
}
The setup just consists of initializing the LCD module, and printing a simple message to the serial monitor as an optional self-check.
Loop
void loop(){
DHT.read11(tempSensor); //Reads information from tempSensor(pin 5), stores in DHT
lcd.setCursor(0,0); //Sets cursor of LCD to very first position
lcd.print("H: "); //Prints H: , for humidity
lcd.print(DHT.humidity); //Outputs humidity
lcd.setCursor(0,1); //Sets cursor of LCD to first position, second line
lcd.print("T: "); //Prints T: , for temperature
lcd.print(DHT.temperature); //Outputs temperature
lcd.print(" C"); //Prints C for celcius
delay(4000); //Delays for approximately 4 seconds
lcd.clear(); //Clears the LCD
lcd.setCursor(0,0); //Resets cursor to first position
lcd.print("Lux: "); //Prints Lux, for light level
lcd.print(analogRead(lightSensor)); //Outputs lux value
delay(4000); //Delays for 4 seconds before looping
}
The loop starts by reading the DHT11 sensor, and storing the values in the DHT object. Then, it outputs the information to the LCD. It delays for a few seconds, and then it reads the light sensor. It continues in a loop like this, reading and then outputting. You can adjust the delay to change how often the display updates the values, and you could take it one step further by implementing a button so that the display only updates when you push a button.