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

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Nice, can you elaborate on why you need that extra resistor ? Change the amplification on the OP-Amps ?
Let's see if you can tell me? :grinning-face-with-smiling-eyes: :face-with-tears-of-joy: :rolling-on-the-floor-laughing:
 

Attachments

  • robo-tank_pH2.jpg
    robo-tank_pH2.jpg
    95.5 KB · Views: 82

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
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,
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
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. :)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
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 :)
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
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
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
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

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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
View Badges
Joined
Jan 15, 2020
Messages
1,695
Reaction score
1,607
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

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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
View Badges
Joined
Jan 15, 2020
Messages
1,695
Reaction score
1,607
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

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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:

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
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.
 

Rovert

Active Member
View Badges
Joined
Jun 14, 2022
Messages
369
Reaction score
282
Location
Lords Valley, PA
Rating - 100%
3   0   0
Welcome to the development thread of reef-pi, an open-source, affordable, modular DIY reef-tank controller based on Raspberry Pi...
Howdy, folks. First post in this thread, I've been poking my head in periodically to see what's been going on.

As someone whose business is dependent on Raspberry Pi availability, I'm wondering if @Ranjib and the dev team have been frustrated by the lack of availability of Pi units on the market. I'm given to understand that the Pi Foundation has prioritized OEM partners and dialed back on making units available for retail distributors servicing the hobbyist market by allocating supply so tightly that resellers allow only one per customer.

I'm just wondering how easy it might be to port the code from a Raspberry Pi to, say, a Rock Pi, Jetson Nano or other such board to keep the project alive and flourishing in the face of supply chain constraints. Those boards may be more expensive at list price, but given the scarcity of Pi4 units selling for upwards of $150 each for the 4GB model, it might be a good strategy to not 'put all the eggs in one basket' by considering another platform.

Just curious... thanks for reading.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
Location
Germany
Rating - 0%
0   0   0
Howdy, folks. First post in this thread, I've been poking my head in periodically to see what's been going on.

As someone whose business is dependent on Raspberry Pi availability, I'm wondering if @Ranjib and the dev team have been frustrated by the lack of availability of Pi units on the market. I'm given to understand that the Pi Foundation has prioritized OEM partners and dialed back on making units available for retail distributors servicing the hobbyist market by allocating supply so tightly that resellers allow only one per customer.

I'm just wondering how easy it might be to port the code from a Raspberry Pi to, say, a Rock Pi, Jetson Nano or other such board to keep the project alive and flourishing in the face of supply chain constraints. Those boards may be more expensive at list price, but given the scarcity of Pi4 units selling for upwards of $150 each for the 4GB model, it might be a good strategy to not 'put all the eggs in one basket' by considering another platform.

Just curious... thanks for reading.
You came at the right time, update 6.0 does something like that:
Enabling the user to install Reef-Pi on a x86 system such as a mini PC and outsourcing hardware connections to an ESP32 microcontroller, currently interfaced using WiFi.

This currently comes at the cost of system reliability being directly dependant on WiFi reliability, but I'm sure this will improve over time.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
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:
Another thing I just noticed: I'm not sure if those two 100nF capacitors after the OP-Amp have currently any effect, apart from generating a high-frequency load on that OP-AMP and increasing power draw.
If you want to use those capacitors as a filter you need a resistor between them and the OP-Amp.
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Another thing I just noticed: I'm not sure if those two 100nF capacitors after the OP-Amp have currently any effect, apart from generating a high-frequency load on that OP-AMP and increasing power draw.
If you want to use those capacitors as a filter you need a resistor between them and the OP-Amp.
Thanks, those were suggested when the extra resistor for ORP was added, maybe I'll just remove them as I'm happy with the performance without them. During my tests they didn't seem to do anything anyways but thought I would leave them.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
Location
Germany
Rating - 0%
0   0   0
Thanks, those were suggested when the extra resistor for ORP was added, maybe I'll just remove them as I'm happy with the performance without them. During my tests they didn't seem to do anything anyways but thought I would leave them.
True, they would filter out noise with a resistor, but that would limit your ability to average the ADC measurement below the ADC resolution, since you need noise for that.
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 37 27.8%
  • 100% dry rock + 100% live sand

    Votes: 45 33.8%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 29 21.8%
  • 75% live rock, 25% live sand

    Votes: 12 9.0%
  • 25% live rock, 75% live sand

    Votes: 10 7.5%
Back
Top