Show Posts
Pages: [1] 2 3
1  Community / Exhibition / Gallery / Re: My GardenBot on: March 10, 2011, 11:04:27 am
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#
2  Community / Exhibition / Gallery / Re: My GardenBot on: March 04, 2011, 10:18:06 am
Your sig is flawed smiley-razz

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.
3  Community / Exhibition / Gallery / Re: My GardenBot on: March 03, 2011, 03:15:32 pm
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).
4  Community / Exhibition / Gallery / Re: My GardenBot on: March 03, 2011, 12:14:42 pm
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).
5  Community / Exhibition / Gallery / Re: My GardenBot on: March 03, 2011, 10:16:48 am
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!
6  Community / Exhibition / Gallery / My GardenBot on: March 02, 2011, 08:56:59 pm
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
Code:
//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)
Code:
#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
7  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 05:11:36 pm
Have a look for EEPROMWriteAnything.

Thanks! Reading that made me realize that my numbers will only need to use one address!
8  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 05:05:13 pm
Ok, now I know how to save variables, but Lefty says that they use two addresses. Do I have to split the variable up, or just give it enough space to "overflow" into the next address? Also, how would I "put the variable back together" after reading it from the two addresses?
9  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 04:58:46 pm
One more little question: Is there a way to clear the Serial communication window? I have the Arduino posting values every 3 seconds, and I don't like having a gigantic list.
10  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 04:56:35 pm
Quote
However, I could code it so it would only write/overwrite if the value changed...
That's the way to do it.
I think the erase/write limit is something like 1 million (front page of the datasheet), which may sound a lot, but 20 times a minute would soon use it up.

Ok, it would DEFINATELY write a lot less than 20 times a minute, as the sensors are (sun)light (using a photocell) and soil moisture (using two straightened paper clips) (I've had a non/saving script running for about an hour, and the variables haven't changed much). I'm going to post a thread about my project soon!
11  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 04:50:49 pm
Sure, use your on chip EEPROM memory.

http://arduino.cc/en/Reference/EEPROM

Lefty

Thanks! I didn't even know that page existed. Do I have to start at, for example, the last address to make sure I don't overwrite any of the bootloader or code?

No, EEPROM memory is it's own unique memory with it's own address, nothing to do with internal flash (program) or SRAM (data) memories. Different AVR chips have different size EEPROM, but if you just need to store a way a handle full of variables they all are large enough. You do have to keep track yourself what eeprom addresses you used and how large the variables are. The basic commands just write or read one byte at a time and a int is 2 bytes long, so you you have to manage where and how many bytes to read for you use.

Lefty
 

Will you please give me an example of splitting an integer into two bytes?

P.S. The values I'm saving only go from 0 to 100.
12  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 04:49:57 pm
EEPROM memory is not program memory; you can't overwrite the bootloader.
Be aware that the EEPROM has limited erase/write cycles,so only write to it when necessary.

Thanks. How often do you think I should write/overwrite? If I did not add any more delays in the program, it would write/overwrite about every 3 seconds. However, I could code it so it would only write/overwrite if the value changed...
13  Using Arduino / Programming Questions / Re: Is There a Way to Save Variables? on: March 02, 2011, 04:43:38 pm
Sure, use your on chip EEPROM memory.

http://arduino.cc/en/Reference/EEPROM

Lefty

Thanks! I didn't even know that page existed. Do I have to start at, for example, the last address to make sure I don't overwrite any of the bootloader or code?
14  Using Arduino / Programming Questions / Is There a Way to Save Variables? on: March 02, 2011, 04:38:13 pm
I'm making a GardenBot (gardenbot.org), but writing my own code for it smiley-lol. I have min/max values for the sensor readings, but when I power down/reset the Arduino, the values are lost smiley-eek! Is there a way to save variables to the internal memory of the ATMega 328 chip? Thanks!
15  Using Arduino / Programming Questions / Re: Help me With My Code! on: February 13, 2011, 06:56:06 pm
You need one resistor for each led, aroudn 330 and you'll probably be safe.
The same gibberish is good, try the resistors and report back smiley

Ok, I put a 680 ohm resistor on the ground wire, but all it did was make the display dimmer, it still shows the same pattern of gibberish.
Pages: [1] 2 3