reef-pi :: An opensource reef tank controller based on Raspberry Pi.

robsworld78

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
Feb 14, 2020
Messages
924
Reaction score
1,229
Review score
+0 /0 /-0
Location
Edmonton, Canada
Rating - 0%
0   0   0
Hi Rob,
thank you for your message, yes I was following your old project so I understand what you're saying... It was a very complex project but, in my opinion, it had one of the best looking GUI I've ever seen in a reef controller (and not only that)...
Regarding my project.. Is not that complicated, I think I've complicated the things by myself...
My goal is to run 3 separate PCBs in 1 single enclosure (to minimize cable run an footprint) the boards are these:
CPU Board - with Raspberry Pi Zero, and all the circuit for input side, 0-10V out from Rpi, DS18B20, ADC and I2C
Powerbar - connected to the previous board by a CAT5 0.15cm cable. It runs 8 AC outlet and 8 DC outlet by a PCA9685.
Light/Dosing - to design yet, it'll have another PCA9685 connected by the same CAT5 cable and it'll control 3/4 dosing pump and 3/4 lights channel.

I was trying to keep I2C signal very short since I know that long cable can cause many troubles.
Attached to the CPU board (but in the same box) I'll have 2 Ph Board (the one made by Roberto Buti) and the SHT31D sensor which is the only device connected by a long cable to reach my sump and measure temp/humidity to control an exhaust fan.

I was also thinking about changing the SHT31D to a DHT22 (as you do in your new software if I rember correctly) to be able to have long cable without problem, but I don't know how to add it to Rpi...
Thanks for the kind words, working on bringing back that GUI. :) For the DHT22 you can run a python script like this, if you edit it so only the humidity is saved to the file you can import it in reef-pi using the file driver. If you can get away from I2C its best, I know it's tempting though with 2 wires vs 16.

 
World Wide Corals

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
82
Reaction score
69
Review score
+0 /0 /-0
Location
Italy
Rating - 0%
0   0   0
Thanks for the kind words, working on bringing back that GUI. :) For the DHT22 you can run a python script like this, if you edit it so only the humidity is saved to the file you can import it in reef-pi using the file driver. If you can get away from I2C its best, I know it's tempting though with 2 wires vs 16.

Thank you Rob, I'll give it a try :)
 
OP
Ranjib

Ranjib

7500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 16, 2016
Messages
9,769
Reaction score
16,911
Review score
+0 /0 /-0
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
One of my tank. Now the sps are growing at a rate and has passed a size that I can sustainably frag a few (green slimer, forest fire digitata , red milli pora, strawberry shortcake ) for testing in pico tank
F0E0EDC9-E301-4EFA-9952-A66A89EC3F55.jpeg

Here is a close up of the green slimer colony . I have to frag it, otherwise it will shade the other acro frags glued beneath
0EC770E6-A397-45E1-A9F7-10BC0D8711C5.jpeg


strawberry shortcake colony
E98BA855-4A87-46FD-B5A1-657F97B9C24E.jpeg

Pink stylo
A24501C7-F413-46B3-91E1-B1C1A85DB76C.jpeg

I really want to test a minimal reef-pi setup that can keep at least some of these across. I am able to keep green slimer and monti right now. Without any dosing . But over the last few months I have sourced pretty awesome 12v brushless motor that generates ample flow, and now that dosing systems are tested with all for reef based alk/ca supplement , I think i have all the things needed. I am really excited about this. It will be so cool to have a pico tank with a sizable sps colony as the center piece , all grown out with reef-pi in a very affordable and open setup. That will be an awesome milestone
 
Aquarium Specialty - dry goods & marine livestock

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Another question, How do I calibrate a single point calibration probe such as ORP?
If I set 225mV for both mid value and second point I always have 225 reading... I'm missing something :downcast-face-with-sweat:
Well, judging from the Atlas Instrument datasheet, which gives some Information on working principle and calibration, I would hazard the guess that it’s similar to pH, e.g. that the „mid-value“ is supposed to be 0mV, corresponding to the ORP value of silver chloride. That probably needs to have a value of zero, but I’m not completely sure about that.

