Arduino and your tank

Discussion in 'Anything DIY related' started by f-fish, Jun 30, 2012.

  1. DigiGram

    DigiGram

    Joined:
    Feb 25, 2012
    Messages:
    206
    Likes Received:
    2
    Location:
    Parys, FS
    I think you misunderstood me. I have not seen any aquarium heaters that is fitted with an earth wire. So I want to add one as a safety measure, to decrease the risk of fire. (true, I know South African law does not really like it when you increase safety...).
     
  2. Guest




  3. Hawk

    Hawk Clown Fish :-)

    Joined:
    May 25, 2012
    Messages:
    5,147
    Likes Received:
    79
    Location:
    Cape Town
    @DigiGram - Please be patient as this is not my field of expertise but if i had a light attached to an earth spike on one end and a lead on the other end into my tank, would that work? :embarrest:
     
    Last edited by a moderator: Oct 2, 2016
  4. DigiGram

    DigiGram

    Joined:
    Feb 25, 2012
    Messages:
    206
    Likes Received:
    2
    Location:
    Parys, FS
    I am patient, especially since I'm a Chemical Engineer, not an Electrical Engineer. As far as I know, it should work. Something like a DC 5V LED will not survive, but a 20W bulb might do the trick, but I have no idea and this is something I won't be able to test (live in an apartment on the top floor). This actually does increase your fire-risk, so you do this at your own risk
     
  5. Hawk

    Hawk Clown Fish :-)

    Joined:
    May 25, 2012
    Messages:
    5,147
    Likes Received:
    79
    Location:
    Cape Town
    @DigiGram - Unplug at the wall then...:bigsmile:
    Thanks guys and sorry again for the interruption.
     
    Last edited by a moderator: Oct 2, 2016
  6. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
  7. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    So after pulling my hear out with the full project loaded and crashing if found it to be memory related .. I rehashed all the code (not that it is a lot I might add) dropped all String objects - and it worked. Implemented the PString library and started clawing back some basic functionality I dropped while debuggering.

    Results are as follows.
    date rotated log file - done
    logging of multiple temp devices - done
    minimal display on LCD - done
    auto scroll of lcd buffer - to do (but needed to get the pstring stuff to work first)

    Below the sketch .. this compiles to Binary sketch size: 23,182 bytes (of a 32,256 byte maximum)

    I did a WC while monitoring the recovering water temprature ... scarry the time it takes to get back to normal, no wonder people have big fish deaths or illness after a BIG WC.

    Code:
    
    
    /*-----( Import needed libraries )-----*/
    #include <SD.h>
    #include <Dht11.h>
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    #include <OneWire.h>
    #include <RTClib.h>
    #include <DallasTemperature.h>
    #include <PString.h>
    
    RTC_DS1307 RTC;
    
    OneWire oneWire(2);
    DallasTemperature sensors(&oneWire);
    DeviceAddress Temp1 ;
    int NOTS = 0;
    int NOTSC = 0;
    
    char bufferSDate[13];
    PString strSDate(bufferSDate, sizeof(bufferSDate));
    char bufferNDate[40];
    PString strNDate(bufferNDate, sizeof(bufferNDate));
    char bufferDate[40];
    PString strDate(bufferDate, sizeof(bufferDate));
    char bufferTop[40];
    PString strTop(bufferTop, sizeof(bufferTop));
    char bufferBot[40];
    PString strBot(bufferBot, sizeof(bufferBot));
    
    LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27
    dht11 DHT11;
    #define DHT11PIN 6
    
    void setup()   /*----( SETUP: RUNS ONCE )----*/
    {
      Wire.begin();
      RTC.begin();
      // following line sets the RTC to the date & time this sketch was compiled
      //RTC.adjust(DateTime(__DATE__, __TIME__));
    
      lcd.init(); 
      lcd.backlight();
    
      pinMode(10, OUTPUT); // SD Card CS pin
      SD.begin(10);
      delay(100);
    
      sensors.begin();
      NOTSC = sensors.getDeviceCount();
      for (NOTS = 0; NOTS < NOTSC; NOTS++){
        if (!sensors.getAddress(Temp1, NOTS)) //Serial.println("Unable to find address for Device 1"); 
          sensors.setResolution(Temp1, 11);
    
      }
    }
    
    void loop()
    {
      setMDate();
      getData();
      //readLog();  
      //print to LCD 
      lcd.clear();
      lcd.print(strTop);
      lcd.setCursor(0,1);
      lcd.print(strBot);
    
      delay(300000);
    }
    
    void readLog()
    {
      Serial.begin(57600);
      File myFile = SD.open(strSDate);
      while (myFile.available()) {
        Serial.write(myFile.read());
      }
      myFile.close();
    
    }
    
    void setMDate()
    {
      DateTime now = RTC.now();
    
      // Set up filename
      strSDate=now.year();
      strSDate += now.month();
      strSDate += now.day();
      strSDate += ".txt";
    
      // Setup log Date and time
      strDate = now.year();
      strDate += "/";
      if(now.month() <10) strDate +="0";
      strDate += now.month();
      strDate += "/";
      if(now.day() <10) strDate +="0";
      strDate += now.day();
      strDate += " ";
      if(now.hour() <10) strDate +="0";
      strDate += now.hour();
      strDate += ":";
      if(now.minute() <10) strDate +="0";
      strDate += now.minute();
      strDate += ":";
      if(now.second() <10) strDate +="0";
      strDate += now.second();
    
      //Setup LCD time display 
      strNDate = "";
      if(now.hour() <10) strNDate +="0";
      strNDate += now.hour();
      strNDate += ":";
      if(now.minute() <10) strNDate +="0";
      strNDate += now.minute();
      strNDate += ":";
      if(now.second() <10) strNDate +="0";
      strNDate += now.second();
    }
    
    void getData()
    {
      File myFile = SD.open(strSDate, FILE_WRITE);
      // operate on TH sensor
      DHT11.read(DHT11PIN);
      sensors.requestTemperatures();
    
      strTop = strNDate;
      strTop += " C=";
      strTop += DHT11.temperature;
      strTop += " H=";
      strTop += DHT11.humidity;
    
    
      myFile.print(strDate);
      myFile.print(F(" Temp DHT11 "));
      myFile.println(DHT11.temperature);
    
      myFile.print(strDate);
      myFile.print(F(" Humi DHT11 "));
      myFile.println(DHT11.humidity);
    
    
      //operate on DS probes
    
      strBot = "";
      for (NOTS = 0; NOTS < NOTSC; NOTS++){
        sensors.getAddress(Temp1, NOTS);
    
        myFile.print(strDate);
        myFile.print(F(" Temp "));
        for (uint8_t i = 0; i < 8; i++)
        {
          //lcd.print(Temp1[i]);
          myFile.print(Temp1[i]);
        }
        myFile.print(" ");
        myFile.println(sensors.getTempCByIndex(NOTS));
    
        strBot += NOTS;
        strBot += "=";
        strBot += sensors.getTempCByIndex(NOTS);
        strBot += " ";
      }
      myFile.close();
    }
    
    
    Later Ferdie
     
  8. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Slow day on TASA ... I used the time to research some 433MHz eavesdropping, the idea would be to use this to listen in on my oregon probes and log that data also .. this includes 1 thermo-hygro meter, 1 water probe a UV meter and normal temp meter. Looking at some sample code this seems doable .. just not sure I have enough memory capacity left on the current dev board .. might need to go mega.

    Oh and I need to get a 433Mhz receiver .. details details details

    Later Ferdie
     
  9. butcherman

    butcherman Administrator

    Joined:
    Apr 30, 2009
    Messages:
    1,583
    Likes Received:
    19
    Location:
    Kempton Park
    I love reading these tech threads! good job so far!
     
  10. KillerBunny

    KillerBunny

    Joined:
    Jul 13, 2012
    Messages:
    182
    Likes Received:
    9
    Location:
    Krugersdorp
    I have used the RFM12B previously... Very simple to use with Arduino, and nice and cheap:
    RFM12B-S2 Wireless Transceiver | Wireless | Electronics | Netram Technologies

    Also, have a look at the Jeelabs blog - Lots of information on the RFM12B and he has even done some work decoding the protocol of the Oregon sensors:
    http://jeelabs.org/2010/04/15/oregon-sensors/

     
  11. Zoom

    Zoom Retired Moderator

    Joined:
    Apr 13, 2009
    Messages:
    8,459
    Likes Received:
    107
    Location:
    Jhb- Roodepoort
    All I have to say is:

    Ferdie... check you are on the correct forum. This is a fish forum... I think you are posting "nerdy stuff" in the wrong text box...

    Zoom run's and hide's before :hitfan:
     
  12. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    LOL @Zoom ..actually posting the nerdy stuff is 1) a backup 2) to show how simple it is to do this type of thing 3) more nerdy stuff will follow to support 1 and 2 ;-) - trust me it all ties back to the fish and tanks.

    Got a few experiments planned
    1) WC impact on water temp and power consumption to get the tanks back to the correct temp
    2) water temp and evaporation - what is the relationship
    3) 4 point temp compare in a tank (i.e. temp bands in low flow tanks)
    and so the list goes on

    Thanks @KillerBunny ... yeap that is the puppy I am after - order placed, he he he - spend loads of time on jeelabs not so sure about the ordering and SAPO if I can not get insurance on it, but good content and some solid sketches.
     
    Last edited by a moderator: Oct 2, 2016
  13. hadiosbourne

    hadiosbourne

    Joined:
    Aug 13, 2012
    Messages:
    23
    Likes Received:
    1
    Very interesting,
    I recently became interested in doing a controller for my system, expect i don't have much programming skills:D
    I've ordered the Raspbery Pi Since they make a much better web server, but the backorder is massive,
    I'll probably get mine in december , Will keep you posted once it arrived
     
  14. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Yeah the Pi's are cool - also get some expansion boards will make interfacing much simpler. Truth is arduino is very easy to use esp with sensors and the like. Loads of examples on the web etc. Hope your Pi is going to be more than just another PC project or media centre, but for the size and versatility if you put your mind to it it sure is a nice bit of silicone.

    Quick update on the project .. well everything is working as coded ... been running for a week doing daily log rotation each file is 60K giving 1435 lines of logs. I have had zero time to play on this so none of the other stuff has been happening in the background.
     
  15. hadiosbourne

    hadiosbourne

    Joined:
    Aug 13, 2012
    Messages:
    23
    Likes Received:
    1
    Yeah, i know the possibilites are endless with these kits, but i'm going to get the basic stuff running first, then will start expanding it into a kick-ass controller,
    Gonna need everyone's help though,
    what type of expansion board i should take? and where?
     
  16. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    So the logger has been running for a while now -- I glance over at the LCD to check if the RTC is still true and let it be ... decided to pull some of those logs and see what the room and lucky 13 looks like on the temp side.

    I took the pivot'ed data

    [TABLE="width: 790"]
    [TR]
    [TD][/TD]
    [TD]Temp 401931558400243[/TD]
    [TD]Temp 402381788400106[/TD]
    [TD]Temp 402511128400123[/TD]
    [TD]Temp DHT11
    [/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:30[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]16[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:35[/TD]
    [TD="align: right"]18.44[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:40[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:45[/TD]
    [TD="align: right"]18.62[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:50[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 22:55[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:00[/TD]
    [TD="align: right"]18.56[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:05[/TD]
    [TD="align: right"]18.31[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:10[/TD]
    [TD="align: right"]18.25[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:15[/TD]
    [TD="align: right"]18.37[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:20[/TD]
    [TD="align: right"]18.44[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:25[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:30[/TD]
    [TD="align: right"]18.5[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:35[/TD]
    [TD="align: right"]18.62[/TD]
    [TD="align: right"]24.37[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:40[/TD]
    [TD="align: right"]18.75[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]16[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:45[/TD]
    [TD="align: right"]18.69[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.31[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:50[/TD]
    [TD="align: right"]18.69[/TD]
    [TD="align: right"]24.44[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/30/12 23:55[/TD]
    [TD="align: right"]18.62[/TD]
    [TD="align: right"]24.56[/TD]
    [TD="align: right"]24.25[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [TR]
    [TD="align: right"]7/31/12 0:00[/TD]
    [TD="align: right"]18.56[/TD]
    [TD="align: right"]24.5[/TD]
    [TD="align: right"]24.19[/TD]
    [TD="align: right"]15[/TD]
    [/TR]
    [/TABLE]


    100 000 odd lines and made excel do the work (I really need to pump this to a rrd at some stage)
    Sept-Oct Temp.jpg

    Here you can clearly see when I removed the heater from the tank (beginning October) and that the room on avg stay above 15 degrees ..

    Green tank temperature and red the room.

    Below the associated humidity for the room.

    humisept-Oct.png


    Logger is still running - so lets see.

    Later Ferdie

    Sept-Oct Temp.jpg

    humisept-Oct.png
     
    Last edited: Oct 13, 2012
  17. Pauline

    Pauline Guest

    @f-fish and @Zoom - aren't IT techy people and fish people both nerdy types? I thought that was our claim to fame? ;) :p
     
    Last edited by a moderator: Oct 2, 2016
  18. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    @Pauline lol ..... yeah must be the simplicity found in a tank, BTW I have been hypnotized by my tanks before. Was doing the morning feed had a seat to watch them eat - lost 45 minutes that morning
     
    Last edited by a moderator: Oct 2, 2016
  19. Pauline

    Pauline Guest

    Love that :) we used to eat supper watching the tank at one stage LOL

    there's always something interesting to see, and the view changes constantly :)


    My favourite moment was when I added snail killer to a tank and we poured some red wine and watched them die :)
     
  20. Jagwa

    Jagwa

    Joined:
    Mar 30, 2010
    Messages:
    141
    Likes Received:
    0
    Location:
    Newlands, Cape Town
    Haha
     
  21. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    The logging has been working without any issues, got myself a PI to play with - no not a movie player. want to know what a PI is see

    I know I can use the io ports on the PI to do most of what I do on the arduino, but I like both for different reasons.

    So the plan:

    remove the LCD from the arduino - maybe take it to the PI.. I will probably leave the SD card and RTC on the arduino with all the probes - with the LCD library and sketch gone I will have some memory to do more sensors on the arduino.

    use the PI's USB to power and interact with the arduino, this leave the GPIO for other stuff.

    on the RPI
    pi@raspberrypi ~ $ uname -a
    Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
    I use mobaxterm it has a xserver, in 6.1 you can even select environment you want to work in LXDE or openbox on the stock wheezy - nice for doing direct development and programming the arduino straight from the pi and the arduino IDE.

    Later Ferdie
     

Recent Posts

Loading...
Similar Threads - Arduino tank Forum Date
Arduino Controlled Tank Members Systems Jul 13, 2012
Arduino controll General Discussions Oct 18, 2014
Fish tank movers General Discussions Monday at 4:25 PM
My tank since no one wanted it! Full tank shots Sunday at 5:50 PM
Tank for growing plants. Beginner Discussions Jan 20, 2020
Freebie: Tank trim Wanted/Swop/Freebies Jan 15, 2020
Where it all began - Show your first tank General Fish Discussions Jan 12, 2020

Share This Page