Reef Discussion

Apocrathia

Member
Nov 6, 2013
9
1
Way ahead of you on the GitHub part...
github(dot)com/Apocrathia/AquaPi

Edit: Micro-Community is live.
 
Last edited:

Moreno5

Member
Oct 1, 2013
19
0
Way ahead of you on the GitHub part...
github(dot)com/Apocrathia/AquaPi

Edit: Micro-Community is live.
Well done mate, will keep an eye on this and help where I can. I am looking forward to getting stuck into this.

We need to get international links for the sensors and it may be a good idea to get the manufacturer of the sensors involved as people who do this deserve a discount or at least less extensive postage costs. It may also be a good idea to suggest different places to get sensors.
 

Apocrathia

Member
Nov 6, 2013
9
1
We need to get international links for the sensors and it may be a good idea to get the manufacturer of the sensors involved as people who do this deserve a discount or at least less extensive postage costs. It may also be a good idea to suggest different places to get sensors.


Agreed. I think that getting the source out there and available for more people will allow this project to really grow. There's potential to integrate some Arduino functionality for expanded sensor compatibility, and there's definitely already code out there to support this type of endeavor. (Open Reefs, which uses the Atlas Scientific probes, has their source available.) The ability for the Raspberry Pi to work as the backend interface, collector, and orchestrator, while utilizing a dedicated microcontroller for the actual sensor and relay work could be a very interesting option.

Making this project available to everyone will help out immensely, and the open source community could provide a lot of support and development that could really push this project as an economically viable solution for a DIY aquarium controller. I also see it being very useful to those out there doing aquaponics, so there's definitely a lot of potential. I'm just hoping we can get our hands on a copy of the source soon so that we can make it available.
 

Apocrathia

Member
Nov 6, 2013
9
1
github(dot)com/Apocrathia/AquaPi

I just pushed some code that I got from @Moreno5 on to the GitHub repository. It's still missing the sensor interface code, as there's a CGI (Just a Bash case statement) file to create the RRD files for the graphs which refers to a $QUERY_STRING variable which isn't defined anywhere. I'm not awesome at web coding, so there's some AJAX fuckery going on that I'm still trying to read through, but I wanted to get what I have out to everyone as soon as possible. Thanks to @Moreno5 for sending me what he had!
 

Apocrathia

Member
Nov 6, 2013
9
1
Any updates to your progress?
Unfortunately, not much. Since we haven't heard anything from rob or clowny in months, there's not a lot I can do. There's still a lot of backend code that I'm missing. I'll probably take bits and pieces of the design from the webpage and integrate them into something, but a lot of that is on the back burner while I have finals and holiday bullshit going on.
 

macca_75

Member
Apr 22, 2012
2,125
844
what are you missing @Apocrathia

I'm not really good at this stuff, but I do have a working model complete with ORP, pH & 3 temps probes.

Cheers
 

Apocrathia

Member
Nov 6, 2013
9
1
You can see everything that I currently have on the GitHub page. https://github.com/Apocrathia/AquaPi
I'm missing the python code which interfaces with the probes and cgi scripts to generate rrd data. An image would be extremely helpful, as we could tear the whole thing apart and sort out all of the pieces.
 
Right, I am back, apologies for not being around but been a tad busy. Just catching up on the posts and I been to see the micro community thing. Not sure how they work but could not see how this will host the code, documentation, accept changes etc ? I assume we are now using github which will work out better? I will have some time over the holidays to continue with the documentation so shall I post it on github?
 

Moreno5

Member
Oct 1, 2013
19
0
Right, I am back, apologies for not being around but been a tad busy. Just catching up on the posts and I been to see the micro community thing. Not sure how they work but could not see how this will host the code, documentation, accept changes etc ? I assume we are now using github which will work out better? I will have some time over the holidays to continue with the documentation so shall I post it on github?
Yeh that's probably the best thing and then it is all in one place. Can you host the ad card image on there too?
 

Apocrathia

Member
Nov 6, 2013
9
1
Right, I am back, apologies for not being around but been a tad busy. Just catching up on the posts and I been to see the micro community thing. Not sure how they work but could not see how this will host the code, documentation, accept changes etc ? I assume we are now using github which will work out better? I will have some time over the holidays to continue with the documentation so shall I post it on github?
No worries, it's a crazy time of year for everybody.
I'll assume that your github profile is https://github.com/Clownfishy? I went ahead and added you to the repo that I have open right now so that you can update it as well.
 

macca_75

Member
Apr 22, 2012
2,125
844
I'm not really keen on sharing my entire image as it has passwords, etc in it I would need to share.

If there is something in particular you want/need (such as scripts, list of cron jobs, etc) let me know and I will see what I can do to help.

Cheers
 

Rob

Member
Apr 26, 2012
743
424
Anyone got a profilux ? I am going to use the RPi at my DT as a wifi bridge for my profilux and to collect data from the profilux. The trending on RPi is soo much better than the profilux limited trends. Today I'll buy a new sdcard and try the bridging function

@macca_75 I have sig pic envy :)
 

Apocrathia