Actually: I wouldn’t at all be surprised if you could in principle connect an ORP probe to @robsworld78 ‘s pH circuit and measure it that way. The circuit does after all only seem to measure an isolated voltage between -700 and +700mV :grinning-face-with-sweat:
 
Last edited:

robsworld78

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
Feb 14, 2020
Messages
924
Reaction score
1,229
Review score
+0 /0 /-0
Location
Edmonton, Canada
Rating - 0%
0   0   0
Actually: I wouldn’t at all be surprised if you could in principle connect an ORP probe to @robsworld78 ‘s pH circuit and measure it that way. The circuit does after all only seem to measure an isolated voltage between -700 and +700mV :grinning-face-with-sweat:
Exactly, a high resolution volt meter. The other day someone told me after running it along side his other good meter it's bang on. Heard this many times now. :) I've never tested it for ORP but a while ago someone told me to add an extra resistor and it would work with ORP so I've actually revised the board since you got yours, it's even smaller now. Currently it has a solder jumper to activate the extra resistor for ORP. I haven't really tested it yet but I bought a cheap ORP probe and some 225mV calibration solution. I don't really know how to test it properly so I'm just going to see how close it is to 225mV, figures crossed. :)
 

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Exactly, a high resolution volt meter. The other day someone told me after running it along side his other good meter it's bang on. Heard this many times now. :) I've never tested it for ORP but a while ago someone told me to add an extra resistor and it would work with ORP so I've actually revised the board since you got yours, it's even smaller now. Currently it has a solder jumper to activate the extra resistor for ORP. I haven't really tested it yet but I bought a cheap ORP probe and some 225mV calibration solution. I don't really know how to test it properly so I'm just going to see how close it is to 225mV, figures crossed. :)
Nice, can you elaborate on why you need that extra resistor ? Change the amplification on the OP-Amps ?
 
Last edited:
www.dinkinsaquaticgardens.com

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Let's see if you can tell me? :grinning-face-with-smiling-eyes: :face-with-tears-of-joy: :rolling-on-the-floor-laughing:
Well, you basically measure the voltage between the probe‘s contacts. Since this voltage can also be negative you have to bias this voltage to a point between VCC and GND. This bias point should be identical for pH and ORP, but might be different if you are only interested in specific value ranges.
This means if you are for example not interested to measure pH symmetrically around 7.0 you can shift this by using a different bias that’s not the exact middle of VCC and GND.

this resistor does basically that, it moves this bias to pretty much the middle, ensuring a symmetrical measurement range for ORP.
 
OP
Ranjib

Ranjib

7500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 16, 2016
Messages
9,769
Reaction score
16,911
Review score
+0 /0 /-0
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I have just completed the first draft of the telemetry server setup for reef-pi 6.0. If you are inrterested please check it out and provide any feedback you may have

thank you,
 
Reef Chasers Aquaculture

robsworld78

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
Feb 14, 2020
Messages
924
Reaction score
1,229
Review score
+0 /0 /-0
Location
Edmonton, Canada
Rating - 0%
0   0   0
Well, you basically measure the voltage between the probe‘s contacts. Since this voltage can also be negative you have to bias this voltage to a point between VCC and GND. This bias point should be identical for pH and ORP, but might be different if you are only interested in specific value ranges.
This means if you are for example not interested to measure pH symmetrically around 7.0 you can shift this by using a different bias that’s not the exact middle of VCC and GND.

this resistor does basically that, it moves this bias to pretty much the middle, ensuring a symmetrical measurement range for ORP.
Exactly how I would have said it. :rolling-on-the-floor-laughing: I had a feeling it was due to the negative voltage, couldn't remember exactly though but knew you would know and you did. :)
 

