Aquarium Reef Controller, stage 1, the LCD shield,

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 :P

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.

what a pain on breaking your LCD shield, ther no way you could salvage it with some clever soldering?

ah well least you have have a few goodies to keep you entertained, Ive spent most my afternoon working on my coding today trying different things adn where to go, Playing with gettting my LEDs to night up at a set time now. but i might give your Temp probe coding a bit of go now and see if i get anywhere with it.

Thanks

Well with clever soldering I was able to get the backlight working on the LCD, but I have no idea what to do for the data. Right now the LCD lights up and rows 1 and 3 are filled with white blocks while 2 and 4 are empty.

The lcd is only $15 at least so while disappointing, not a major setback.

My arduino mega just arrived in the mail so I'll be able to play around with that atleast!

thats great news, you'll love the extra ports of the Mega, Just remember the main difference is the possition of the SDA and SCL (for oyur RTC module) they are in a different place, (on the mega they are digital pin 20 and 21) other then that slight change in wiring everythign else should be directly transferable. you wont need to change your coding as the wire.h library compensates for the change in SDA and SCL pin locations.

i love my mega, every time i look at it i "discover" a new pin or something, i found 2 ground pins which i werent aware of.

how did you wire up your temp probes?

wire the Grd to pin 1 of the DS2018s wire 5V to pin 3 of the DS2018s wire all the pins 2 of the DS2018 to a single spare Analog pin wire a 4.7K resistor between pin 2 and 3 (one each or 1 per Analog line?) thinking of making my own bridge board

something like a small board of 3 rows, 1 row for the Ground, 1 row for the 5V, 1 row for the Arduino pin. then just have 1 resistor bridging the 5v to the pin row? with a bank of header pins spanning each row

does that make vague sense? its not because im tight fisted, i just want to do a neater end job and thought that be a pretty cool way to do it if i got some Header pins for quick "connect and disconnect"

i'll do a drawing if that didnt make enough sense

im actually going to make a guess and say id only need 1 resistor at the start... because its just to act a a pull up wait now that i think about it id need resistors on each .... pah i just like to solder things... lol anyhow my brains to fried to think straight now so im off for a bit, hopefully have my temperature probes adn menu rewritten soon

Thanks for the tip on the clock pins!

I have 4.7k resistors connected to each probe. , I wired the resistor and probe within the case for each probe.

Here's the diagram I used:

I don't have any photos of the probe itself because already sealed up in the case, but I just have them going to a breadboard with common 5v, ground, and data going to the arduino (on pin 13 in my example).

I'll try to get a nice photo of the stuff wired and show how I did my probe capsules as well.

thats perfect information Ludnix, and after i sat down and thought about it i came to teh same conclusion more or less on how to do it. how did you encapsulate/seal yours? did you notice any loss in precission (i vaguely remember you saying something about encasing yours in some rubber syphon/similar tubing, or was it a case once the probe had been placed in solution ~(i.e. in tank) the heat transfered through to the sensor with no problems.

Thanks anyhow

edit: Ah haa i thought you could do it this way

thats the image from the Arduino dellasTemp.h wiki library page

they connected 1 resistor to turn the whole +5 line into a pull up line (if that makes sense) and used 1 resistor per line, not 1 resistor per probe.

goign to get me some fancy quick connect adn disconnect ends and make a little "temp Board".

lol

edit agian:http://milesburton.com/wiki/index.php?title=Dallas_Temperature_Control_Library#Introduction

Hmm Well I've hit yet another wall it seems, I quickly wired up my DS18B20 chips up as singles and varying chain lengths and my Arduino cant "find them/locate them" on any of the DallasTemp.h library examples....

any ideas?

i've litterally downloaded the DallasTemperature.h librarys and pulled there examples across just to see if i get anywhere.