Reef Discussion

Rob,

Can't wait for the documentation. I am going to order my Raspberry Pi now that the new version is out and uses even less power! Is there a parts list available that I can also order ready for the build?

This is such an awesome project and many thanks all the work you have put into this :cool:

Sent from my Nexus 10 using Tapatalk 2
 

Rob

Member
Apr 26, 2012
743
424
Just need to be careful with the ph ORP boards. The original project did not work on my tank that's why it's being used on another members tank, & working perfectly. My 6x54w lights 8" above the water induced a voltage into the tank which influenced the ph & ORP readings. It was NOT any electrical feedback/ noise through the mains power circuit or RF , it was definatly the tubes induced voltage into the water column.

So if you run fluorescent tubes I would stick with just the temperature measurements

As far as how-to its now very easy as others have this really nicely documented and you o not have to build your own board now the board below seems perfect for.:

1wire for temperature probes
Rs232 for the atlas interface to ph ORP
WE NEED TO MODIFY THE BOARD TO BYPASS THE MAX232CHIP.the atlas uses 3.3v not rs232level of +\-7.5 v. I like this board as although the rs232 circuit will be removed it does give us a nice db9 connector.

My current thought is to just use the spare pins of the db9 and wire these to two gpio pins plus the RPi tx and rx pins. That way we can make a simple cable db9 to https://www.atlas-scientific.com/product_pages/embedded/serial-port-connector.html

Both how to get these working on the pi is document here
http://www.abelectronics.co.uk/products/3/Raspberry Pi/26/Com-Pi-RS232-Serial-and-1-Wire

The only trick is the command line to send / receive data through the serial port to the atlas which I already have developed. It's really only one line of code in a simple script which is on page 2 of the post under setup tips
 
Thanks for the info. Just been looking at new Raspberry Pi and it only has 256mb of memory (model A). Do you have any stats on memory use? I would prefer to run this on the model A as it is lower power but just want to check t will run with this amount of memory.

Sent from my Nexus 10 using Tapatalk 2
 

Rob

Member
Apr 26, 2012
743
424
6.1 Read Script -rev 0 original code
Got the script file tonight which goes out and gets the data from the Atlas devices and 1wire temperature sensors.

This code gets ph,orp and 3 temperatures, does some error checking to amke sure their valid then writes the data into a trend package called rrdtools and also puts it in a large ascii file which the gauges use. For those looking to get data from the atlas device you should be able to see the command to send a "r" to the device ("\x72\xff\x0D")
and then the response goes into a temporary file called "rob". I will clean up the code in the coming weeks however this code has been working for the last 5 months. I use two outputs (GPIO17 & 18) to switch the serial port between the two devices ORP & PH. Atlas have this 4 port switching device although I currently only have two devices connected. Hope the following makes sense. The only tricky command is "cat < /dev/ttyAMA0 > ./rob" what this does is concatenate "=read" anything coming from the serial port and place it in a file called rob. This allows the atlas response value to get captured.

I am sure you could do this more elegantly in "c" however these few lines in bash script work just fine.

Code:
#!/bin/bash
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
 
while true
do
###  Read pH and ORP from Atlas Scientific Devices ###
( cat < /dev/ttyAMA0 > ./rob ) &
bgPID=$!
sleep 1
gpio -g write 18 0
sleep 1
printf "\x72\xff\x0D" >/dev/ttyAMA0
printf "\x72\xff\x0D" >/dev/ttyAMA0
sleep 2
kill $bgPID > /dev/null
read ReefORP < ./rob
#echo $ReefORP
 
rm ./rob
sleep 1
( cat < /dev/ttyAMA0 > ./rob ) &
bgPID=$!
sleep 1
gpio -g write 18 1
sleep 2
printf "\x72\xff\x0D" >/dev/ttyAMA0
printf "\x72\xff\x0D" >/dev/ttyAMA0
sleep 3
kill $bgPID > /dev/null
read ReefPH < ./rob
 
### Delete Trailing Carriage return ###
ReefORP=$(echo "$ReefORP" | sed 's/.\{1\}$//')
ReefPH=$(echo "$ReefPH" | sed 's/.\{1\}$//')
 