Tom Bishop

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 1, 2019
Messages
1,111
Reaction score
1,568
Review score
+0 /0 /-0
Location
Missouri
Rating - 0%
0   0   0
One of my tank. Now the sps are growing at a rate and has passed a size that I can sustainably frag a few (green slimer, forest fire digitata , red milli pora, strawberry shortcake ) for testing in pico tank
F0E0EDC9-E301-4EFA-9952-A66A89EC3F55.jpeg

Here is a close up of the green slimer colony . I have to frag it, otherwise it will shade the other acro frags glued beneath
0EC770E6-A397-45E1-A9F7-10BC0D8711C5.jpeg


strawberry shortcake colony
E98BA855-4A87-46FD-B5A1-657F97B9C24E.jpeg

Pink stylo
A24501C7-F413-46B3-91E1-B1C1A85DB76C.jpeg

I really want to test a minimal reef-pi setup that can keep at least some of these across. I am able to keep green slimer and monti right now. Without any dosing . But over the last few months I have sourced pretty awesome 12v brushless motor that generates ample flow, and now that dosing systems are tested with all for reef based alk/ca supplement , I think i have all the things needed. I am really excited about this. It will be so cool to have a pico tank with a sizable sps colony as the center piece , all grown out with reef-pi in a very affordable and open setup. That will be an awesome milestone
Awesome as usual I went to Tropic Marin all for reef and that way all I have to dose is one thing....works really well but man your tanks always look so much better than mine, lol...if you want to ship any of those SPS frags I will gladdly pay for shipping :)
 

Tom Bishop

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 1, 2019
Messages
1,111
Reaction score
1,568
Review score
+0 /0 /-0
Location
Missouri
Rating - 0%
0   0   0
One more comment, I am always playing and just loaded a mini reef-pi for my copepod cultures since I added heaters but IMHO it would be nice to know which releases we consider a LTS release. Basically I always view the new releases as bleeding edge until enough testing and users have beat on it and I usually load it up on my test units but at least for me it would be nice to know which versions we consider LTS stable so I have a better idea on which version to go and grab. Looks like @robsworld78 script is pulling 5.2 so I assume its pretty stable but thought I would ask.

Thanks
 
AquaCave Logo Banner

Tom Bishop

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 1, 2019
Messages
1,111
Reaction score
1,568
Review score
+0 /0 /-0
Location
Missouri
Rating - 0%
0   0   0
So 5.2 has a pesky issue with the hysteresis and controlling a heater, threshold under value error. I was able to find a bug in git and figured out a workaround but wondering if that bug was corrected in 5.3. I think 5.3 was the latest 5.x build?

Another topic can someone explain how hysteresis is supposed to work, I thought I knew but was getting some odd variation with my heater. The way I thought it worked is you could provide some float around the setting that you are using, say I set my heater threshold for 79deg and a hysteresis of 1deg then it would float the temp down to 78deg before turning back on or is it I have threshold set to 79deg and hysteresis set to 1deg it will float from 79 to 80 before shutting off...I had it set like the first example and it was turning off at 79 but as soon as it hit 78.9 turning back on even though I had hysteresis set to 1deg. Maybe i forgot to reload after changing it, doing some more testing.

PSA, i thought my temp probes were close enough but ive had some heaters failing and finally got another temp gauge that would take a temp reading and even testing it against a cup of ice water was off 1.5deg. Bottom line get a calibrated handheld temp gauge that you can ensure is calibrated to then adjust your reef-pi temp probes, I had been running my tank much higher than I thought...
 

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
So 5.2 has a pesky issue with the hysteresis and controlling a heater, threshold under value error. I was able to find a bug in git and figured out a workaround but wondering if that bug was corrected in 5.3. I think 5.3 was the latest 5.x build?

