Posted on

Simple Arduino Temperature, Moisture and Light Monitor

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:

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
  • 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
    • Cheap, easy to use and fairly accurate.
    • DHT22 is a better version, but is more expensive

Connecting everything to the Arduino

Schematic for Temp/Humidity/Light Sensor
Schematic for Temp/Humidity/Light Sensor

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 <LiquidCrystal_I2C.h> //Import LcrystalI2C for FC 113 + LCD module
#include <dht.h> //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.

Posted on

ProGrow Update #4 – SD Card, Analog Buttons & 3D Printed Enclosures

ProGrow Version 1.0

ProGrow Update #4

ProGrow Version 1.0
ProGrow Beta

 

I completely revamped the layout and configuration of the modules on the front of the ProGrow. I designed and printed some basic enclosures for all of the different little modules to help isolate each unit and tidy it up. It’s still a mess of wires, but I’m making progress on the overall design. I used 3DS Max to design the basic enclosures, and then I used my Kossel Delta printer to make them. Most of the things were printed using white PLA, but I ran out and used black PLA to print the 9V battery enclosure.

3D Printed Enclosures

This slideshow requires JavaScript.

 

I’ve successfully added an SD card module to store data for the long term. I have a spare 16gb MicroSD in there right now, so I have a few years worth of samples that I could store. I’m going to change the SD card to a smaller, more robust one to help avoid catastrophic accidental corruption. I use the SPI.h and SD.h libraries in order to read/write to the SD card and I store the sensor data in a .txt file. I’m working on graphing the data automatically, but it’s not a priority right now.

 

4 Buttons Connected To One Analog Output
4 Buttons Connected To One Analog Output

I removed the 4 digital buttons that I was using for manual control. I made a circuit that outputs an analog signal instead of a digital one, and connected the buttons to a free analog pin. This freed up 4 digital pins for future use. I use a few series resistors to create different analog signals that gets sent out through the purple wire in the image above. The buttons are placed so that they will see different levels of resistance from the chain of resistors when pressed. The programming simply reads the analog value and then makes decisions based off of the value. Much more pin-efficient than before!

 

The LED display made the old RGB indicator light obsolete, so I removed it. This gives me even more digital pins for future use.

 

I’m going to work on reducing the power draw, and implementing batteries next. I’ll be publishing a parts list sometime soon.