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.

Posted on

ProGrow is under development… again!

ProGrow Development

I’ve just started work on my ProGrow system after quite a long period of inactivity. Surprisingly, everything on the ProGrow still worked when I first plugged it in after so long. The moisture sensors didn’t seem to accumulate too much corrosion, and everything was still reading properly. It even had the program still loaded. Pretty crazy, considering it’s made using the cheapest parts available, went through a move and has sat idle for 6+ months. The plant that I used to have in the system was very dead. I replaced the soil, added a layer of cat grass seeds and then put an inch of soil over top. I chose cat grass because it’s super cheap, grows like crazy and I have two cats.

ProGrow Day 7 Growth From Front
ProGrow Day 7 Front

DC Pump

I bought a 3V-6V submersible pump from Aliexpress. It cost approximately $2 for one pump! That’s pretty darn cheap. I tested the pump by connecting it directly to a ~6V 18650 battery bank, and it pumped like crazy. It seems to work fine with a 9V battery as well, so I ended up using one of those because I had plenty of spares. I’m going to implement a more permanent rechargeable battery bank soon, possibly with some kind of solar power.

3V-6V DC Water Pump
3V-6V DC Water Pump

Relay Module

I added a double relay module to the project ( also bought on Aliexpress ), and connected the inputs on the module to digital pins 12 and 13 on the Arduino. It gets 5V and a ground connection from the nearby breadboard that holds the button inputs. A 4 digit segment display was added to the front to display the current sensor readings, instead of sending the information through the serial connection. I bought the display from RobotDyn on Aliexpress ( big surprise ), and it uses the arduino-tm1637-master library. Currently it displays the temperature, air and soil moisture, ambient light, run time and the delay between automatic samples. It also displays the project name and some other stuff while turning on.

ProGrow Day 10
ProGrow Day 10 with relay & LCD

Watering

I attached a mason jar to the side of the container in order to act as a water reservoir. With some hot glue and double sided tape, I attached the pump to the inside and ran some wires. I attached the pump to a 9V battery, and connected that to the relay that is controlled by pin 12 on the Arduino. I use the values read from the moisture sensors in order to control power to the pump. When the soil moisture falls below a certain threshold for a certain length of time, the pump will engage and water the plant until the average moisture rises back up. I plan to add another sensor to indicate when the water level is low in the reservoir, so that it won’t burn out the pump if there’s no water.

ProGrow Day 11 Status
ProGrow Day 11 Status

 

I intend to remove the RGB LED on the side to free up 3 more GPIOs. This will give me extra pins for future use. I am also going to move the relay modules to different pins.

I’m going to try to design and 3D print some customized enclosures for the modules that I have added. When my wireless chips and SD module come in the mail, I am going to implement wireless data logging and communication. I’m also looking into purchasing a sensor expansion board, and some silicon boards to clear up the wiring a bit. Not sure if the name “ProGrow” is going to stay.

I’m also going to try to make more detailed posts about the individual steps at a later date.