Another topic can someone explain how hysteresis is supposed to work, I thought I knew but was getting some odd variation with my heater. The way I thought it worked is you could provide some float around the setting that you are using, say I set my heater threshold for 79deg and a hysteresis of 1deg then it would float the temp down to 78deg before turning back on or is it I have threshold set to 79deg and hysteresis set to 1deg it will float from 79 to 80 before shutting off...I had it set like the first example and it was turning off at 79 but as soon as it hit 78.9 turning back on even though I had hysteresis set to 1deg. Maybe i forgot to reload after changing it, doing some more testing.

PSA, i thought my temp probes were close enough but ive had some heaters failing and finally got another temp gauge that would take a temp reading and even testing it against a cup of ice water was off 1.5deg. Bottom line get a calibrated handheld temp gauge that you can ensure is calibrated to then adjust your reef-pi temp probes, I had been running my tank much higher than I thought...
Hmm, can‘t quite elaborate on the hysteresis with certainty, but I think it should work like your first thought, e.g. shut down on target and turn on below target-hysteresis.

Temperature probes are notoriously inaccurate in absolute terms, e.g. 78 degrees typically means something in the range of 77 to 78, which is what you can see when you have several probes in the same environment, e.g. the same cup of water.
My probes are bought calibrated a few months ago I think, which is why they show the same right now, when they are in the same room. This is only true right now, next year they might be slightly different.
However they are pretty accurate in relative terms when the probe shows 78 degrees today and tomorrow you can be sure that the temperature is the same to about 0.1 degrees, or when you have several probes in the same environment and one probe rises 1.0 degrees all probes will rise by pretty much 1.0 degrees.
 

elysics

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 15, 2020
Messages
1,363
Reaction score
1,289
Review score
+0 /0 /-0
Rating - 0%
0   0   0
Hmm, can‘t quite elaborate on the hysteresis with certainty, but I think it should work like your first thought, e.g. shut down on target and turn on below target-hysteresis.
Wait what? I have always thought it was the other way around, with the default being that all heaters and coolers are OFF and the thresholds being the value at which they turn ON, heat/cool for a temperature difference of the hysteresis, then turn OFF again.

Thats why it's called threshold, not target, isn't it?

Maybe I'm wrong but it has always worked as expected for me

As a side note, it would be nice to be able to set separate hystereses for heaters and coolers, flickering 12V fans is fine, flickering mains relays not so much
 

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Wait what? I have always thought it was the other way around, with the default being that all heaters and coolers are OFF and the thresholds being the value at which they turn ON, heat/cool for a temperature difference of the hysteresis, then turn OFF again.

Thats why it's called threshold, not target, isn't it?

Maybe I'm wrong but it has always worked as expected for me

As a side note, it would be nice to be able to set separate hystereses for heaters and coolers, flickering 12V fans is fine, flickering mains relays not so much
Hm, if it has always worked as expected for you then maybe I'm wrong.

The way you present it makes sense as well, since you want a heater to raise temperature, so a heater threshold would be usefull to work as a lower limit below which the heater is always on, whereas you might want the cooler threshold to work as an upper limit where the cooler is always on above that.

Let me have a look at the Code on Github and get back to you ^^
 

elysics

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 15, 2020
Messages
1,363
Reaction score
1,289
Review score
+0 /0 /-0
Rating - 0%
0   0   0
On another node, I haven't looked at the esp integration, or esp itself at all yet, does that support stepper motor dosers right now?

And if so, how does it work, is the dosing schedule sent via wifi to the esp and saved there, or is each individual "dose 10ml right now" command sent over wifi? And how does it work for DC doses, can the same issue as with the pca9685 happen where the "stop turning the motor now“ command is separate and can get lost?
 

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
Wait what? I have always thought it was the other way around, with the default being that all heaters and coolers are OFF and the thresholds being the value at which they turn ON, heat/cool for a temperature difference of the hysteresis, then turn OFF again.

