Aquarium Reef Controller, stage 1, the LCD shield,

I grabbed the code from the example code given out with your LCD - I got it from the URL you posted. All I was using it for was to illustrate which pins are used.

Ludnix / Anyone, could you please post your RTC code, the code on that tutorial is very haphazard. (including any librarys)

i cant really see which is the DS1307 library? and which is the code that goes into my main methods.

Cheers

(gave up on trying to use 18 Guage single core wiring for jumpers and gave in and brought 150 varying length jumper leads from ebay, for £7 which i thought was pretty good.)

so to do something constructive i just wired my led's up and played around with the battery ofr 10 minutes, the pink led looks pretty cool considering you dont see them very often.

Right, Well this is going to sound stupid butttt...... i cant for the life of me get this Arduino to import my new librarys?!

after some googling, i managed to find the .H, .CPP and keywords file for the DS1307 librarys and i was under the impression i should just copy and paste the files into a folder called DS1307, (once i had created them in a text/code editor), in my librarys subfolder.....

and then use the Inport library option in the Arduino Compiler.... well why cant it see the folder?

And another thing i've noticed, its "lost" the pathway for my other imported library (LCD_4BITMOD, i dont use it anymore) its there in my subfolders just the compiler wont view them....

C:\Program Files (x86)\Arduino\arduino-0018\libraries\DS1307

What am i doing wrong? lol

this worked before and what i was told to do previously and i had no problems.

HELP!

(my new jump leads should be here by monday/tuesday =))

EDIT: never mind, for some reason it just didnt like me using a shortcut to load the Arduino.exe application.... strange but sorted now, it was opening a "clean" new version (i..e like for the very first time) but its fixed now.

on to placing with my RTC =D

Version 18 seemed to have changed how libraries worked a bit since they have a different directory now. It's tossed me a few curve balls.

Here is the RTC library with some examples. The folder should be in arduino/libraries, so one of your included files would be arduino/libraries/DS1307.h

http://code.google.com/p/ds1307/downloads/list

It is then included in my code as #include <DS1307.h>, arduino automatically finds it, but you must restart arduino before trying out the new library or else it won't find it. That might have been your problem with the new libraries you tried. I think the arduino software scans the libraries folder on startup, so anything added after the software is running it doesn't know about.

Here is the code in action for my setup:

 if(RTC.get(DS1307_HR,true) > 12){
 hour = RTC.get(DS1307_HR, true) - 12;
 ampm = 2;
 lcd.print(hour);
 }else if(RTC.get(DS1307_HR, true) >= 12){
   ampm = 2;
   lcd.print(RTC.get(DS1307_HR,true));
 }else{
 ampm = 1;
 lcd.print(RTC.get(DS1307_HR,true));
 }
 if (RTC.get(DS1307_HR,true) == 0){
 lcd.print("12");
 }
 lcd.print(":");
 if(RTC.get(DS1307_MIN,false) < 10){
   lcd.print("0");
 }
 lcd.print(RTC.get(DS1307_MIN,false));
 if(ampm == 2){
 lcd.print("PM  ");
 }else{
 lcd.print("AM  ");
 }