Member
Nov 6, 2013
9
1
I'm not really keen on sharing my entire image as it has passwords, etc in it I would need to share.

If there is something in particular you want/need (such as scripts, list of cron jobs, etc) let me know and I will see what I can do to help.

Cheers
Understandable. Any scripts, cron jobs, or code snippets you can provide will be perfect. I've been in the process of starting my project from scratch, and I'll gladly include anything I can to bring it up to where you guys are.

Anyone got a profilux ? I am going to use the RPi at my DT as a wifi bridge for my profilux and to collect data from the profilux. The trending on RPi is soo much better than the profilux limited trends. Today I'll buy a new sdcard and try the bridging function

@macca_75 I have sig pic envy :)
It's funny that you mention this, because I was actually looking at how to integrate a dosing capability. The peristaltic dosing pumps are actually pretty cheap on their own, and would be fairly easy to work with.
 
Last edited:

Rob

Member
Apr 26, 2012
743
424
Having had a couple weeks off I finally got around to getting a new sdcard and setup a new image. I will not be using the atlas interfaces any more however they have been very reliable. I just don't have enough room under my tank for a lot of this sort of stuff. So I plan to get data direct from my profilux aquarium controller into the RPi for trending. As Aquapi has a front end GUI and a backend data gathering script which pushes data into an RRDTools database it should be easy for me to swap over and get data direct from the profilux as it has an ethernet port and onboard web server. Anyhow its going to take a couple of steps, the biggest getting the RPi online and act as a wifi bridge for my profilux.
Profilux -wired-> RPi -wifi-> Home Router
Current status is I now have my RPi talking wifi and connected to the profilux this is at my DT. With some static routes set in my router I can now get access to the profilux from my pc. I ended up setting up the RPi as a router with the two networks, onboard wired and wireless USB
Home network 192.168.1.x (PC,NAS, etc etc)
Tank Network 192.168.2.x (Raspberrypi, Profilux)

OK so this isn't helpful to those using atlas ph/orp direct connect to AquPi etc however it does mean the interface will progress.
Code:
# file      : /etc/network/interfaces
# physical  : Profilux -> (wired)_RPi_(wifi) -> Home Network -> Internet
# Date      : 04-Jan-2013  rev0
# Function  : 1. Use a RPi to act as a bridge (router) between Profilux 3.1N and the Home wireless network
#              2. The RPi apache web server to host additional trending and web application for the Profilux aquarium controller
# Revision  : 0  Do not use gateway definition in eth0

auto lo
iface lo inet loopback

# Ethernet port -Reef Tank Network
auto eth0
iface eth0 inet static
  address 192.168.2.1
  netmask 255.255.255.0
  network 192.168.2.0
  broadcast 192.168.2.255


# Wireless port -Home Network
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  address 192.168.1.101
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1

iface default inet dhcp
I have this setup through static routes in my home router
 
Last edited:

Rob

Member
Apr 26, 2012
743
424
Improved scan script to read 1wire and Atlas devices, although I did this 6 months ago and just pwoered up my development RPi thought I would extract the scan script. The two RS232 serial Atlas interfaces pH & ORP are connected via the Atlas serial mutliplexor. This mutliplexor uses two outputs from the PI to switch between pH and ORP devices. See Atlas site for serial port connector it lets you connect up to 4 devices to 1 serial port. Anyhow the following script uses pin 17 & 18 to switch between ph & orp.

@macca_75 This is the script we should use for your next build. If you kill the program now it cleans up the "cat" process left behind so it will restart normally. Have also included the ability to bias both the pH and orp readings via a simple text file for each. These txt files simply have an offset value you wish to bias the results by. normally left at 0 however if you know your reading is high you can simply place an offset (i.e. -0.3 ). Of course you should really calibrate the Atlas driver however this is quick and easy.

Code:
 #!/bin/bash
#title  :AquaPi Read Script
#description :Read sensor data, range test then write data to file
#author  :R Conway
#date  :July 2013
#version  :23
#usage  :Start script in background [nohup /var/script/DataScan >/dev/null &]
#notes  :if you kill the script you also kill the cat process left behind
#=======================================================================

stty -F /dev/ttyAMA0 raw 38400 cs8 -ignpar -cstopb eol 255 eof 255
OWWRITE="/opt/owfs/bin/owwrite -s 3001"
OWREAD="/opt/owfs/bin/owread -s 3001"
AWK="/usr/bin/awk"
gpio -g mode 17 out
gpio -g mode 18 out
(pkill -x cat)

while true ;do

###  Read pH and ORP from Atlas Scientific Devices ###
( cat < /dev/ttyAMA0 > ./serial_in ) &
  bkgPID=$!; disown $PID
  gpio -g write 17 1
  gpio -g write 18 0
  sleep 2
 printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 1
 printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 2
  kill $bkgPID >/dev/null
  read ReefPH  <./serial_in
 ReefPH=$(awk -v SENSOR="$ReefPH" '{printf "%4.2f",(SENSOR+$0)}' /var/scripts/ph_cal_factor.txt)