Thats why it's called threshold, not target, isn't it?

Maybe I'm wrong but it has always worked as expected for me

As a side note, it would be nice to be able to set separate hystereses for heaters and coolers, flickering 12V fans is fine, flickering mains relays not so much
Found it, you were right.
@Tom Bishop I was incorrect:
Temp<Heater threshold=>Heater goes on
Heater threshold<Temp<Heater threshold + Hysteresis=>Heater stays on
Heater threshold + Hysteresis<Temp=>Heater turns off

Same the other way arround for the cooler:

Cooler threshold<Temp=>Cooler goes on
Cooler threshold - hysteresis<Temp<Cooler threshold=>Cooler stays on
Temp<Cooler threshold - hysteresis=>Cooler turns off

@Ranjib Found a possible technical issue.
In the code you check for
case h.pastTarget == downerTarget && math.Abs(o.Value-h.config.Max) < h.config.Hysteresis:
when the cooler = downer should continue. However, when the temperature rises faster than the hysteresis within the check period it turns off immediately. This will make the cooler turn periodically on and off, when the hysteresis and/or period is too small. Same for the heater, which might not be desireable, since you are in that case already way past the threshold and definitely dont want the heater/cooler to fluctuate.
I would suggest to change this to:
case h.pastTarget == downerTarget && h.config.Max - h.config.Hysteresis < o.Value:
and
case h.pastTarget == upperTarget && o.Value < h.config.Min + h.config.Hysteresis:
respectively.
I was thinking whether this has some security feature when the sensor crashes, but this would immeditely switch the Heater/Cooler on the next period again anyway. So I think it might be usefull to program this kind of "bad sensor" error mode more effectively.

On another node, I haven't looked at the esp integration, or esp itself at all yet, does that support stepper motor dosers right now?

And if so, how does it work, is the dosing schedule sent via wifi to the esp and saved there, or is each individual "dose 10ml right now" command sent over wifi? And how does it work for DC doses, can the same issue as with the pca9685 happen where the "stop turning the motor now“ command is separate and can get lost?
Looking over the ESP32 code it doesn't look like it, yet. This gave me an idea however: there are convenient Arduino libraries for running a stepper motor on an ESP32:
@Ranjib I haven't looked at them myself yet, but it might be very easy to incorporate Stepper Motor functionality that way.

Security wise I'm afraid it is currently the same as with the PCA9685: if the ESP32 doesn't get an off command due to WiFi or Raspberry issues, it doesn't change its state. That should be easy to fix though:
- The quick and dirty method would be to manually define maximum runtimes in the ESP32 code, either generally for all jacks (even if it is used for a light) or specifically for the jack that the doser is connected to.
- The proper way would require an additional feature in the Reef-Pi ESP32 driver and doser handling and establishing a separate method in the ESP32 code for "dose with PWM power x for interval y"
 
Last edited:
Tidal Gardens

Sral

Well-Known Member
Review score
+0 /0 /-0
View Badges
Joined
May 2, 2022
Messages
607
Reaction score
699
Review score
+0 /0 /-0
Location
Germany
Rating - 0%
0   0   0
@Ranjib I think if we added a doser-interface to the ESP32 code, we could probably run the "off-timer" on the second core, freeing the first core to continue running everything else, including incomming http requests. Not sure though, if that's even necessary since I believe the WiFi connection might be handled by a kind of interrupt.
 

Tom Bishop

Valuable Member
Review score
+0 /0 /-0
View Badges
Joined
Jan 1, 2019
Messages
1,111
Reaction score
1,568
Review score
+0 /0 /-0
Location
Missouri
Rating - 0%
0   0   0
Found it, you were right.
@Tom Bishop I was incorrect:
Temp<Heater threshold=>Heater goes on
Heater threshold<Temp<Heater threshold + Hysteresis=>Heater stays on
Heater threshold + Hysteresis<Temp=>Heater turns off

