Go Down

Topic: Aquarium Reef Controller, stage 1, the LCD shield, (Read 78030 times) previous topic - next topic


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:


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).



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.

Code: [Select]
#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

#define ONE_WIRE_BUS 13  //Where the temperature probe data pin is connected to arduino (pin 13 in this case)
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()
 if (!sensors.getAddress(insideThermometer, 0));
 if (!sensors.getAddress(outsideThermometer, 1));
 sensors.setResolution(insideThermometer, 9);
 sensors.setResolution(outsideThermometer, 9);  

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

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);
void printData(DeviceAddress deviceAddress)
 Serial.print(" ");

void loop()
lcd.print("Aquarium Controller");
lcd.print("Temp1: ");
lcd.print((char)223); // print degree symbol °
lcd.print("Temp2: ");
lcd.print((char)223); // print degree symbol °

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.



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!


May 05, 2010, 12:35 am Last Edit: May 05, 2010, 12:52 am by Harlequin Reason: 1
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.


May 05, 2010, 02:40 pm Last Edit: May 05, 2010, 02:50 pm by Harlequin Reason: 1
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".


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.

Go Up