###  Read Temperatures from 1wire Devices ###
ReefTemp=$($OWREAD  /28.FE6828040000/temperature | $AWK '{printf "%3.1f\n",($0)}')
sleep 1
HeaterTemp=$($OWREAD  /28.FB4228040000/temperature | $AWK '{printf "%3.1f\n",($0)}')
sleep 1
RoomTemp=$($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
 
T1test=`echo $ReefTemp |cut -f1 -d'.'`
  if [ -z $T1test ] || [ $T1test -gt 50 ]; then
  echo "`date` Reef Tank Temperature reading error $ReefTemp" >>/var/scripts/nohup.out
  ReefTemp="U"
  fi
 
T2test=`echo $RoomTemp |cut -f1 -d'.'`
  if [ -z $T2test ] || [ $T2test -gt 50 ] ; then
  echo "`date` Room Temperature error $RoomTemp            " >>/var/scripts/nohup.out
  RoomTemp="U"
  fi
 
### 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 & \
- - 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
 
Now I have some time on my hands, I am going to order everything I need. As I was thinking about this, I thought I could help out and document the parts people needed so it could be included in your documentation. Apologies if you have already done this or some of the wording is incorrect but just trying to help with the little knowledge I have! Not sure where you guys in Australia buy your Raspberry Pi's from but maybe someone could post a link so that could be included?

1.0 Hardware / loading and getting a net connection
1.1 Parts Required.1.1.1 Raspberry Pi
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

1.1.2 Breakout Board
In order to connect probes to the Raspberry Pi you will need a breakout board. This breakout board connects directly onto the Raspberry Pi with no need for soldering.
http://www.abelectronics.co.uk/products/3/Raspberry-Pi/26/Com-Pi-RS232-Serial-and-1-Wire

1.1.3 In-tank Temp Probe
http://littlebirdelectronics.com/products/temperature-sensor-waterproof-ds18b20
 

Rob

Member
Apr 26, 2012
743
424
@Clownfishy : Any help is welcome thats for sure :)


Had a few hours the last couple of days to get Ver2 up and running. Had a couple of issues one being the 1wire/RS232 breakout board. I had to remove the max232 chip off the board as it was holding the RPi rcv line low. The Atlas ph/orp boards need to be connected directly to the Rpi GPIO tx/rcv pins as the all work on 3.3 V. So the RS232 port on the breakout board is not a good option. I had hoped I could modify the DB9 connector pins on this board however would be better to get the 1wire only board or cut off the MAX232 chip. The ATLAS devices need to connect directly to teh RPi serial port. the max232 increases the voltage levels and will distroy the Atlas devices. As the RPi has only 1 serial port you need a multiplexer to allow you to connect multiple devices to the serial port. Only one device at a time can communicate. So Atlas have a serial connector board which allows up to 4 devices to connect to a single serial port. You control which device is communicating via two GPIO pins which simply switch between the 4 devices.

So the Hardware is done see below and is all working now.

HARDWARE LIST
Raspberrypi Style A or B (I used style B)

1Wire Interface
1wire interface Board
1wire/RS232 interface board (You have to remove "cut-off" the max232 IC from this board) -Better to use 1wire only board
Temperature probes -You can connect lots of these to th 1wire interface

pH and ORP Probes
Multi-port Serial Board
pH Probe
ORP Probe
 
Excellent this is looking good. What about adding in some other detail about physically connecting it up e.g. how do you connect the 3 wires from the temp to the 1 wire. I only suggest this as there are going to be a lot of novices such as myself who never have had a Raspberry pi and no nothing......and I mean nothing about electronics!

I have just order Raspberry pi model A, the waterproof temp sensor, the 1 wire pi and a USB WiFi adapter. I am more than happy to write up the detail and produce a few pictures along the way so it will help.


Sent from my Nexus 10 using Tapatalk 2
 
Just beginning to receive the hardware but still waiting on the Raspberry Pi:rolleyes: I will start to get some "user" documentation along with pictures putting it all together. Your project is amazing and the fact that you have made it all open source is a credit to you personally. I hope I can give something back by by helping documenting some of it

Sent from my Nexus 10 using Tapatalk 2
 
OK, my first dumb question (there are going to be lots of these on the electronic side. I now have the 1-wire board and the temp sensor and raspberry pi. I am going to order the atlas boards shortly but I thought I could crack on and get the temperature probe attached directly on the 1 wire board for now. So here it comes........the temp probe has three coloured wires, white, red and black.......which wire goes into which hole on the i-wire board! I am not using the RJ12 connector but the holes next to them just to test if I can read from the temp probe?
 

Rob

Member
Apr 26, 2012
743
424
Theres a couple more steps before launching into running a script for data collection.

I will try and write up step 1 in the next few days and how to connect a temperature probe. This requires no scripting at all, just loading One Wire File System. (owfs) I will show you how the owfs web interface works. Its a lot easier to test that all probes are connected and working prior to trying to collect the data via a script. The owfs web interface is loaded when you install owfs so no need with any fancy apache at this stage.
 
First off, just would like to say a HUGE thank you to Rob for what he has produced here. Although I have not got my working yet due to my own impatience, I am learning a lot and this solution will save me a fortune in buying a proprietary monitor. I will order the Atlas parts today :-)
 

Rob

Member
Apr 26, 2012
743
424
Get the temperature running first, what lighting do you have on your aquarium. The Atlas probes have provided to work ok with metal Halides and LED's. High power T5 induce a voltage into the DT that you cannot engineer around.
 
Hi rob,

Any chance you could post the wiring diagram or description on how to connect the temp wires to the 1 wire board? I think I have found how to get the 1 wire software working but I cannot see a 10 directory in the mint/1wire directory so am not sure I have wired it correctly. Just trying to understand the what the red, black and white cables from the temp sensor connect to

Sent from my Nexus 10 using Tapatalk 2