Same the other way arround for the cooler:

Cooler threshold<Temp=>Cooler goes on
Cooler threshold - hysteresis<Temp<Cooler threshold=>Cooler stays on
Temp<Cooler threshold - hysteresis=>Cooler turns off

@Ranjib Found a possible technical issue.
In the code you check for
case h.pastTarget == downerTarget && math.Abs(o.Value-h.config.Max) < h.config.Hysteresis:
when the cooler = downer should continue. However, when the temperature rises faster than the hysteresis within the check period it turns off immediately. This will make the cooler turn periodically on and off, when the hysteresis and/or period is too small. Same for the heater, which might not be desireable, since you are in that case already way past the threshold and definitely dont want the heater/cooler to fluctuate.
I would suggest to change this to:
case h.pastTarget == downerTarget && h.config.Max - h.config.Hysteresis < o.Value:
and
case h.pastTarget == upperTarget && o.Value < h.config.Min + h.config.Hysteresis:
respectively.
I was thinking whether this has some security feature when the sensor crashes, but this would immeditely switch the Heater/Cooler on the next period again anyway. So I think it might be usefull to program this kind of "bad sensor" error mode more effectively.


Looking over the ESP32 code it doesn't look like it, yet. This gave me an idea however: there are convenient Arduino libraries for running a stepper motor on an ESP32:
@Ranjib I haven't looked at them myself yet, but it might be very easy to incorporate Stepper Motor functionality that way.

Security wise I'm afraid it is currently the same as with the PCA9685: if the ESP32 doesn't get an off command due to WiFi or Raspberry issues, it doesn't change its state. That should be easy to fix though:
- The quick and dirty method would be to manually define maximum runtimes in the ESP32 code, either generally for all jacks (even if it is used for a light) or specifically for the jack that the doser is connected to.
- The proper way would require an additional feature in the Reef-Pi ESP32 driver and doser handling and establishing a separate method in the ESP32 code for "dose with PWM power x for interval y"
I think this is what you meant, on the last line when Heater Threshold + Hysteresis is greater than temp (you had less) it shuts off, right?

Temp<Heater threshold=>Heater goes on
Heater threshold<Temp<Heater threshold + Hysteresis=>Heater stays on
Heater threshold + Hysteresis>Temp=>Heater turns off

I've always seen threshold as the ceiling, as long as it's below the ceiling the outlet stays on, when it hits the ceiling (threshold) it turns off...this is what we see in the logs:

Dec 13 08:53:52 octopi reef-pi[5675]: 2022/12/13 08:53:52 Current value of 'Tank temp' is below minimum threshold. Executing up routine

below threshold leaves the outlet on, if the outlet was off it would turn it on...then adding Hysteresis is the float value, so you can hit the threshold + x and it will stay on until it goes outside of that range which corresponds to what you have above. I had something wonky going on and not sure but once I hit reload it seems to behave. I've always let my heater control the temp and set reef-pi to shut it off if the tank hits a certain temp over what it's set for, like a glorified inkbird. Others set the heater thermostat higher and let reef-pi control the heater and if it fails then allow the heater thermostat to kick in as fail safe. All heaters are junk IMHO just a matter of time when they fail so I have multiple temp probes and have reef-pi be the fail safe, plus Im just not sure how long my relays could go turning on/off the heater.
 

How difficult is it REALLY to keep Acropora corals?

  • 1 - easy to keep

    Votes: 17 3.4%
  • 2

    Votes: 6 1.2%
  • 3

    Votes: 13 2.6%
  • 4

    Votes: 12 2.4%
  • 5 - average

    Votes: 133 26.5%
  • 6

    Votes: 45 9.0%
  • 7

    Votes: 131 26.1%
  • 8

    Votes: 75 15.0%
  • 9

    Votes: 17 3.4%
  • 10 - difficult to keep

    Votes: 52 10.4%
Top