( cat < /dev/ttyAMA0 > ./serial_in ) &
  bkgPID=$!; disown $PID
  gpio -g write 17 0
  gpio -g write 18 1
  sleep 2
 printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 2
 printf "\x72\xff\x0D" >/dev/ttyAMA0 ; sleep 2
  kill $bkgPID >/dev/null
  read ReefORP  <./serial_in
 ReefORP=$(awk -v SENSOR="$ReefORP" '{printf "%3.0f",(SENSOR+$0)}' /var/scripts/orp_cal_factor.txt)


###  Read Temperatures from 1wire Devices ###
 ReefTemp=10 #=$($OWREAD  /28.FE6828040000/temperature | $AWK '{printf "%3.1f\n",($0)}')
 sleep 1
 HeaterTemp=20 #$($OWREAD  /28.FB4228040000/temperature | $AWK '{printf "%3.1f\n",($0)}')
 sleep 1
 RoomTemp=30 #$($OWREAD  /28.E1C96F030000/temperature | $AWK '{printf "%3.1f\n",($0)}')


### Out of Range Error trap -Do not log data (U=Undefined data) ###
 orptest=`echo $ReefORP |cut -f1 -d'.'`
  if [ -z $orptest ] || [ $orptest -gt 500 ] ||[ $orptest -lt 0 ] ; then
  echo "`date` Reef Tank ORP reading error $orp" >>/var/scripts/nohup.out
  ReefORP="U"
  fi
 phtest=`echo $ReefPH |cut -f1 -d'.'`
  if [ -z $phtest ] || [ $phtest -gt 10 ] ; then
  echo "`date` Reef Tank pH Reading Error $ph" >>/var/scripts/nohup.out
  ReefPH="U"
  fi
 T1test=`echo $HeaterTemp |cut -f1 -d'.'`
  if [ -z $T1test ] || [ $T1test -gt 75 ]; then
  echo "`date` HEATER Temperature reading error $HeaterTemp" >>/var/scripts/nohup.out
  HeaterTemp="U"
  fi
 T2test=`echo $ReefTemp |cut -f1 -d'.'`
  if [ -z $T2test ] || [ $T2test -gt 50 ]; then
  echo "`date` Reef Tank Temperature reading error $ReefTemp" >>/var/scripts/nohup.out
  ReefTemp="U"
  fi
 T3test=`echo $RoomTemp |cut -f1 -d'.'`
  if [ -z $T3test ] || [ $T3test -gt 50 ] ; then
  echo "`date` Room Temperature reading error $RoomTemp" >>/var/scripts/nohup.out
  RoomTemp="U"
  fi

## Used for testing only when starting script manually -normally comment lines out
 echo "=================="
 echo "pH  Reading :"$ReefPH
 echo "ORP Reading :"$ReefORP
 echo "Reef  Temp :"$ReefTemp
 echo "Heater Temp :"$HeaterTemp
 echo "Room  Temp :"$RoomTemp

### Push data into txt file for web gauges ###
 #sec=$(/bin/date +%s)
 #echo "$sec 0 5 & Acidity pH $ReefPH 8.3 9 7 8.8 8.0 0 0 0 0 1 3 & \
 #ORP orp $ReefORP 200 500 0 450 10 0 0 0 0 1 0 & \
 #ReefTemp DegC $ReefTemp 29 30 20 29 25 0 0 0 1 1 1 & \
 #RoomTemp DegC $RoomTemp 29 40 10 30 0 0 0 0 0 1 0 & \
 #Evaporation Litres 0 35 40 0 40 20 0 0 0 0 1 3 &" >/var/www/aqua_tag.txt

### Push Data into Trend File ###
 #rrdtool update /var/www/rrd/Marine1.rrd N:$ReefPH:$ReefORP:$ReefTemp:$HeaterTemp:$RoomTemp:0:0:0:0:0
 #rrdtool update /var/www/rrd/Marine.rrd N:$ReefPH:$ReefORP:$ReefTemp:$HeaterTemp:$RoomTemp:0:0:0:0:0

sleep 60
done
New interface does not use the date slider. You just choose the gauge then 1,3,5 or 30 days. The best thing about this is you can also see the previous readings for the period which I think is THE most valuable data. As a user looking at the difference between this week and last week can show immediately any problems.
The trend also shows the average value for the time with a solid horizontal line and also the average for the last period with a white dotted line. Thus you imediatly see is the average is higher or lower for the previous period. As you can see below the pH is slightly higher for this period (this week) ver the avg for the last week. I also print this on the lower trend area. The date for the max / min is for the current period however also show max min for the previous week although does not show which date and time.
ph pic.png
If you click the previous period box you also get the trend line for the previous period, see below the temperature trend, the white dotted line is the previous week. This does show the last week was higher tank temps than this week although accounted for thur /fri being higher. (Oh just seen on the pic I need to format the temperature scale as its rounding the scale graduations.)
temppic.png

The temperature profile still shows the three variables.
tempprofile.png

Oh.. This is actually macca's tank data and yes there is lost data on Sunday but that's another story. I think he may of turned the power off for a while :eek
 
Last edited: