ReefSpy / ReefberryPi

DIY Aquarium Controller
8 stars 5 forks source link

Fan control and custom channels for relay #31

Open blshkv opened 1 month ago

blshkv commented 1 month ago

Hi, thanks for the great project!

I set it up for my hardware and facing an issue: I need to control a fan. The logic is the same as for the heater (apparently) because I connect it to a reversed (NC, normally closed) pin. Switch ON the "Heater" (i.e. reversed: Fan is OFF physically) if it gets below MIN_TEMP Switch OFF the "Heater" (i.e. reversed: Fan is ON physically) if it gets above MAX_TEMP

I also use a different relay board, Waveshare compatible but with 4 relays. Its channels are the following

Relay_Ch1 = 19
Relay_Ch2 = 26
Relay_Ch3 = 20
Relay_Ch4 = 21

So there are few things can be improved in the software:

Do let me know if you need any additional details. Thank you again

ReefSpy commented 2 weeks ago

Hi thanks for taking time to check out my project! Sorry for late reply, I was pulled off this project recently, but should have time to start working on it again soon. I apologize for the state of the relays right now, they are not in a good state and you might notice things are not behaving as they should.

First issue: I was using RPi.gpio library to control the relays and MCP3008 controller. This library is depreciated and will not work with Raspberry Pi 5, so I am replacing this code with using the gpiozero library. The change is complete for the MCP3008 code, but not on the relay code. This means there are currently 2 libraries fighting to control gpios and this is not good and is breaking things.

Second issue: I starting fixing the relay code, then I realized, I wanted to completely change the relay boards I use. I want to move to I2C capable relay boards which means I won't be using so many GPIO pins to control each individual relay. With the change I have in mind, I will be able to daisy chan many relay boards together, so I won't just be limited to 8 channels, I plan to support 16 or 24 individually addressed relays and this would only take 4 pins of GPIO.

I will take your comments into consideration when I get a chance to start on this code. Thanks for helping out and please let me know if you have any more ideas or issues!