DIY Raspberry PI Tank Monitor Project

Discussion in 'Equipment / DIY / Reviews' started by Rob, Jun 5, 2012.

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Users Viewing Thread (Users: 0, Guests: 0)

  1. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    @Rob
    Hi Rob,
    Ok, I wish to run the project!
    Please send me the link and follow the instructions.:)
    Last edited: Nov 26, 2014
  2. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    @Rob
    Hi Rob,
    I still need an instruction for the temperature adjustment of the pH probe because the temperature in the pond so very fluctuating.
    I want the program realiesieren a DS18B20 Automatic.
    How can that be considered?

    Command syntax
    (Using an example temperature 19.5)
    T,19.5<CR> Where the temperature is any value; floating point or int, in ASCII form
    T,?<CR> Query the set temperature

    T,?<CR>????????????????????????
    Last edited: Nov 26, 2014
  3. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    Yes O.K.
  4. Rob

    Rob Member

    Messages:
    879
    Ratings:
    +708
    Country:
    Australia
    State:
    Victoria
    • Funny Funny x 1
  5. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    Thank you for the work Freundschaftspins-Deutschland-Australien.jpg
    A great project
  6. Clownfishy

    Clownfishy Member

    Messages:
    98
    Ratings:
    +16
    Country:
    United Kingdom
    State:
    Gloucestershire
    Just logged back in after being a way a while. Any further update on this project that Rob started? Is there still much interest in this project? If so, more than happy to help with the documentation. I have included the latest version below and can upload a PDF version if I can have a login to the project site. I have been using my AquaPi to monitor the temp since seeing this post and it is perfect so would like to see the project progress further. dump the data to a sqlite DB and push the statistics up to a friends webserver I have access to. Simply but effective as I can keep an eye on my reef temp anywhere in the world!! ore than happy to include these details if people would be interested http://www/coldaston.com/temp.php.

    Documentation So Far -

    Hardware Build
    Hardware Requirements
    The AquaPi requires the following hardware to be purchased.


    Raspberry Pi Style A or B
    Both the Raspberry Pi Model A and Model B is suitable for the tank monitor. These can be ordered from many places including-

    http://uk.farnell.com/raspberry-pi/raspberry-moda-256m/sbc-raspberry-pi-model-a-256mb/dp/2254699#

    http://uk.rs-online.com/web/generalDisplay.html?id=raspberrypi

    alh4_googleusercontent_com_229iTf5oQ_JoYv2pHG209aKZbg5Vh602Y8xc641166dedc03c36a813a7c7ddb0e05d.png


    AB Electronics 1 Wire Pi
    Used to connect the temperature probes to the Raspberry Pi.

    https://www.abelectronics.co.uk/products/3/Raspberry-Pi/27/1-Wire-Pi

    alh6_googleusercontent_com_W5nvfZbjISZJygR6b6ou7GcH9YP5XBPXvii3f17c3c408d3a2c02049c4446dd41d6c.png

    Waterproof Temperature Probes
    Waterproof temperature probes which are saltwater safe.

    http://littlebirdelectronics.com/products/temperature-sensor-waterproof-ds18b20

    alh6_googleusercontent_com_TiuNUJ4Qh69uqkWA6__flp__dqlM2taAVF65fa1a4af1a85e1869b0cc3e567956c2d.png

    Hardware Section Still To Be Completed

    Need to add all the hardware and wiring details listed here


    Software Build
    Raspbian
    The first thing you will need to start to build your AquaPi is an SD Card built with the Raspbian operating system. For those new to Raspberry Pi's, Raspbian is a Linux based operating system distribution which is used to start up your Raspberry Pi. To put it another way, the Raspberry Pi is the hardware, Raspbian is the base software to power the Raspberry Pi hardware and then applications are layered on top of the base operating system software to run the AquaPi.

    This guide provides some basic information on building the SD Card but for further detail, please refer to the Raspberry Pi website.

    References:

    Raspberry Pi SD Card Setup

    http://elinux.org/RPi_Easy_SD_Card_Setup

    Raspbian Download

    http://www.raspberrypi.org/downloads


    Note: The following instructions have been written installing AquaPi from a Ubuntu Linux PC.


    Install Raspbain by copying the Raspbian image to the SD Card. Example:

    sudo dd bs=4M if=2014-09-09-wheezy-raspbian of=/dev/mmcblk0

    Note: Note that when specifying “of=/dev/device-name-mounted-by-linux” this is the device name not the partition name.



    Wifi Configuration
    If you wish your Raspberry Pi to connect to your home network router wirelessly, the Raspbian operating system must know the configuration of your home network. This information is stored in a file named interfaces and can be found in the directory /etc/network. Edit this file using your favorite text editor and amend the file to the following configuration.

    auto wlan0

    iface wlan0 inet dhcp

    wpa-ssid your-wifi-name

    wpa-psk your-password

    wireless-power off

    Although beyond the scope of this document, you may wish to configure your home wireless router to allocate the same IP address to your Raspberry Pi each time it is rebooted by assigning your chosen IP address to the MAC address from the Raspberry Pi wireless USB adapter. If you choose not to do this, your Raspberry Pi will be allocated a random IP address each time it is rebooted. However you wish to configure the IP address, make a note of the address as it will be needed in order to login to your Raspberry Pi.




    Raspbian Configuration
    Once you have powered on your Raspberry Pi, you should now be able to connect to it from another Linux computer using ssh. To do this run the command

    ssh -l pi the-ip-address-of-your-Raspberry-Pi

    Example: ssh -l pi 192.168.1.200

    You will be prompted for a password which is

    raspberry


    You can now update the image with the latest firmware. Run the following, reboot and login again using the previous login details.

    sudo rpi-update


    Once logged in, you have the ability to configure the Raspbian operating system with some basic settings and to do this type

    sudo raspi-config

    The basic configuration is to expand the Raspbian image which will ensure Raspbian uses all the space available on the SD Card. You can also change things such as the username and password which is used to log into the Raspberry Pi and setting the hostname of the Raspberry Pi.

    After another reboot, it is time to ensure that Raspbian is updated with any patched software that have been released since the Raspbian image was created. This should be done on a regular basis to ensure your Raspberry Pi’s software is secure. To do this type the following commands and answer Yes to any prompts asking you to install software.

    sudo apt-get update

    sudo apt-get upgrade


    Reboot your Raspberry Pi by entering the command

    sudo reboot


    Once rebooted, connect to your Raspberry Pi again

    ssh -l pi the-ip-address-of-your-Raspberry-Pi


    Now run the following command to remove all the old Raspian packages

    sudo apt-get autoclean


    1-Wire Configuration
    Raspian needs a number of configuration changes and additional software in order for it to communicate to the 1-wire Pi board. The first configuration change is to the raspi-blacklist.conf file. To edit this file enter:

    sudo nano /etc/modprobe.d/raspi-blacklist.conf

    Add # before the line “blacklist i2c-bcm2708” and then save this file.

    Example: #blacklist i2c-bcm2708


    Now we need to make a change to the modules file. To edit this file enter:

    sudo nano /etc/modules

    Add new line containing the following and then save the file.

    i2c-dev


    Now install some additional software but entering the command:

    sudo apt-get install automake autoconf autotools-dev gcc-4.7 libtool libusb-dev libfuse-dev swig python2.6-dev tcl8.4-dev php5-dev i2c-tools


    Once this software has been installed, reboot the Raspberry Pi using the command:

    sudo reboot


    After the Raspberry Pi has completed its reboot, connect to the Raspberry Pi and enter the command:

    sudo i2cdetect -y 1

    If everything is working correctly, the 1wire board should connect to the Raspberry Pi at I2C address 18 and successfully display:


    0 1 2 3 4 5 6 7 8 9 a b c d e f

    00: -- -- -- -- -- -- -- -- -- -- -- -- --

    10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --

    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    70: -- -- -- -- -- -- -- --



    OWFS 1 Wire Filesystem
    Now the base Raspbian operating system is installed, configured and updated we are now ready to move onto the next step and layer the OWFS file system software onto Raspbian.

    First, from your Linux computer, download the latest 1-wire filesystem from

    http://owfs.org/index.php?page=download


    You will then need to transfer this file to your Raspberry Pi by using the command

    scp 1-wire-filename Raspberry-Pi-username@ the-ip-address-of-your-Raspberry-Pi:/usr/src

    Example: scp owfs-2.9p8.tar.gz pi@192.168.1.200:/usr.src


    The password you are prompted for is the password you set on your Raspberry Pi if you changed it. If not, the password will be raspberry.

    The 1-wire filesystem you transferred to the Raspberry Pi will be compressed also known as tar. You will now need to uncompress, untar the file before you can begin setting up the 1-wire filesystem. To do this type the following on your Raspberry Pi:

    cd /usr/src

    tar xvzf 1-wire-filename

    Example: tar xvzf owfs-2.9p1.tar.gz


    Now type the following commands below to compile the 1-wire software:

    cd 1-wire-filename

    sudo ./configure

    Note: This command will take approximately 3 minutes to complete.

    sudo make

    Note: This command will take approximately 30 minutes to complete.

    sudo make install

    Note: This command will take approximately 3 minutes to complete.

    sudo mkdir /mnt/1wire

    sudo nano /etc/fuse.conf

    Update the line “#user_allow_other” and remove the # from the start, then save your changes.
    Last edited: Jan 4, 2015
    • Like Like x 1
  7. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    "Clownfishy, http: //www/coldaston.com/temp.php ."


    @Clownfishy

    Howdy, it is a bit too complicated.
    The time you broke 1-Wire Configuration and no more OWFS 1 Wire Filesystem.

    Enable 1-wire GPIO
    os.system("modprobe w1-gpio")
    os.system("modprobe w1-therm")
    Enabled automatically adding these 2 lines to /etc/modules:
    w1-gpio
    w1-therm

    #!/bin/bash

    ### Temperatur des Sensors auslesen vom 1wire Bus ###

    Sensor1=$228-00000sdef7ccbc

    tempread=`cat /sys/bus/w1/devices/$Sensor1/w1_slave`
    if [ $? -ne 1 ]
    then
    TEMPERATURE=$(echo -e "$tempread" | grep "t=" | cut -f 2 -d "=")
    INTEGER=${TEMPERATURE:0:(-3)}
    FRACTION=${TEMPERATURE:(-3)}

    # Restore the leading 0 for positive and negative numbers
    if [ -z $INTEGER ]
    then
    INTEGER="0"
    fi
    if [ "$INTEGER" == "-" ]
    then
    INTEGER="-0"
    fi
    temp=$INTEGER.$FRACTION
    TempAb=$($x | $AWK 'BEGIN {printf "%.0f\n", ARGV[1] }' "$temp")
    else
    # A CRC was found, show error message instead
    echo "Sensor TempAb $Sensor1 = CRC error"
    fi

    Last edited: Jan 4, 2015
  8. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    @macca_75

    Hello macca_75,

    please can i have info about your http://macca.myreef.info/weekly.html?

    How do you write the data to the 24_average_ph.txt or weekly_average_ph.txt files?

    What is the script with RRDtoll ?


    rrdtool dump
    rrdtool fetch
    rrdtool xport

    No matter what I suppose it does not work!!!!



    Sorry for my bad english!
    Last edited: Jan 4, 2015
  9. macca_75

    macca_75 Member

    Messages:
    2,281
    Ratings:
    +1,202
    Country:
    Australia
    State:
    Vic
    Sorry @onkel.paul - it totally slipped my mind. I'll try and get it tonight.
    • Cheers! Cheers! x 1
  10. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    @macca_75
    Ok never mind is in order.
    Your info.html is really great !!!

    It would be nice if you can send me the script.

    Greetings from Paul ;)
  11. macca_75

    macca_75 Member

    Messages:
    2,281
    Ratings:
    +1,202
    Country:
    Australia
    State:
    Vic
    Will do @onkel.paul

    I went to get it last night, but the PI isn't responding. I suspect its something I did (caused it to run out of disk space). I need to hook it up to the TV and try and boot to confirm.
  12. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW

    Hello @macca_75,@Rob,
    I am surprised that your myreef.info/daily.html is no longer online.
    Is this due to me or to the beautiful weather in Australia?
    Rob`s Pi is. Also no longer online.
    Too bad it not been online since I could learn from it a lot!
    For me, winter is around 2 ° C.

    Thanks to pray here!!!!

    It may be that my eglisch not always true is please to to excuse!

    For your further help, I would be happy !!!!!

    21.jpg

    BILD0448.JPG
    Oxygen and salinity may come. 7.jpg

    A temperature-adjusting the Ph. Probes I succeeded.
    Since the temperature in the pond varies more than in Saltwater Reef Aquariums


    1*
    .
    .
    .
    .
    printf "$Tempkomp\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    printf "$Tempkomp\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    sleep 2
    printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 2
    kill $bkgPID >/dev/null
    .
    .


    1* ### TempAb temperature adjustment of the sensor read out from 1wire bus ###

    Sensor1=$228-00000677ccbc

    tempread=`cat /sys/bus/w1/devices/$Sensor1/w1_slave`
    if [ $? -ne 1 ]
    then
    TEMPERATURE=$(echo -e "$tempread" | grep "t=" | cut -f 2 -d "=")
    INTEGER=${TEMPERATURE:0: (-3)}
    FRACTION=${TEMPERATURE: (-3)}

    # Restore the leading 0 for positive and negative numbers
    if [ -z $INTEGER ]
    then
    INTEGER="0"
    fi
    if [ "$INTEGER" == "-" ]
    then
    INTEGER="-0"
    fi
    temp=$INTEGER.$FRACTION
    TempAb=$($x | $AWK 'BEGIN {printf "%.0f\n", ARGV[1] }' "$temp")
    else
    # A CRC was found, show error message instead
    echo "Sensor TempAb $Sensor1 = CRC error"
    fi


    #### Conversion Decimal to Hex for the temperature compensation pH reading ####

    Tempkomp="\x"$(for letter in $(echo "$TempAb" | sed "s/\(.\)/'\1 /g");do printf '%x' "$letter";done)

    .
    .
    .
    .
    printf "$Tempkomp\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    printf "$Tempkomp\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    sleep 2
    printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 1
    printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 2
    kill $bkgPID >/dev/null
    Last edited: Jan 7, 2015
  13. Rob

    Rob Member

    Messages:
    879
    Ratings:
    +708
    Country:
    Australia
    State:
    Victoria
    @onkel.paul nice with the temperature correction

    I was very slack and never configured a static IP and my router decided to renew my Aqupi's IP address. I spent 30 seconds and now use a static IP which I should of done in the first place...:banghead
    • Funny Funny x 1
  14. macca_75

    macca_75 Member

    Messages:
    2,281
    Ratings:
    +1,202
    Country:
    Australia
    State:
    Vic
    Hi @onkel.paul

    My PI isn't of by choice, I need to look at it as something went wrong - I just haven't had time yet. Should be back online soon and I can get those scripts you are after.
  15. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    @Rob Hei,

    yes he is back online.
    Do you still have more tips for me?

    I'm still looking for a solution as times from the RddTool the data for only 24 PH, 24. only ORP, 24. only temp., 24. Time data back writes to a .txt.
    As with http://macca.myreef.info/daily.html
  16. Rob

    Rob Member

    Messages:
    879
    Ratings:
    +708
    Country:
    Australia
    State:
    Victoria
    It looks like Macca needs to rebuild his Pi so we will create a script file to create the empty rrdtool database. I did have a script however have looked a number of times for this however cannot find it. From my memory you need to create a rrdfile correct ?
  17. macca_75

    macca_75 Member

    Messages:
    2,281
    Ratings:
    +1,202
    Country:
    Australia
    State:
    Vic
    Buying a new SD card this arvo. Give me something to do if I get some down time on the weekend.
  18. Rob

    Rob Member

    Messages:
    879
    Ratings:
    +708
    Country:
    Australia
    State:
    Victoria
    I found my rrd build scripts... OK I stole them back from maccas sdcard as I had really lost them :D You really need to read the rrdtools website info to understand what the following means. Although in a nut shell it creates an empty file structure which allows you to store up to 10 variables called pnt_1 - pnt_10 and can hold consolidated data history as per the comments below.

    Code:
    #!/bin/sh
    
    # Update interval is 5 min (300 seconds)
    # ROWS x SAMPLE x STEP
    
    # 10000 x 1   x (300) =   35 days   (5 min  steps)
    # 15000 x 6   x (300) =   312 days  (30 min steps)
    # 20000 x 12  x (300) =   2.2 years (1 hr   steps)
    # 20000 x 24  x (300) =   4.5 years (2 hr   steps)
    # 20000 x 48  x (300) =   9   years (4 hr   steps)
    
    
    rrdtool create /var/www/rrd/Marine.rrd --step 300 \
    DS:pnt_1:GAUGE:600:-10:1000 \
    DS:pnt_2:GAUGE:600:-10:1000 \
    DS:pnt_3:GAUGE:600:-10:1000 \
    DS:pnt_4:GAUGE:600:-10:1000 \
    DS:pnt_5:GAUGE:600:-10:1000 \
    DS:pnt_6:GAUGE:600:-10:1000 \
    DS:pnt_7:GAUGE:600:-10:1000 \
    DS:pnt_8:GAUGE:600:-10:10000 \
    DS:pnt_9:GAUGE:600:-10:10000 \
    DS:pnt_10:GAUGE:600:-10:10000 \
    RRA:AVERAGE:0.5:1:10000 \
    RRA:MAX:0.5:1:10000 \
    RRA:MIN:0.5:1:10000 \
    RRA:AVERAGE:0.5:6:15000 \
    RRA:MIN:0.5:6:15000 \
    RRA:MAX:0.5:6:15000 \
    RRA:AVERAGE:0.5:12:20000 \
    RRA:MIN:0.5:12:20000 \
    RRA:MAX:0.5:12:20000 \
    RRA:AVERAGE:0.5:24:20000 \
    RRA:MIN:0.5:24:20000 \
    RRA:MAX:0.5:24:20000 \
    RRA:AVERAGE:0.5:48:20000 \
    RRA:MIN:0.5:48:20000 \
    RRA:MAX:0.5:48:20000 \
    
    Here is also a small script which allows you to retrieve history from the rrdfile. this can be used for testing before making trends etc. Gives an idea on how to use the rrdtool fetch command

    Code:
    !#/bin/bash
    rrdtool fetch /var/www/rrd/Marine.rrd AVERAGE --start end-8h --end now
    
  19. macca_75

    macca_75 Member

    Messages:
    2,281
    Ratings:
    +1,202
    Country:
    Australia
    State:
    Vic
    @onkel.paul - let @Rob know what you want. He has it Ll know ;-)

    I'll get a copy back off him sometime soon.
  20. onkel.paul

    onkel.paul Member

    Messages:
    16
    Ratings:
    +0
    Country:
    Germany
    State:
    NRW
    Hi @macca_75,
    yes ok.
    what is Ll know?

    I have everything always translate with google.:(
    This is sometimes mistranslated!!!!
    Last edited: Jan 8, 2015

Share This Page