Arduino and your tank

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

  1. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Almost 3 years running without missing a beat on the original arduino project, time to take the next step. Here is hoping the that the next bit lasts 3 years again. True the PI is cool - heaven knows I have several of them either running ADS-B feeds, cameras or some probes or even low power emergency PC if we have a power outage and I need to get some work done.

    The original stilling running ..
    [​IMG]

    But after looking at the stability of the original project - I still think arduino is the way to go for something that you do not want to patch every second week.
    [​IMG]

    Been collecting some new toys - and the time might be right, plan is still fuzzy, idea is to use a Yun - either a 4 line display or the 2 line with buttons, probably the 4+ probes and some higher resolution humidity sensors. Have a lux chip in the mix, some relays a switch-mode 12 -> 5 volt supply - will use a 12V 7A alarm battery to keep it running during load shredding.

    Later Ferdie

    take2datalogger.jpg

    take1datalogger.jpg
     
    Last edited: May 27, 2015
  2. Guest




  3. Wazi

    Wazi

    Joined:
    Jan 28, 2011
    Messages:
    157
    Likes Received:
    1
    Location:
    Alberton
    Def tagging along. Im also busy with a arduino tank project.
     
  4. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    you know it is ruff when you look-up at your project that has now been running for a few years ... and you display shows the following.

    ruff.jpg

    hmmm time for a reboot, clearly the lack of load shredding is having an affect or is the universe trying to say something? Clearly the universe does not have a TASA account - it just have PM'ed me, like really-now!!!


    Latar Ferdie

    ruff.jpg
     
    Last edited: Sep 27, 2015
  5. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    ruff01.jpg

    oK back in business .. RTC is a bit off ... main reason why I like NTP even with lead seconds.

    Yes room temp is 23
    and two of the tanks 24.37 and 24.00

    Later Ferdie

    ruff01.jpg
     
    Last edited: Sep 27, 2015
  6. neltf

    neltf

    Joined:
    Jun 29, 2014
    Messages:
    2,223
    Likes Received:
    147
    Location:
    Boksburg
    Now this is a cool gaget...
     
    Last edited: Sep 28, 2015
  7. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    So the Yun has been waiting for some attention.

    I would like to see what I can get migrated today from the old UNO to the YUN.

    [​IMG]

    Lets see, no clue how long this will take.

    Later Ferdie
     
  8. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    The actual changes to the code did not take all that long, spend a good while tracking down a BUG in the i2c display library with the new IDE.

    While I was at it I changed the 2 line display for a 4 line version. Cleaned up the breadboard to make adding probes easier.
    [​IMG]

    The Wifi on the YUN is a total treat. I am for now logging directly to a single file that the uHTTP server will then allow me to graph via dyGraph .. but still need to play with that.


    Output to the server ..
    2016/01/17 15:30:29,Temp,DHT11,26
    2016/01/17 15:30:29,Hum,DHT11,26
    2016/01/17 15:30:29,Temp,0,24.75
    2016/01/17 15:30:29,Temp,1,24.38
    2016/01/17 15:30:29,Temp,2,24.50

    Later Ferdie
     
  9. BadgerBadger

    BadgerBadger

    Joined:
    Jan 16, 2015
    Messages:
    426
    Likes Received:
    36
    Location:
    Pretoria
    Very cool! How difficult was the programming component?
     
  10. Wazi

    Wazi

    Joined:
    Jan 28, 2011
    Messages:
    157
    Likes Received:
    1
    Location:
    Alberton
    Awesome. Looking good. I need to dig out my old arduino project, never actually finished the prototype. Are you just using it for data logging or are you controlling the lighting and temp of the tank?
     
  11. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Actually simple, wish I could play with these things more often, ... once you have all the working libraries. (Basically took the code that I had from the UNO and re-factored it for the YUN). The nice thing about the YUN, because it is a networked device, I did not need to bother with the Real-Time-Clock, rather using NTP from a time server - works way better already. Also the SD card I used in the past is now not needed since I use the linux filsystem's storage.

    Here is the ruff code that still I need to sit and optimize, but for now it is working OK. (Yes this is my backup copy now, used the previous code form way back as the starting point)

    Code:
    
    
    
    
    
    /*-----( Import needed libraries )-----*/
    #include <Dht11.h>
    #include <LiquidCrystal_I2C.h>
    #include <Wire.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #include <PString.h>
    #include <FileIO.h>
    
    
    
    
    OneWire oneWire(4);
    DallasTemperature sensors(&oneWire);
    DeviceAddress Temp1 ;
    int NOTS = 0;
    int NOTSC = 0;
    int LogCount = 0; 
    
    
    
    
    char bufferNDate[20];
    PString strNDate(bufferNDate, sizeof(bufferNDate));
    char bufferTop[20];
    PString strTop(bufferTop, sizeof(bufferTop));
    char bufferBot[20];
    PString strBot(bufferBot, sizeof(bufferBot));
    char bufferLog[20];
    PString strLog(bufferLog, sizeof(bufferBot));
    
    
    LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27
    dht11 DHT11;
    #define DHT11PIN 6
    
    
    void setup()   /*----( SETUP: RUNS ONCE )----*/
    {
      Wire.begin();
    
    
      lcd.init(); 
      lcd.backlight();               // initialize the lcd 
    
    
      lcd.home ();                   // go home
      lcd.print("Hello booting ");  
      lcd.setCursor ( 0, 1 );        // go to the next line
      lcd.print (" Waiting  "); 
      delay(1000);
    
    
    
    
      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);
    
    
      }
        Serial.begin(9600);
        Bridge.begin();
      
      FileSystem.begin();
    
    
      while(!Serial);  
      Serial.println("Filesystem datalogger\n");
    }
    
    
    void loop()
    {
      setMDate();
    
    
      getData();
    
    
      lcd.clear();
      lcd.print(strTop);
      lcd.setCursor(0,1);
      lcd.print(strBot);
      lcd.setCursor(3,3);
      strLog += LogCount;
      lcd.print(strLog);
      LogCount = 0;
      
    
    
    
    
      delay(300000);
    }
    
    
    
    
    
    
    void setMDate()
    {
    
    
      //Setup LCD time display 
      strNDate = getTimeStamp();
    }
    
    
    void getData()
    {
    
    
        // Set up filename
    String strSDate = String(getDateStamp());
    
    
      // Setup log Date and time
     String strDate = String(getDateTimeStamp());
    
    
      DHT11.read(DHT11PIN);
      sensors.requestTemperatures();
      int DHT = DHT11.temperature;
      int DHH = DHT11.humidity;
      
      lcd.clear();
      strLog ="Logged: ";
      strTop = strNDate;
      strTop += " DHT11 ";
      strTop += DHT;
      strTop += "C ";
      strTop += DHH;
      strTop += "%";
    
    
    
    
    
    
    String logDHT = String(strDate + ",Temp,DHT11," + DHT);
      writeLog(logDHT);
    String logDHH = String(strDate + ",Hum,DHT11," + DHH);
      writeLog(logDHH);
    
    
      //operate on DS probes
    
    
      strBot = "";
      for (NOTS = 0; NOTS < NOTSC; NOTS++){
          
      String logPT = String(strDate + ",Temp,"+ NOTS+","+ sensors.getTempCByIndex(NOTS));
      writeLog(logPT);
    
    
    
    
        strBot += sensors.getTempCByIndex(NOTS);
        strBot += "C ";
       
      } 
    
    
    }
    
    
    String getDateTimeStamp() {
      String result;
      Process time;
      time.begin("date");
      time.addParameter("+%Y/%m/%d\ %H:%M:%S");  
      time.run(); 
    
    
      while(time.available()>0) {
        char c = time.read();
        if(c != '\n')
          result += c;
      }
    
    
      return result;
    }
    
    
    String getTimeStamp() {
      String result;
      Process time;
      time.begin("date");
      time.addParameter("+%H:%M");  
      time.run(); 
    
    
      while(time.available()>0) {
        char c = time.read();
        if(c != '\n')
          result += c;
      }
    
    
      return result;
    }
    
    
    String getDateStamp() {
      String result;
      Process time;
      time.begin("date");
      time.addParameter("+%Y%m%d");  
      time.run(); 
    
    
      while(time.available()>0) {
        char c = time.read();
        if(c != '\n')
          result += c;
      }
    
    
      return result;
    }
    
    
    void writeLog(String dataString)
    {
    File dataFile = FileSystem.open("/mnt/sda1/arduino/www/log/datalogger.txt", FILE_APPEND);
      if (dataFile) { 
        digitalWrite(13, HIGH);
         dataFile.println(dataString);
        dataFile.close();
        Serial.println(dataString);
        LogCount++;
      
          
      }
    
    
      else {
        Serial.println("error opening datalog.txt");
      } 
      
    }
    
    
     
  12. BadgerBadger

    BadgerBadger

    Joined:
    Jan 16, 2015
    Messages:
    426
    Likes Received:
    36
    Location:
    Pretoria
    Cool, thanks! Will check it out tomorrow on my PC so I can step through the code. Did you have to create any of your own custom libraries, or were the usual libraries sufficient?
     
  13. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Thanks Wazi.

    Today's aim was just to replace the Uno. Now that I have a linux prompt on the other side controlling vs just logging is a real option. Nice thing about the YUN for that .. it speaks REST.

    For today it is still just logging.

    But have the other bits laying around - first want to check stability.

    The sketch is already a memory beast. Might not get bridge and Server stuff loaded in the remaining space. Time will tell.

    Later Ferdie
     
  14. Wazi

    Wazi

    Joined:
    Jan 28, 2011
    Messages:
    157
    Likes Received:
    1
    Location:
    Alberton
    Nice. I'm using the mega at the moment. It controls the lighting heating and pumps while feeding. It also controls the fans for cooling and the lights. Man I need to find some time to get it all working again.
     
  15. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Most of the libraries are Stock

    Think #include <PString.h> #include <Dht11.h> #include <LiquidCrystal_I2C.h> are of different sources. Rest are stock ..

    Yeah the code is messy - I need to fix the multiple date functions, should be one with a bit of string manipulation.
    One flow error for the last probe temp (no C is being appended)


    Later Ferdie

    BTW if you get a
    LiquidCrystal_I2C.h library and you only see the first char on your display - do not spend hours debbugering it. It is actually a issue between what the latest IDE thinks a valid return should be. So a dirty patch to you ccp should fix that. Shout if you have the same issues.

     
  16. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Yeap Mega has just that extra bit of memory to make it all stick nicely.

    Can you remember what the compiled size of your sketch was?

    Later Ferdie
     
  17. Wazi

    Wazi

    Joined:
    Jan 28, 2011
    Messages:
    157
    Likes Received:
    1
    Location:
    Alberton
    Lol. Just got the code and compiled. It says 122,596 bytes. The mega has 256. So it's only half at the moment.
     
  18. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Code still running rock solid no issues.

    running.jpg

    Had to grey scale the image to see in the dark ;-)

    Later Ferdie

    running.jpg
     
  19. OP
    f-fish

    f-fish #unspecified

    Joined:
    Jun 27, 2009
    Messages:
    9,294
    Likes Received:
    1,869
    Location:
    JHB - Randburg
    Bit of an odd post .. here goes.

    Happened past a toy shop today .... spotted some lego. Hmmm ... looked at what they had, nothing got my fancy.

    Now just to put things into perspective, I have not played with lego for decades and non of this pre-shaped stuff made any sense. I got home at went on an epic voyage, to find my old toy case and build something.

    [​IMG]

    I ended building a mount for the arduino display.

    [​IMG]

    Got into the swing of things and ended with a custom block for the Yun , display and the breadboard.

    [​IMG]

    It is a very tight fit ... I like the net result.

    [​IMG]

    While at is I did a custom enclosure for the raspberry pi 2 and a touch screen.

    [​IMG]

    Another tight fit.

    [​IMG]

    Added a camera mount.


    All in all a fun few hours .... boy the brain get old quick. I found myself counting block sizes cause I did not recognise them by touch. But still, loads of fun was had.

    Hopefully I will play ... ah build stuff from lego again soon and not wait a few more decades.

    Later Ferdie
     
  20. Wazi

    Wazi

    Joined:
    Jan 28, 2011
    Messages:
    157
    Likes Received:
    1
    Location:
    Alberton
    Dude, I think you are showing your age.... Lol awesome looking mounts though.
     
  21. Subaman

    Subaman

    Joined:
    Nov 15, 2015
    Messages:
    85
    Likes Received:
    0
    Location:
    Gauteng
    How many temp probes can you connect to a single setup, be it raspberry pi, yun, or arduino?
     

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