That's in my loop, it's just checking what the RTC says the hour is, converting it 12 hour time (RTC values for the hour are 0-23, so I subtract 12 if it's over 12 to get the 12 hour version).

If you haven't set the clock yet you can use this code, I just run it once to set the time and then commented it out.

void setup()
{
  //CLOCK
  // set the time
  RTC.stop();
  RTC.set(DS1307_SEC,0);        //set the seconds
  RTC.set(DS1307_MIN,32);     //set the minutes
  RTC.set(DS1307_HR,2);       //set the hours
  RTC.set(DS1307_DOW,6);       //set the day of the week
  RTC.set(DS1307_DATE,16);       //set the date
  RTC.set(DS1307_MTH,4);        //set the month
  RTC.set(DS1307_YR,10);         //set the year
  RTC.start();
  
}

I got my ethernet controller today. I discovered it uses pins 10-13 though, leaving them unavailable. That only leaves me with 8 digital pins which is too few for my needs. If I want to continue with the ethernet shield I will likely need to either upgrade to the mega, or expand my number of I/O ports using a chip and i2c interface. I also found the ekitszone ethernet shield doesn't use the ethernet library that the arduino made ethernet shield does. If I decide to continue with the ethernet shield I might just buy the arduino version which is $40 opposed to the $24 I spent at ekitszone.

Hello Guys, (and any Girls) Hope everyone one is well.

Spent the last few hours redoing and neatening up my Menu's (im now on version 1.03 ha) And hopefully my jumper wires will be here tomorrow.

Im just about to start looking at the software "half" of the RTC but im too tired at the moment and shall pick it up tomorrow no doubt.

Hopefully i'll have something more constructive to add in a few days.

Luke

I ended up ordering an arduino mega this weekend for $32 shipped of ebay. I was originally going to do the integrated chip route to expand if necessary, but since the mega has 54 digital i/o ports that's more than I could ever need and would be much easier to just use that than rig my own setup. I still might buy a new ethernet adapter though, the code for the ekitszone.com ethernet shield is pretty ugly and hard to use compared to the actual arduino shield library code.

I've been running some lunar link moon lights on my tank for a long time now, but some of the leds are pretty dim and seem to be burning out. I am planning on replacing them, but figured it would be cool to make them dimmable via arduino at the same time. I'm thinking of using the PWM on the arduino to transistor to control the power to the LEDS. They need 6vdc according the transformer so I suspect the arduino can't power them on it's own, thus the transistor connected to the transformer.

Is that similar to what you're going to be doing for your leds? I know you'll be working with a higher wattage since you're controlling the main leds and not just moon lights, but I was curious to hear how you planned to dim them with the arduino.

My led set up is different Ludnix, Im using 10 3 watt leds, over a 15"x10"x8" tank (its the test pico, i have twin 250's over the 4ft marine)

And i have 5 Cree X-RE Royal blues and 5 Cree X-RE "R2" (whites), each string is regulated by a luxdrive BuckPuck (Each buck puck has a pot on it to dim the lights, but you can snip this off and supply a PWM signal to dim them) if you were desperate, you could wire up to 1-18(maybe a few more) 1 Watt led's to a buck puck and just supply a PWM signal if you cant get any further. but i bet you could wire them up and power them off an Arduino, even if they require 6 v , you could ether drop a few leds or use transistor (think thats the one) to beef up the voltage, failing that you could always salvage the Led's out of it, heat shrink them and just create a new 5V chain.

got my jump leads, and my Temperature probes in the post today, the RTC coding is giving me a bit of a head ache so i mgiht try and work on the Temp chips now they are here.

i desperately need to order some new bread boards but i cant bring myself to buy one of those large 2.5K point boards (like oyu have) that £20 could go to a complete new module/component :stuck_out_tongue:

Well Im having Tonnes of trouble putting my RTC chip module together and to get it to work with my controller.

I assemble my RTC in the following way:

Crystal leg---------[1 8] ----------5V(shared on a rail that has a
Crystal leg---------[2 7] a pin to the LCD on as well)
------------------[3 6] --------- Pin 20 SDA
| ---------[4 5] --------- Pin 21 SCL
| |
| |
| |
-- +/- ----------------------Ground (shared with other pins from the LCD that need to go into the ground)

*note im using an Arduino mega, the SDA and SCL are located at pin 20 and 21, not pin 4 and 5 as in the previous/smaller models. im assuming that the wire.h library has the ability to distiqunish which board is in use (i.e. if its a mega and therefore use pin 20 and 21) this is the case as far as i can tell researching. Ludnix, your going to come across this problem i think as well, hopefully you'll jsut have to change your wire locations.

In the Duelmore models pin 4 and 5 had Pull up resistors built in again im assuming this is the case in the mega, but i could be wrong.
i need to go pick some 4.7K resistors up anyhow at some point. for my DS20BS18 chips.

can anyone see anything painfully obvious? with my hardware layout?

Secondly coding wise, for testing purposes i just used one fo the generic testing cases knocking on the net

When i run the code it doesnt set the RTC values to the values i set
i.e. RTC.set(DS1307_SEC,32);

but instead prints out

0:0:0 0/0/2007 DOW:0

and doesnt "incriment up" as time goes by, i can see the screen flickering as the screen is refreshed via the loop(); but the seconds just stay at 0, its not something stupid like me resetting the values to 0 each loop.

i even tried your code Ludnix (modified for my 16x2).

Anyone got any ideas?

a step by step would be nice if anyone has one in building a DIY RTC ;D (again i've looked at that one you posted ludnix time and time again and cant see what im doing differently...)

Help would be appriciated.

(next week we have Temp probes to work through XD (they came today))

With I2C, you need to use use external pullup resistors, I have seen anything from 1k8 (1800 ohms) to 47k (47000 ohms) used.

Ok so after about 7 hours of battering my head against code and hardware im getting somewhere, I've managed to write a small piece of code which set and displays the correct time And it incriments correctly.

I do it by having some RTC.set code, which i run once, i then // this code in the set up, and upload the new code which is missing the set up and just use the RTC.get method to display the time. so far so good it keeps its time and doenst do anyhting funny etc.

But for some reason when i Pull the power to simulate a power cut(which is via usb, not a wall power supply so this may have something to do with it) the DS chip resets and looses the data stored for the time (AKA the back up battery isnt kicking in)

Anybody got any suggestions or reasons why?

Now i HAVENT included any pull up resistors ether, and am assuming that pin 20 and 21 have internal pull up resistors like the previous models.

(and because i only have 1K and 20K resistors to hand...) could this be a reason why?

basically Why isnt my back up battery kicking in?

Ah well each day i get one small step closer.

Night all,

Cool project! I started a similar one several months ago (ongoing).

Just figured I'd let you know that a bunch of the code you're trying to write I've done already. It's not commented that great, but you can check it out:

http://www.diy-labs.com/projects/arduarium-controller

Which pin do you have the battery hooked up to the DS1307? IIRC positive goes to the pin and the battery gets grounded. (may not be right since it's been a really long time since I've setup the rtc).

Hello,

I actually came across your site a few days a go before you posted and was very interested, Thank you for the offer but half te fun is compiling my own coding and figuring things out by myself, but this RTC has got me stumped lol.

I have probably found my issue tho witht he battery back up. i think the brand new battery is Dead... i couldnt even light an 3 or 5mm led up with it?! where as last week i was able to, so i think i've somehow fried the battery (that or it had the tiniest amount of power in it) so i need to go to the shop and pick a new one up, which is annoying

soldered up my RTC module on some copper board, tbh i could have done a neater job but it works. and ive managed to make it relatively compact its 1" x 2" (about 1/4 of the arduino board size).

For some reason when i go to include the RTC code to my controller code i keep geting an error message (well 3)

"c:/program files (x86)/arduino/arduino-0018/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

c:/program files (x86)/arduino/arduino-0018/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

c:/program files (x86)/arduino/arduino-0018/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

Bad error line: -7
"

and the error line contains no code just // out comments, i can delete these adn the error line changes....

any ideas?

i might just re write the menu code around the RTC not the other way around, and try adn debug what ever problem im having.

its not conflicting with the LCD code, because i've been able to write code that displays the RTC value on my LCD etc.

i'll look at it later.

in the mean while i might start having a stab at the DS20B18 temperature probes. I havent got any 4.7K resistors to hand would 5 1K resistors put in series or 1x20K resistors work instead?

never mind if not l'll pick some 4.7 ks up at some point.

I remember running into that error before. Took me hours to figure it out.

In the rtc code you may be missing a closing bracket which is throwing the error.

If you could post the code that would help.

You should be able to 4.7k resistors at an Electronics shop. I was able to 5 for a dollar at radioshack here and they have an extremely limted selection of components

oh i can pick them up cheap enough, its just finding the time to get them, i have 1K and 20K resistors to hand that was all. I'll try and pick some up on tuesday, im working 8-8 for the next 3 days, then back to uni tuesday-friday but im sure i'll find some time to get some

well it took me embarisngly long to figure out whats wrong with the battery back up on the RTC..... i wired the Battery holder in the wrong way round, wired all the wires correctly just got the two pins of the battery holder mixed up, flipped the battery cell "upside down" and volia it works.

For some reason i keep getting that error message though when i try to add the RTC code to my currently made controller program, so i've started to re write the menus etc into a new file, so far so good it compiles etc.

Also brought some 4.7 K resistors i got 10 for £1.40 o once i've got my menu's re created i'll try the temperature probes. anyone got any good tutorials/info on those.

I'm assuming you'll be wanting to wire the temp probes in parasite mode. I will post my code when I get home tonight, displaying a single temp probe reading was pretty simple but I initially had a hard time doing multiple readings so I'll post code and some commentary as well.

Do you know how many probes you plan to use? I currently had two working and ordered a third so I'll have to modify my code for that as well.

I unfortunately ruined the connectors on my LCD and can't get it to display data anymore so I can't test my code out with the LCD until the new one arrives tomorrow or Thursday. I did order a bunch of other components though which will help my project along nicely. I ordered a piezo buzzer for alarms and confirmation noises, some RGB LEDs for moonlights and some vinyl lettering for my keypad so I can have custom symbols on it.

Here's how my code looks, you will have to modify it to fit your system but the temperature code part should be the same.

#include <LiquidCrystal.h>
#include <WProgram.h>
#include <Wire.h>
#include <OneWire.h>
#include <DS1307.h>
#include <DallasTemperature.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int backLight = 9;    // pin 13 will control the backlight

//TEMPERATURE
#define ONE_WIRE_BUS 13  //Where the temperature probe data pin is connected to arduino (pin 13 in this case)
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 
DeviceAddress insideThermometer, outsideThermometer; //arrays to hold device addresses

void setup()
{
   //TEMPERATURE PROBES
  Serial.begin(9600);
  sensors.begin();
  if (!sensors.getAddress(insideThermometer, 0)); 
  if (!sensors.getAddress(outsideThermometer, 1)); 
  sensors.setResolution(insideThermometer, 9);
  sensors.setResolution(outsideThermometer, 9);  

  //LCD
  analogWrite(backLight, 10); // turn backlight on.
  lcd.begin(4,20);              // rows, columns
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           
  lcd.print("Aquarium Controller");
  delay(1000);
}
//FUNCTIONS

//TEMPERATURE
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  lcd.print(DallasTemperature::toFahrenheit(tempC));
}
void printData(DeviceAddress deviceAddress)
{
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop()
{
 //TEMPERATURE PROBES
 sensors.requestTemperatures();
 //LCD
 lcd.setCursor(0,0);
 lcd.print("Aquarium Controller");
 lcd.setCursor(0,1);
 lcd.print("Temp1: ");
 printData(outsideThermometer);
 lcd.print((char)223); // print degree symbol °
 lcd.print("F");
 lcd.setCursor(0,2);
 lcd.print("Temp2: ");
 printData(insideThermometer);
 lcd.print((char)223); // print degree symbol °
 lcd.print("F");
  delay(1000);
}

This should just display 2 temperature probes on individual lines of the LCD. the probes are named outsideThermometer and insideThermometer, when I get my third probe I'll see about making the code for that and giving them some proper names.