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

elysics

Valuable Member
View Badges
Joined
Jan 15, 2020
Messages
1,520
Reaction score
1,511
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,006
Reaction score
976
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,520
Reaction score
1,511
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,006
Reaction score
976
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,006
Reaction score
976
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,344
Reaction score
1,722
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
334
Reaction score
293
Location
Milford, PA
Rating - 0%
0   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,006
Reaction score
976
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,006
Reaction score
976
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

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
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,006
Reaction score
976
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.
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
Location
Edmonton, Canada
Rating - 0%
0   0   0
Some good news for Christmas. :)




 

elysics

Valuable Member
View Badges
Joined
Jan 15, 2020
Messages
1,520
Reaction score
1,511
Rating - 0%
0   0   0
Some good news for Christmas. :)





100+ 4 1gb freely available, but no 2 or 4gb and no zeros :/ but maybe I'm too late
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
Location
Edmonton, Canada
Rating - 0%
0   0   0
100+ 4 1gb freely available, but no 2 or 4gb and no zeros :/ but maybe I'm too late
Yeah they aren't completely out of the woods yet. The first few months of 2023 there won't appear to be much improvement as they are selling to select people but hopefully in the 2nd quarter we start seeing them for sale.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,056
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
@Ranjib are webserver/api logs stored anywhere locally?
api docs are bundled with every reef-pi and accessible from the web ui, linked under the footer section
logs are in systemd journal and can be viewed as `journalctl -u reef-pi.service`
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
api docs are bundled with every reef-pi and accessible from the web ui, linked under the footer section
logs are in systemd journal and can be viewed as `journalctl -u reef-pi.service`
I do have to say that this is an absolutely gorgeous detail. However, sometimes I wish that this API documentation would go a bit more into detail about certain inputs, e.g. what kind of format it expects, or what options for certain parameters are.

Just a few examples:
- You mentioned a certain light profile that's only accessible from API
----> the API doesn't give any info about the profile types
- I wanted to implement a formula to convert the ESP32 AnalogRead to milli volts but was struggling with the format
----> the API only says "string"

These kinds of infos would be absolutely great and I guess the API Doc is possibly the simplest way of implementing this "Wiki" kind of information.
 

MikeSpike

Community Member
View Badges
Joined
Jan 2, 2019
Messages
73
Reaction score
52
Rating - 0%
0   0   0
Hi I use reef-pi across multiple devices eg a tablet , my iPhone. Dashboard config varies across these devices - is there a way to store the best layout for each rathe than just having one configuration across all my devices?
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,056
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Hi I use reef-pi across multiple devices eg a tablet , my iPhone. Dashboard config varies across these devices - is there a way to store the best layout for each rathe than just having one configuration across all my devices?
No . Not right now . It will be nice feature to have this (save different layouts and be able to select them ). Let me think about it, no promise though .
this can be easily done through grafana .
 

Clear reef vision: How do you clean the inside of the glass on your aquarium?

  • Razor blade

    Votes: 128 59.5%
  • Plastic scraper

    Votes: 63 29.3%
  • Clean-up crew

    Votes: 77 35.8%
  • Magic eraser

    Votes: 37 17.2%
  • Other

    Votes: 63 29.3%
Back
Top