Reef Discussion

onkel.paul

Member
Oct 31, 2014
15
0
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
Hi @Rob,
Thanks for the info rrdtool create !
 

onkel.paul

Member
Oct 31, 2014
15
0
Sorry - he has it (the card) now.
Hi @macca_75,
I've seen your Pi. again running a bit!!!

"It works!
This is the default web page for this server.

The web server software is running but no content has been added, yet."


I have the following times for the html. hicharts JS tried:

Code:
### Write data to a tendency file.txt ###
echo -n "$ sec," >> / media / log data / 24h_daten / 24_achse_zeit.txt
echo -n "$ TeichPH, 0" >> / media / log data / 24h_daten / 24_achse_ph.txt
echo -n "$ TeichRedox, 0" >> / media / log data / 24h_daten / 24_achse_orp.txt
and so on.
But is not so good!:(

Wish you have a nice evening!
 

macca_75

Member
Apr 22, 2012
2,125
844
Correct - apache is loaded but I haven't restored data yet. Still also need to get 1wire, I2C working, etc
 

onkel.paul

Member
Oct 31, 2014
15
0
Sorry - I thought I was waiting on a reply from you @onkel.paul

I use the I2C for some Atlas Probes (pH, ORP).

I use the 1Wire for 3 x Temp probes.

I have access to all my old scripts so let me know what you need/want specifically.

I've also started using mjpeg_stream to control my web cam - works really well.

http://macca.myreef.info:8080/javascript_simple.html
Hi @macca_75 ,

the SKRIBT I'd like to read back from. * RRD to eg "24_average_heater.txt"> daily.html "> weekly.html> monthly.html> myreef.info/yearly.html for hicharts JS!

The SKRIBT to read Atlas Probes (pH, redox) via I2C me I would be interested in've only script for URAT but my new probes can also I2C.

You have my E.mail address in your Private Message!

What you control even with the Pi to your REEF?

OK.?
Thanks in advance!
 
Last edited:

Poelie

Member
Mar 31, 2015
1
0
@Clownfishy I hope the project s'not dead. I started this week with the project for my koi pound. software already running and waiting for the probes. currently running the web gui of rob but I like to make a more fancy interface with webcam support.
 

macca_75

Member
Apr 22, 2012
2,125
844
@Poelie
If you want to stream webcam from a PI, check out mjpg-streamer

I am using it with a Logitech C510 (not all camera work the same)

Here is the default landing page
http://macca.myreef.info:8080/

And the one I use most (works in every browser tested to date)
http://macca.myreef.info:8080/javascript_simple.html

(NOTE: You may not see much as it is live, depending on the time of day)

takes about 1% CPU and not a lot of memory. I have slowed stream down to 1fps as that's all my bandwidth out can handle. easily 720p@30fps (about 5% CPU from memory) and is very smooth on local network.
 

Rob

Member
Apr 26, 2012
743
424
Macca You must of cleaned the glass before posting your link haha.. Its crystal clear.

Project itself... Its not dead however Im not progressing any further myself as I have the data, can trend it and since I created the overlay buttons where you can overlay last weeks data ontop of this weeks to compare the trend it now does everything I wanted. Although in saying that I do run a profilux to do all the control. The Pi has been very reliable and if you wanted to expand this to turn on/off non critical devices I would not hesitate.

Camera: If you use your iphone, you can create a link (home screen bookmark/icon thing !) direct to your camera feed. Doing this you end up with a full screen (i.e. no safari menu bars) from an icon, it kind of looks like an app. I did play with the widthxhieght of the camera setup so it fills the creen nicely. I have also now placed the ph orp and temp reading as a text overlay on the camera feed. So when its displayed on the phone you see the camera feed and the parameters. You just need to google on how to overlay text. its generally used to overlay date and time, you simply use the bash script where your collecting the data and update the camera feed text command.
 
Last edited:

leaky john

Member
Apr 5, 2015
8
2
I am also working on the ph probe kit with raspberrypi using i2c

so far I have got it all wired up and its seem to be flashing correctly and its returning an whole bunch of values

the next step for me is where i am bit stuck on is what these ouput values means and reading it in human friendly format

i appreciate any pointer or snippet code for i2c via ph kit probe.

I can post some really basic output if requested

thanks
 

Rob

Member
Apr 26, 2012
743
424
Hi Sorry, Macca & I have only used the Serial Interface. Looking at the example I2C code on the Atlas Scientific web site (I2C for Arduino) it seems to provide the value simply in pH units. I2C should be a good option for multiple sensors alot better than having to multiplex the RPi serial port.
 

leaky john

Member
Apr 5, 2015
8
2
@Rob I have reading on the all good work everyone been doing here

hardware:-

I2C enabled on PH stamp and directly connected to RPI 2 B+ GPIO I2C pins

so here is the initial script (hope the format readable)

#!/usr/bin/python
import smbus
import time

bus = smbus.SMBus(1)

#address of i2c ports
ph = 0x63

#probe i2c cmd
cmd = 0x52 # R = read probe

#playing with time delay
delay = 1.5

#main logic
while True:
try:
print bus.read_i2c_block_data(ph, cmd, 48)
time.sleep(delay)

except IOError:
pass

And the output is (4 lines) :-

[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 118, 1, 82, 204, 118, 8, 0, 0, 0, 108, 20, 187, 126, 99]
[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 118, 1, 82, 204, 118, 8, 0, 0, 0, 108, 20, 187, 126, 99]
[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 118, 1, 82, 204, 118, 8, 0, 0, 0, 108, 20, 187, 126, 99]
[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 118, 1, 82, 204, 118, 8, 0, 0, 0, 108, 20, 187, 126, 99]

If am correct in recalling various atlas documents that

254 means "pending" ? 99 means address (ASCII/DEC for ph meter 0x63) ? apart from maybe bit more everything else is alien to me atm

while messing about i have managed to return value of 1 (success) rather than the usual 254 (pending)

for now not been able figure out on getting repeatability of the value of 1 even when i have played about with the timing.

will pop back if i have more luck :)
 

