My GardenBot

There is a website called gardenbot.org, and it is a site documenting how to make a garden monitoring robot (is that the right word?) to water your plants automatically. My version currently doesn’t water the plants, but it monitors light levels and the moisture content of the soil. I have some pictures! Note: I can’t seem to embed pictures, I’m trying to upload them by putting the file path in between the image labels.

Building the Sensors:
I built the light sensor just using a medium sized photocell. I made the soil moisture sensor using a couple of straightened large paper clips. The control circuits I used are exactly the same as on the GardenBot website. IMPORTANT: The light sensor is on ANALOG 0 and the soil moisture sensor is on ANALOG 1. I used some phone wire to connect the sensors to the Arduino.

The Code:
Right now, the code just finds the mimimum, maximum (all time), and current readings, converted to percentages, and sends them to the computer through the Serial Window. You will probably have to resize the window to just fit one reading at a time.

Here is my code:

runOnce Program

//RUN THIS BEFORE FIRST USE OF MAIN GARDENBOT PROGRAM
#include <EEPROM.h>
const int LTS = 0;
const int SMS = 1;
int SM = 0;
int minSM = 0;
int maxSM = 0;
int LT = 0;
int minLT = 0;
int maxLT = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("Started");
  SM = analogRead(SMS);
  SM = 1024 - SM;
  SM = SM / 10.24;
  LT = analogRead(LTS);
  LT = 1024 - LT;
  LT = LT / 10.24;
  minSM = SM;
  maxSM = SM;
  minLT = LT;
  maxLT = LT;
  EEPROM.write(0, minSM);
  EEPROM.write(1, maxSM);
  EEPROM.write(2, minLT);
  EEPROM.write(3, maxLT);
}

void loop()
{
  Serial.println("Done");
  delay(60000); 
}

gardenBot Program (Note: Does not yet water plants)

#include <EEPROM.h>
const int LTS = 0;
const int SMS = 1;
int SM = 0;
int minSM = 0;
int maxSM = 0;
int LT = 0;
int minLT = 0;
int maxLT = 0;
int watering = false;

void setup()
{
  Serial.begin(9600);
  delay(100);
  Serial.println("Started");
  SM = analogRead(SMS);
  SM = 1024 - SM;
  SM = SM / 10.24;
  LT = analogRead(LTS);
  LT = 1024 - LT;
  LT = LT / 10.24;
  minSM = EEPROM.read(0);
  maxSM = EEPROM.read(1);
  minLT = EEPROM.read(2);
  maxLT = EEPROM.read(3);
}

void loop()
{
  LT = analogRead(LTS);
  LT = 1024 - LT;
  LT = LT / 10.24;
  SM = analogRead(SMS);
  SM = 1024 - SM;
  SM = SM / 10.24;
  maxminchange();
  printstats();
  delay(5000);
}


void maxminchange()
{
  if (SM < minSM)
  {
    minSM = SM;
    EEPROM.write(0, minSM);
  }
  
  if (SM > maxSM)
  {
    maxSM = SM;
    EEPROM.write(1, maxSM);
  }
  
  if (LT < minLT)
  {
    minLT = LT;
    EEPROM.write(3, minLT);
  }
  
  if (LT > maxLT)
  {
    maxLT = LT;
    EEPROM.write(4, maxLT);
  }
}

void printstats()
{
  Serial.println("----------------------");
  Serial.println("Current Soil Moisture:");
  Serial.println(SM);
  Serial.println("Min Soil Moisture:");
  Serial.println(minSM);
  Serial.println("Max Soil Moisture:");
  Serial.println(maxSM);
  Serial.println();
  Serial.println("Current Light Level:");
  Serial.println(LT);
  Serial.println("Min Light Level:");
  Serial.println(minLT);
  Serial.println("Max Light Level:");
  Serial.println(maxLT);
  Serial.println();
  if (watering == true)
  {
    Serial.println("Watering");
  }
  else
  {
    Serial.println("Not Watering");
  }
  Serial.println("----------------------");
  Serial.println();
}

I have attached the files to save you the trouble of copying and pasting.

Thanks for looking, and make sure to post about how it could be improved!

058606

runOnce.pde (608 Bytes)

gardenBot.pde (1.61 KB)

Perhaps add in two pads that can be jumped on first run which causes it to run the 'run once' code.

mowcius: Perhaps add in two pads that can be jumped on first run which causes it to run the 'run once' code.

Good idea! I have a button that I could use. I'm also thinking of getting rid of the min/max display. Last night both readings went to 0%. Maybe I should get a realtime clock and have it display the min/max of the day or something. I'll post on this thread every time I update!

i would love to see some pictures - im a very visual guy - and i plan on doing something slightly similar once I have my own place again...

fkeel: i would love to see some pictures - im a very visual guy - and i plan on doing something slightly similar once I have my own place again...

I would LOVE to post pictures, but I don't know how to embed them into the post. PROJECT UPDATE: Trying to make it more interactive/more information with the Messenger library, and adding runOnce into the main program (activated by a pushbutton).

try uploading them to picasa - thats what I do. or set up a blog with blogspot.com -- both can be done with relativly little hassle (that is, if you ahve a gmail adress.)

fkeel: try uploading them to picasa - thats what I do. or set up a blog with blogspot.com -- both can be done with relativly little hassle (that is, if you ahve a gmail adress.)

Good idea to use Picasa, since I use that already. I'll ask my parents about a blog, but every time I've asked before, they've said no (although they let me make a site on Google Sites).

Your sig is flawed :P

Should be: const int loveRobots = 1; const int loveElectronics = 1; const int loveComputers = 1;

or probably boolean loveRobots = true; boolean loveElectronics = true; boolean loveComputers = true;

mowcius: Your sig is flawed :P

Should be: const int loveRobots = 1; const int loveElectronics = 1; const int loveComputers = 1;

or probably boolean loveRobots = true; boolean loveElectronics = true; boolean loveComputers = true;

Haha, I noticed that a couple of days ago, but haven't changed it yet. Good observation! That's a little bug in my code for the watering variable, too.

or even:

define my_love_for_robotics_is true

:D

Subscribing to this interesting project.

I too am looking forward to seeing the pictures.

058606:

fkeel: i would love to see some pictures - im a very visual guy - and i plan on doing something slightly similar once I have my own place again...

I would LOVE to post pictures, but I don't know how to embed them into the post. PROJECT UPDATE: Trying to make it more interactive/more information with the Messenger library, and adding runOnce into the main program (activated by a pushbutton).

I have finally posted pictures! View them at https://picasaweb.google.com/104824220305339859922/ArduinoGardenBot#