Smart Garden with Arduino _ Pump Update (6/13/2014)

As its Spring here, I’m starting to get into the gardening spirit. I really want to get into bonsai tree gardening, but try as I might every year, I end up killing my plants because of over or under watering them. So, this year I’m combining my love of electronics with my urge to bonsai. I am going to create an Arduino-controlled, bonsai monitoring system. I am working on an nRF24L01 home network that I will incorporate the garden into… eventually.

My initial plan is to use a Soil Hygrometer Sensor and Digital Temperature Sensor to monitor and keep track of the bonsai trees’ condition. This will hopefully help me know when to water them. My eventual goal is to have the sensors in a meshed network and also automate watering them, but that will come (much?) later.

I am currently using Arduino Nanos as they are quite small and cheap while still having all the features of the Uno. And hopefully soon I will switch to the DigiSpark Pro once they are shipped out.

I’m still working on getting the nRF node system working, but until then, I have made a standalone module that takes readings and displays them to an OLED display. Code below and images in 2nd post. I will update as I progress.

UPDATE: I finally got my 12V peristaltic pump working correctly without melting my transistor… Its long ,painful story to me, that ended in reversing the direction of a diode :roll_eyes:. My problem now is that I have acquired another pot with three very young trees in it and splitting the output to now 3 pots is beginning to be too much for this little pump. It should work for the short term, but now I’m looking at possibly getting a valve/servo set up. But again, I won’t be able to get to that for some time.

  Arduino Garden Monitor
Test code
Soil Hygrometer
  Attach  VCC to 5V, 
          GND to GND, 
          A0 to analog input on Arduino.
  Reading of 1023 means that the soil is completely DRY. 
  Lower numbers indicate MORE moisture.
DHT11 Temperature Sensor
  Good reference source: 
    VCC to 3V-5V power
    Data out to 2
    3rd Pin not connected
    Ground to GND
  Use 4.7K or 10K resistor as a pullup from the data pin to VCC
SSD1306 0.96" 128x64 OLED Display (Not from Adafruit)
 - SPI variant (must be SSD1306 Driver to work) 
    GND to GND
    VCC to 3V-5V power
    SCL to 10
    SDA to 9
    RST to 13
    D/C to 11
    Arduino Pin 12 is not connected to anything, but in the adafruit version it is connected to CS

By Aerospacesmith, May 2014


#include <DHT.h>  //DHT Sensor Library from Adafruit 

#include <Adafruit_SSD1306.h>  //SSD1306 oled driver library from Adafruit 
#include <Adafruit_GFX.h>  //GFX graphics core library from Adafruit 
#include <SPI.h>
#include <Wire.h>

// If using software SPI (the default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13

#define charWidth 6  //TextSize 1 pixel size  -for spacing math
#define charHight 8

#define DHTPIN 2     // what pin DHT is connected to
#define DHTTYPE DHT11   // DHT 11 sensor

int hygroPin = A0;    // Hygrometer Pin
int soilValue = 1023;  // variable to store the value coming from the sensor

int motorPin = 4;   //Digital Pin to Base pin on transistor

int waterMode = 2;  //0=Disabled    1=Startup Watering     2=Sensor Activated

void setup() {
  pinMode(motorPin, OUTPUT);   //to Base pin on transistor
    // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);  //must be included
  // init done
  display.clearDisplay();   // clears the screen and buffer --else the adafruit logo will appear
  if(waterMode == 1){
    delay(10000);   //configure time to water

void loop() {
  // read the value from the sensors:
  soilValue = map(analogRead(hygroPin),1023,0,0,100);    //maps the 1024-0 analog range to 0-100 range for percent 
  int ambientHumid = dht.readHumidity();
  int ambientTemp = ((9*dht.readTemperature())/5)+32;  // converts to Fahrenheit ((9*C)/5)+32
  // Draw/refresh the display
  display.fillRect(0, 17, display.width(), 64, BLACK); //Clears the lower portion of display
  display.print("Soil Humidity = " );
  display.write(37);  // % symbol

  display.print("Room Humidity = " );
  display.write(37);  // % symbol
  display.print("Temperature   = " );
  display.write(247); // degree symbol

  display.display(); //draw evreything buffered to the display
  if(soilValue < 60){ //if soil is 40% dry        ------ Needs calibrated to determine the correct warning level
    humidWarning(); //call warning function if soil wetness is too low
    if(waterMode == 2){
      delay(10000);   //configure time to water
  else{display.fillRect(0, 0, display.width(), 16, BLACK); //Clear the warning area if there isn't a warning anymore

  delay(2000);  //wait for next reading

void humidWarning(){
  display.fillRect(0, 0, display.width(), 16, WHITE);
  display.setCursor(((display.width()-(10*charWidth*1))/2)-1 , 1);  //centers text
  display.setCursor(((display.width()-(12*charWidth*1))/2)+2 , 8);  //centers text
  display.print("Water Needed");
  display.display(); //draw evreything buffered to the display

More Images at

Any thoughts or ideas? I value input as I’m mainly just experimenting right now.

[Reserved for future content]

Images so far:

Did you ever get this project to a functional state? Sounds very interesting.

I am currently working on the nRF modules to get them working adequately and do not yet have the mesh network set up. The system does read the environmental status and does water my trees. I am looking into getting a more powerful pump though as the peristaltic pump is just underpowered. I was going to add a buzzer to alert when they are overly dry, but that may get too annoying. Right now, I do not have much free time to dedicate to this project solely, but there is progress nonetheless.