Arduino Aquarium Controller


hello,

as understand subject trying built aquarium controller, working on project 2 years starting scratch because  didn't have idea electronics sailor... , have done lot of research , work, in dead end , help!!!

my controller has lcd (20x4), ds1307 rtc , 3 ds18s20, 1 waterproof, measuring temperature planning add 8 channel relay control multiple devices , push buttons.

my problem temperature not accurate have 0,5 degrees difference temperature controller (elliwell ic915)and wondering if way calibrate ds18s20.
and can't make relay open , close due temperature difference.

here code if can me... (be gentle me amateur understand :-[  :-[  :-[ )

code: [select]


#include <liquidcrystal.h>
#include <math.h>
#include "rtclib.h"
#include <time.h>
#include <wire.h>
#include <onewire.h>
#include <dallastemperature.h>

// data wire plugged pin 3 on arduino
#define one_wire_bus 3

// setup onewire instance communicate onewire devices
onewire onewire(one_wire_bus);

// pass our onewire reference dallas temperature.
dallastemperature sensors(&onewire);

// assign addresses of 1-wire temp sensors.
deviceaddress watertemperature = { 0x28, 0x62, 0x30, 0xca, 0x03, 0x00, 0x00, 0xf1 };
deviceaddress devicetemperature = { 0x10, 0x9a, 0x3e, 0x84, 0x02, 0x08, 0x00, 0x4d };
deviceaddress roomtemperature = { 0x10, 0xa1, 0xfe, 0x83, 0x02, 0x08, 0x00, 0xfc };

/*
lcd connections:
rs (lcd pin 4) arduino pin 12
rw (lcd pin 5) arduino pin 11
enable (lcd pin 6) arduino pin 10
lcd pin 15 arduino pin 13
lcd pins d4, d5, d6, d7 arduino pins 5, 4, 3, 2
*/

liquidcrystal lcd(12, 11, 4, 5, 6, 7);
rtc_ds1307 rtc;
long previouslcdmillis = 0;    // lcd screen update
long lcdinterval = 20000;
// screen show
int screen = 0;   
int screenmax = 2;
bool screenchanged = true;   // have new screen,  definition
// defines of screens show
#define screen1 0
#define screen2       1
#define screen3              2

int ledpinfilter1 = 26;                 // led connected digital pin 28 (filter 1)
int ledpinfilter2 = 27;                 // led connected digital pin 31 (filter 2)
int ledpinheater = 29;                  // led connected digital pin 27 (heater)
int ledpinfan = 28;
int relaypinheater = 24;
int relaypinfan = 25;

void setup(void)
{
  pinmode(ledpinfilter1, output);      // sets digital pin output
  pinmode(ledpinfilter2, output);
  pinmode(ledpinheater, output);
  pinmode(ledpinfan, output);
  pinmode(relaypinheater, output);
  pinmode(relaypinfan, output);
  digitalwrite(relaypinheater, low); // set heater low (off)
 
  // start library
  sensors.begin(); 
  // set resolution 10 bit (good enough?)
  sensors.setresolution(watertemperature, 12);
  sensors.setresolution(roomtemperature, 11);
  sensors.setresolution(devicetemperature, 11);
 
  serial.begin(9600);
wire.begin();
rtc.begin();
lcd.begin(20, 4);
pinmode(8,output);
 
if (! rtc.isrunning()) {
serial.println("rtc not running!");
// following line sets rtc date & time sketch compiled
rtc.adjust(datetime(__date__, __time__));

  lcd.begin(20, 4);              // rows, columns.  use 16,2 16x2 lcd, etc.
  showwelcome(); 
  delay(4000);   // show message on screen}
     
}

void showwelcome()
{
  lcd.clear();
  lcd.setcursor(1, 0);           
  lcd.print("my amazon aquarium");
  lcd.setcursor(3, 1);         
  lcd.print("initialising...");
  lcd.setcursor(1, 2);         
  lcd.print("aquarium controler"); 
}

void showscreen1()
{
  lcd.clear();
  lcd.setcursor(1, 0);// set cursor column 1, line 0 (first row)
  lcd.print("my amazon aquarium");
  lcd.setcursor(0, 1);       
  lcd.print("water temp:");
  printtemperature(watertemperature);
  lcd.print((char)223);
  lcd.print("c");
  lcd.setcursor(0, 2);
  lcd.print("ph: 6.8");
  lcd.setcursor(0, 3);
  lcd.print("tds: 150");
  lcd.setcursor(9, 3);
  lcd.print("ms");
}

void showscreen2()
{
  lcd.clear();
  datetime = rtc.now();
  lcd.setcursor(1, 0);
  lcd.print("my amazon aquarium");
  lcd.setcursor(0, 1);
  lcd.print(now.day(), dec);
  lcd.print('/');
  lcd.print(now.month(), dec);
  lcd.print('/');
  lcd.print(now.year(), dec);
  lcd.setcursor(12, 1);
  if (now.hour()<10)
  lcd.print('0');
  lcd.print(now.hour(), dec);
  lcd.print(':');
  if (now.minute()<10)
  lcd.print('0');
  lcd.print(now.minute(), dec);
  lcd.print(':');
  if (now.second()<10)
  lcd.print('0');
  lcd.print(now.second(), dec);
  lcd.setcursor(0, 2);
  lcd.print("room temp:"); 
  printtemperature(roomtemperature);
  lcd.print((char)223);
  lcd.print("c");
  lcd.setcursor(0, 3);
  lcd.print("ph: 6.8");
  lcd.setcursor(8, 3);
  lcd.print("tds: 150");
  lcd.setcursor(16, 3);
  lcd.print("ms");
 
}

void showscreen3()
{
  lcd.clear();
  datetime = rtc.now();
  lcd.setcursor(1, 0);// set cursor column 1, line 0 (first row)
  lcd.print("my amazon aquarium");
  lcd.setcursor(6, 1);
  if (now.hour()<10)
  lcd.print('0');
  lcd.print(now.hour(), dec);
  lcd.print(':');
  if (now.minute()<10)
  lcd.print('0');
  lcd.print(now.minute(), dec);
  lcd.print(':');
  if (now.second()<10)
  lcd.print('0');
  lcd.print(now.second(), dec);
  lcd.setcursor(0, 2);
  lcd.print("water temp:");
  printtemperature(watertemperature);
  lcd.print((char)223);
  lcd.print("c");
  lcd.setcursor(0, 3);
  lcd.print("device temp:"); 
  printtemperature(devicetemperature);
  lcd.print((char)223);
  lcd.print("c");
 
 
}


void printtemperature(deviceaddress deviceaddress)
{
  float tempc = sensors.gettempc(deviceaddress);
  if (tempc == -127.00) {
  lcd.print("error");
  } else {
  lcd.print(tempc, 1);
}
}
void loop(void) {
  unsigned long currentlcdmillis = millis();

  // must switch screen?
  if(currentlcdmillis - previouslcdmillis > lcdinterval)              // save last time changed display
  {
    previouslcdmillis = currentlcdmillis;
    screen++;
    if (screen > screenmax) screen = 0;  // screens done? => start over
    screenchanged = true;
  }

  // debug serial.println(screen);


  // display current screen
  {
    screenchanged = false; // reset next iteration
    switch(screen)
    {
    case screen1:
      showscreen1();
      break;
    case screen2:
      showscreen2();
      break;
    case screen3:
      showscreen3();
      break;
    default:
      // cannot happen -> showerror() ?
      break;
    }
   
    const int turnheaterontemperature = 27.8;   // temperature sets heater on
    const int turnheaterofftemperature = 28.0;   // temperature sets heater off
    const int turnfanontemperature = 27.2;  // temperature sets fan on
    const int turnfanofftemperature = 27.0;  // temperature sets fan off

    sensors.requesttemperatures();
   {
    if('watertemperature' <= 'turnheaterontemperature'){
    digitalwrite(relaypinheater,high);    // sets heater on
    }
    delay(1000);
    }}}

hi,
my english not best i'm not shure if understand problem

but ds18s20 not verry exact, tolerance abou 0.5 k, think can not mesure better using this.



Arduino Forum > Using Arduino > Programming Questions > Arduino Aquarium Controller


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code