Aquarium Reef Controller, stage 1, the LCD shield,

Thanks Ludnix, that thread you posted below is perfect for what i need, going to place an order for some parts probably in a moment. as far as soldering it and keeping it compact, that shouldnt be a problem, i bet you could get it down to about the size of 1" x 2" square if not smaller, (depends how confident you are to solder on 2 sides of some curcuit board) i've done enough soldering to be prett confident on getting it down to a minimum.

Secondly, i havent given much thought to encasing it, obviously i want it as small as possible im tempted to do it in 2 boxes, 1 with the controller and the electronics, the second with just the LCD screen and keypad etc, with a short cable linking the two (which i'll make desconectable) i could then mount the LCD into my stand/cupboard what ever and have the box hidden.

failing that theres some bigish project boxes i can get locally. infact some are huge, i'd like to do it in a custom built package but again i think id struggle getting the plastic cut to size, do you have any shops local that could cut it for you? i mean i thi nk its safe to say we're both pretty far off from that stage but still :P.

I got told my DS18B20's got shipped yesterday and should be with me in 2-3 weeks. so thats good news.

well after spending about 1 hour or so trawling through electronic sites to try adn find a supplier who sells everything i need i finally found one and the cost was pretty good.

For £8.51(that includes P&P first class) i got all the little bits and bobs i needed for a RTC module,

the cheapest supplier of "arduino" parts wanted £5 plus P&P for the DS1307 chip and 32.7 kHZ crystal.

the cheapest supplier of a prefabricated PCB RTC was £13+ P&P,

i got:-

DS1307 Chip IC 8 pin Chip holder (its an extra £0.08, saves me ruining a chip...) CR2032 coin cell battery CR2032 batter holder (we'll see on this one depends how big it is etc there was no photo, i might swap it out for a "slim line" one if its no good, it was only £0.40 so at the end of the world its not desasterous.) 32.768 kHZ watch crystal

plus because as i was ordering, i threw in a few led's for kicks/proto typing, i never have any spare led's and maplins my closest electronics store charges £1.23 for a 5mm .... i got 1 of each, red,yellow,green,blue, ultra bright white and pink (yeah they did a pink one.... havent seen one of those often...)

and i should hopefully have those by next week if all goes to plan, it will keep me out of trouble till i get my temp Chips ;D

I just got my RTC from futurlec, I haven't wired it up yet, but you're right about the size. It's much bigger than I imagined and making it yourself should actually save space. The printed board they use has a lot of wasted space.

I'm going to play with the clock and see about writing some code to turn a relay on and off based on time, but other than that, I'm just waiting for my controller for the lcd and keypad, and the actual keypad itself and I should have all my components.

man thats unlucky with your prefabed one, ah well least you have it to play with, although i havnet really looked at the RTC coding i would have thought it would be a pretty simple task to code it to turn on a relay and off at a certain point.

i did a quick search at probes today looks like i can pick up a PH probe for about £15-20 but trying to find any other types were pretty difficult.

but then i knew that really from looking at other projects.

It looked like they were having difficulty making a pH probe circuit that didn’t require 2x 9v batteries, but I didn’t look to far into it. I’m not going to be building a pH probe as it’s never been an issue or concern for me. I have a nice hand held probe that I use for the occasional testing.

I played with the clock library and got it to display the set time on the screen, I’m not sure how I keep the clock set, it doesn’t seem to work if I take out the code to set the time, but obviously I wouldn’t it want it to set to the same exact time everytime it powers up since that will change.

Here’s the code I’m using if anyone has any input on reading the clock’s date. It seems like I should be able to set the clock once, and have it remember the time until the battery runs out right?

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

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;    // pin 13 will control the backlight

void setup()
{
  //CLOCK
  RTC.stop();
  RTC.set(DS1307_SEC,1);        //set the seconds
  RTC.set(DS1307_MIN,55);     //set the minutes
  RTC.set(DS1307_HR,3);       //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();
  //LCD
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(4,20);              // rows, columns.  use 2,16 for a 2x16 LCD, etc.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Aquarium Controller");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(7,1);           // set cursor to column 0, row 1
  lcd.print("Ludnix");
  delay(3000);
}

void loop()
{
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Aquarium Controller");
 lcd.setCursor(0,1);
 lcd.print("");
 lcd.setCursor(0,2);
 lcd.print("");
 lcd.setCursor(0,3);
 lcd.print(RTC.get(DS1307_HR,true));
 lcd.print(":");
 lcd.print(RTC.get(DS1307_MIN,false));
 lcd.print(":");
 lcd.print(RTC.get(DS1307_SEC,false));
 delay(1000);
}

EDIT:

Nevermind, removing that section that sets the time in the setup does work for keeping time. I just happened to look when the time was 0 and thought it wasn’t working!

I got the two temperature probes working and modified the clock to display in a 12hr style instead of military. I also ordered the Ethernet shield they sell at the website you linked where you got the LCD shield. Should be fun to play around with the networking side of it.

looking excellent and wow i just noticed how big your RTC module is, even by most thats pretty big considering the size of the components, what are those 3 yellow bars though they look almost like jumpers? if thats the case i might need to order some more bits d'oh

i'll most likely be pestering you questions on the temp probes and the Real time clock module once i get my bits, but it looks like we are pretty level regarding our progress (ok your alittle ahead).

now see the ethernet shield was something i personnally didnt really see much purpose to in this perticular build, what do you plan to network it to? another controller/Hub a proper pc? etc....

you thought about doign anyform of data logging? i'd like to use a standard USB stick for memory failing that an SD card.

Oh its exciting where to go next XD

also noticed your using a Duelamore(probable horribly butchered spelling mistake but im tired and CBA to check...you know what i mean) Looks like you might need to upgrade to a mega soon its looking pretty cramped ;)

The yellow bits are jumpers to switch the SDA, SCL and INT from ENA to DIS. I have no idea what that means but that's what the board says! The board is like 2/3 the size of the arduino and is at least 60% wasted space. I guess it's probably some standard size that fits some specific purpose, but if I did it again i'd probably make my own to save space. I ordered it quite a while ago, before I knew all the components were for sale and easily assembled.

I'm planning on using the Ethernet shield for datalogging. I'll have to work on some way to interface it with a web server, but I'm hoping to store data in a mySQL database, from there it would be very easy to make graphs and display information from my computer. It would also be neat to setup email alerts for certain events.

The integrated circuit for the LCD and keypad will interface through i2c which uses 4 of the analog pins, but can be shared with the clock, keypad and LCD all on the same pins (I think), which will free up all of my digital pins except for the one wire for temperature probes. This should leave me with 11 pins free (2-13) minus the temperature probes. I'm going to control 8 outlets requiring 8 pins so I think I should be okay end up with an extra pin or two in the end for some indicator leds or peizo buzzer for an alarm.

I think using the i2c interface you can get a chip to add extra i/o ports to the arduino. I'm still learning about the process but hopefully that would be another means of expanding the board without having to get a new one. I imagine there are cases where even the mega doesn't have enough pins so there much be a way to expand it elsewhere.

Well my RTC parts came today (which im pretty excited about, the Watch crystal is smaller then i thought ( its about 2-3mm long and the legs are about 3mm long so i'll have to do a decent solder job on it, i really like the battery holder they sent as well its perfect, not massive or stupidly designed, just small and low profile.

hopefully have it set up on a bread board by tonight. (and those "jumpers" are pull up resistors i think, after doing some googling... soem people seem to use them others dont and use the internal Arduino ones...

im in two minds, im seeing my spark mate at 2 to pick up aload of prototype stuff, wire, resistors,boards etc so i'll ask him to have a look at the schematics if he feels up to it. (he's been pretty ill).

got aload more coral yesterday for the pico tank too ^^

It should be fun to wire up, I'm not familiar with how the crystal and circuit work so I'll have to do some research to satiate my curiosity. There are 3 resistors right next to the yellow jumpers so I think you're right.

How much do you think you spent on the clock by doing it yourself? You had initially said the breakout was pretty expensive for the components involved, but you may have been looking at the sparkfun breakout which is $20. The huge one I'm using was $7, so the price isn't that high, but it's definitely a lot bigger than it should be.

Also how was shipping on your LCD+button shield? I ordered the ethernet shield from the same website a week ago, but they still haven't shipped it yet.

I'm also rethinking my 16 button keypad that I was going to originally use. The keypad has the advantage of being able to connect to the integrated circuit I ordered for my LCD, but it might be cooler to use specifically designed buttons for the controller. Since I really only need a few buttons for feed mode, cleaning mode, and arrow and select keys the 16 button keypad isn't really designed for that. Those buttons would need a integrated circuit to control them so I don't waste I/O ports, so I guess I'll have to research to see if I have know-how to do that.

Firstly Ludnix, im UK side so i dont have access to anywhere near the number of arduino parts as you do, the cheapest i could find a complete made module was £13+£5 for postage.

another side wanted £5+ £2.50 postage for JUST the DS1307 chip and a 32.7Khz crystal.

i got

Chip, crystal, battery, battery holder, 5 different 5mm LED’s for £8.60 in total. so i got the compoents for about £5 not including postage, if i were to make a few of these i’d save more money, depending on how it goes i might make a few and sell them off, just seems a bit excessive price wise for the components but then this is the UK T_T,

postage from that company took about 10 days for me which i was alittle supprised usualyl it takes a few weeks for stuff from hong kong.

build quality wise though, the LCD looks fine (abiet the first one didnt work, but that was because they put the wrong resistance value buttons in (so i actually gained a “3” button 2x16 screen for free to use in another project.)

and although i could be completely wrong but i think i read somewhere that the Crystal vibrates at 32.678 kHz (or what ever it was) and the chip knows how many vibrations it can process in 1 second, it simply just counts the number of vibrations and counts up.

Its alittle more complex then that because it has internal memory to process the date and the month and when to “incriment” to the next month etc ( i.e. not to have more days then the month)

I have the same LCD Module. It uses the following:

//RS, RW and Enable can be set to whatever you like
int RS = 8;
int RW = 11;
int Enable = 9;
//DB should be an unseparated group of pins  - because of lazy coding in pushNibble()
int DB[] = {4, 5, 6, 7};  //wire these to DB4~7 on LCD.

Plus it uses AD0 for the 5 button keypad - you see varying values on AD0 for the 5 different buttons.

I switched to the liquid crystal library and made a cable to take it off the board. It is relatively straight forward with the above info.

moved my LCD shield to some breadboards, freed up 4 Anolog pins and 8 digital pins which was pretty good,

annoyingly the Arduino shield is ever so slightly larger then a standard breadboard so i have to use jumpers on one side.

waht is your scematic on the back up batery?

i want to use it in a turbine engine

Firstly Robot, Im not using any back up battery for the main controller though you can pick them up i think. only a back up battery on the RTC chip to keep the time and date,

Daveg, I sort of see what your codes doing but its incomplete, without knowing what you did with the integers RW and RS :-?

anyhow just about to give wiring the RTC chip together onto a breadboard and see what happens from there.

i need to get larger breadboard/stick my current breadboards down as its getting a bit messy now lol.

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