Rob

Member
Apr 26, 2012
743
424
I realise its a silly question but, Do you have the probe connected and in water so it can generate a valid response ? I was hoping I could see an ascii value of 46 (.) somewhere in the string as a pointer to the actual value...
 

leaky john

Member
Apr 5, 2015
8
2
I welcome any suggestions :)

Yes the probe is connected and it is sitting in the storage solution at the moment which i believe has a value of 4.0 ph.

Your are right i too was expecting some other recognizable set of ascii values such as numbers from 48 (0) to 57 (9) and couple others as well ..

here another set of outputs from the same script i posted above sending the R command (Returns a single reading) :-

[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 118, 1, 82, 211, 118, 8, 0, 0, 0, 108, 212, 201, 126, 99]
[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 118, 1, 82, 211, 118, 8, 0, 0, 0, 108, 212, 201, 126, 99]
[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 118, 1, 82, 211, 118, 8, 0, 0, 0, 108, 212, 201, 126, 99]

my conclusion so far :-

i noticed the bold and 0 (zero/null) are always in the same position and values, the other values seem meaningless they do change but only when stop and re-start the script.

[254, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 118, 1, 82, 211, 118, 8, 0, 0, 0, 108, 212, 201, 126, 99]


ascii > hex > (desc/symbol) ph commands
254 > FE > (some icon) pending
128 > 80 > (euro sign) seems meaningless
0 > 00 > (null) termination and or transmission marker
118 > 76 > (lowercase v) seems meaningless
1 > 01 > (SOH) Start of Heading ? seems meaningless
82 > 52 > (uppercase R) Returns a single reading from probe
8 > 08 > (backspace) seems meaningless
108 > 6C > (lowercase l) seems meaningless
126 > 7E > (~ an tilde) seems meaningless
99 > 66 > (lowercase v) seems meaningless

reference for ascii-code.com

Other things i have checked is that i am reading 48 bytes (for troubleshooting purposes), I really should be reading 7(8?) bytes which also includes the 5 bytes of the PH value.

[254, 128, 0, 0, 0, 0, 0, 0]

The 254 is the pending command so I guess it might be timing issue i have tried various delays setting ranging from 0.3 sec to 1.3s to 5 secs and all pretty much the same results "pending".

Thank you for your time
 
Last edited:

Rob

Member
Apr 26, 2012
743
424
I would send the output to Atlas, I emailed them a number of times and they have always been very helpful...

The other things come to mind...

you are powering from 3.3V
I understand the RPi has the I2C pullup resisters on the board, so no need for external pullup resistors.

If all else fails for I2C you can always go back to serial :)
 

leaky john

Member
Apr 5, 2015
8
2
thank for the fast reply

Yes i am on 3.3V and i can confirm I have not added any additional pullup resisters either.

I could fallback to serial which i not tested yet.

Will try an email atlas later like you suggested it would be nice to get the I2C working so i can add other planned sensors

thanks again
 

saltychris

Member
Apr 9, 2015
1
0
The pending message suggests that maybe you need to write to it first.
Maybe something like:

bus.write_byte(address, R)
time.sleep(1)
print bus.read_i2c_block_data(address ,7)