Reef-pi + Home Assistant Build

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
200
Rating - 0%
0   0   0
I control my 2 small aquariums (one 40 gal fresh, one 15 gal nano reef) with a combination of Home Assistant (which also takes care of my apartment), Reef-Pi, and Motioneye.

I wanted the tanks to mirror specific locations as much as possible. For example, I’m querying various sites to get daily water temp, tide, and weather data. I also wanted to be able to monitor everything from outside the house, so it needed to be web accessible.

ha_bali.png
The reef tank:
  • Getting temp and ATO sensor data from reef-pi (Raspberry Pi 3B) and publishing via API, which Home Assistant installation can pick up as sensors
  • Water temperature changes daily according to NOAA data, dropping to lower averages at night, and higher at midday depending on the data coming from a reef in Bali.
  • Kessil Tuna Blue A80 fades up / down according to sunrise / sunset times, and offset by two hours so the late-waking humans can enjoy the tank.
  • High and low tides control the Jabao SW2 wavemaker on/off according to a script that increases intensity at mid-tide change for that specific location.
  • Top off and dosing from two peristaltic pumps on the reef-pi build. These are manual for now, because I'm not sure about speed and volume yet.
ha_amazon (1).jpeg
The freshwater planted tank:
  • Getting temp and ato sensor data from scripts on a Raspberry Pi Zero W, and broadcasting to Home Assistant sensors via MQTT
  • Water temp is targeted to a spot in the Amazon River. Amazon water temp data is hard to find so I had to go with monthly averages in a text file.
  • Finnex Fugeray Planted turns on / off according to sunrise / sunset times, offset by one hour, CO2 also goes on and off with the lights.
  • River high and low tides turn an extra pump on/off according to tide change for that location.
  • a pi-enabled barrel feeder, run from a script on a motioneye action button
  • a Pimoroni Octocam, which posts time lapse movies to twitter (@Octo_Cam_bot) and photos and stats for each feeding
reefpienclosure2.jpg reefpienclosure.jpg
Most simple power on/off switching is done with Tuya smart home outlets via home assistant. You can read about the hardware details of the Reef-pi controller on Thingiverse, with the enclosure files. Improvement has become a never-ending project but I think it’s pretty cool so I wanted to share. Will update the Github repository as I can.

Some other resources for aquarium control:
octocam.jpg Screen Shot 2018-12-16 at 9.18.40 PM.png

Nice work on the integration into Home Assistant.

I have a question. I finally started seeing MQTT messages from my ReefPi's but I am not sure if what I am seeing is normal and the same in your case as well. Looks like the MQTT message structure is not exactly as what I am used to seeing. Looks like the messages are published with single topic subscription. For example since there is a field ClientID under MQTT settings this would be listed as a Topic and then the subtopic for the parameter then the value. I am seeing just the subtopic for parameter and value.

I have this info same on all 3 Reef-Pi's so I suspect this is how they are but just wanted to check with you as you seem to have done a lot of work already with MQTT

Here is what I am seeing is yours the same?

1623071495075.png


The typical MQTT structure would be like this..

1623071546999.png
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
Nice work on the integration into Home Assistant.

I have a question. I finally started seeing MQTT messages from my ReefPi's but I am not sure if what I am seeing is normal and the same in your case as well. Looks like the MQTT message structure is not exactly as what I am used to seeing. Looks like the messages are published with single topic subscription. For example since there is a field ClientID under MQTT settings this would be listed as a Topic and then the subtopic for the parameter then the value. I am seeing just the subtopic for parameter and value.

I have this info same on all 3 Reef-Pi's so I suspect this is how they are but just wanted to check with you as you seem to have done a lot of work already with MQTT

Here is what I am seeing is yours the same?

1623071495075.png


The typical MQTT structure would be like this..

1623071546999.png
There is no "typical" MQTT structure, though it does seem to be getting more standardized across platforms. It's pretty much up to the developer (in this case @Ranjib ) how those channels are set up. What you have above is correct as of now.

If you have multiple reef-pi's the best you can do is name them with the tank info in the name - as I see you've done with "display_tank..." but as far as I could figure out things like "system_load" can't be changed as of yet, so you'll keep getting conflicting messages on the same channel.
 

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
200
Rating - 0%
0   0   0
There is no "typical" MQTT structure, though it does seem to be getting more standardized across platforms. It's pretty much up to the developer (in this case @Ranjib ) how those channels are set up. What you have above is correct as of now.

If you have multiple reef-pi's the best you can do is name them with the tank info in the name - as I see you've done with "display_tank..." but as far as I could figure out things like "system_load" can't be changed as of yet, so you'll keep getting conflicting messages on the same channel.
Thanks this is exactly what I was thinking. There is an "accepted" standard or best practice for implementing MQTT messaging but I know that MQTT is fairly new for Reef-Pi so hopefully @Ranjib will standardize the messaging so its pinned to the Client ID.

Yes you are correct at this time there is not way to display conflicting for these parameters as these are shared amongst all reef-pi's and descriptor is the same

1623080115297.png


The good news MQTT is working on 2 out of 3 reef-pi's. Still trying to figure out the last one.

Thanks for confirming my findings.
 

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
200
Rating - 0%
0   0   0
I have one more question for you if you could let me know please. Are you presently running any dosing using Reef-Pi? If so are you able to see any messages reported by the devices listed under Dosing Pumps? I am not sure if my observation is correct but it appears that Reef-Pi is reporting devices and their state as listed under Equipment and Lights. It is not reporting any devices under Dosing Pump. At least this is my experience so far.

These are reported:
1623092298106.png

These are not:
1623092334785.png


Here is the MQTT side:
1623092405940.png


are you seeing something simmilar?
 

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
Should i update the reef-pi code to use a specific channel. Sorry , I'm just trying to pick up any improvements you may want to see around the mqtt metrics emission. I am not personally using it, but happy to adhere to any best practices that's not a whole lot extra work for us,
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
Should i update the reef-pi code to use a specific channel. Sorry , I'm just trying to pick up any improvements you may want to see around the mqtt metrics emission. I am not personally using it, but happy to adhere to any best practices that's not a whole lot extra work for us,
Maybe @marekd1 has some suggestions but I imagine something like "reef-pi-name/doser-1/doser-name" would work

The most obvious option would be to just follow the same strings as the API. The one exception is that it would be great to be able to have more than one reef-pi installation with it's own name so that the basics like "system_mem_used" can be differentiated between different installations.
 

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
200
Rating - 0%
0   0   0
Maybe @marekd1 has some suggestions but I imagine something like "reef-pi-name/doser-1/doser-name" would work

The most obvious option would be to just follow the same strings as the API. The one exception is that it would be great to be able to have more than one reef-pi installation with it's own name so that the basics like "system_mem_used" can be differentiated between different installations.
I would suggest to utilize the existing ClientID field in the MQTT section. This would allow at minimum identifying the device. The goal is really just to group the function types/device types

Ideally it world be great if we could associate say {DeviceID}/{Reef-Pi-function}/{Equipment type/Device Type}/

So one example would be as follows:

Device ID set as Doser-01
ReefPi-Function- Dosing pumps
Device type Alkalinity

resulting string would be:
Doser-01/DosingPumps/Alkalinity/


Here is a typical example from one of tasmota devices.

1623760247646.png


resulting string is:

1623761315808.png
 

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
200
Rating - 0%
0   0   0
Should i update the reef-pi code to use a specific channel. Sorry , I'm just trying to pick up any improvements you may want to see around the mqtt metrics emission. I am not personally using it, but happy to adhere to any best practices that's not a whole lot extra work for us,
Ranjib, can you please confirm that MQTT is working for the dosing pumps. I am not able to get any messaging. The only messages for dosing that I have if I built direction control under the Equipment menu. It tells me direction state.

Let me know if you need more examples.

BTW here is nice implementation by Atlas IoT

Device name/Sensor type/device bus address/user label/values

1623764717122.png
 
Last edited:
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
20221007_223034.jpg
20221007_222736.jpg Just updating my own thread since it's been a while. I got a new nano tank (thanks @f8thless!).

The vertical tank sump wasn't working well any more and to be honest it never really had the Par real estate for the kind of livestock I wanted. When the Kessil light stopped working it was a good excuse for an upgrade. I'll be resetting some of the reef-pi elements in the next few weeks as well so I'll probably post some more updates as I go along.
 
Last edited:
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
Incidentally, @Ranjib have you come across better dosing options than the generic peristaltic pumps I've been getting from Amazon? The two pumps are the parts that fail about every 6-12 months. I've looked around but they all kind of look the same at different price points. I don't think it's related to reef-pi, just the motors getting worn out with salt and corrosion.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Incidentally, @Ranjib have you come across better dosing options than the generic peristaltic pumps I've been getting from Amazon? The two pumps are the parts that fail about every 6-12 months. I've looked around but they all kind of look the same at different price points. I don't think it's related to reef-pi, just the motors getting worn out with salt and corrosion.
Interesting info !
Since the motors only work very little, you could try encapsulating them, so they never see the salty atmosphere.
Are you driving them with PWM and a transistor, like the Adafruit guide ? That could also possibly do some damage from the voltage spikes slowly eating at the solenoid insulation. Might be solvable by smoothing out the PWM to DC with a capacitor. That could however change the calibration.
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
Interesting info !
Since the motors only work very little, you could try encapsulating them, so they never see the salty atmosphere.
Are you driving them with PWM and a transistor, like the Adafruit guide ? That could also possibly do some damage from the voltage spikes slowly eating at the solenoid insulation. Might be solvable by smoothing out the PWM to DC with a capacitor. That could however change the calibration.
I'm using an h-bridge but an L298N, not the bare bones one like in the guide. I'm pretty sure those have capacitors build in to the unit.

I've checked all of them and can't see any signs of salt corrosion, unless it's only internal. While this last set was on the sump, they were pretty much encased in shrink tube, so I'm kind of stumped. Whatever I do for the next fix, I'm going to try and keep them out of the evap range.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
I forgot to ask before: are you even driving your pumps with a PWM signal ? If not, most of what I wrote and currently write is almost irrelevant ^^

Is your L298N a ready module like here ? It does have capacitors, but only to buffer input voltage, aka. protect your voltage source and other components from the influence of driving the Motor with PWM. It does however not protect your motor, apart from the kickback didoes, which is what I had in mind.
If you do not have a ready module and use the L298N chip by itself, you at least need to add kickback diodes yourself, otherwise the voltage spikes might damage your circuits and your motor.

I found a somewhat interesting article about DC motor drive with PWM and the impact on life-time here. It's not idealy written and sometimes a bit confusing, but from that I gather these infos:
- driving a dc motor with PWM can decrease lifetime drastically (worst case to less than half)
- in our case this is most likely due to current ripple in the motor
- current ripple can be reduced by:
----> increasing PWM frequency
----> smoothing out the ripple by adding additional inductance and/or a parallel capacitance

Also:
depending on the motor, certain frequencies can supposedly induce ultrasonic vibrations inside the motor, decreasing lifetime even more. Solution is supposedly a PWM frequency above 20 kHz.
 

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
Incidentally, @Ranjib have you come across better dosing options than the generic peristaltic pumps I've been getting from Amazon? The two pumps are the parts that fail about every 6-12 months. I've looked around but they all kind of look the same at different price points. I don't think it's related to reef-pi, just the motors getting worn out with salt and corrosion.
All my peristaltic pump has been running for years flawless. Couple of the were showing some grinding noise that I was able to fix by replacing the heads. I’m going with kamoer 12v peristaltic pumps for now. We have a stepper based driver as well. If salt exposure is the main problem, then may be we can design and more robust enclosure that only exposes the minimal power, tubing holes and hide the rest ?
 

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
i was using the doser exclusively on timer , not with pwm. After my initial tests I realized I don’t need to control the speed that often. And can play with dilution instead.
in recent times I have decided to use a dedicated control board mounted on the dosing enclosure itself that offers speed and direction control. Those are 4$ a piece, and given I only tune them once in a while, it gets the job done.
 
OP
OP
sfgabe

sfgabe

Active Member
View Badges
Joined
Sep 7, 2018
Messages
166
Reaction score
264
Rating - 0%
0   0   0
I got a good deal on a Jebao 2.4 wifi/manual doser before I got a chance to wire up the reef-pi pump heads. @Ranjib are you aware of any way to sync that up with reef-pi? Seems like it would need a driver similar to the Kasa power strips.
 
Back
Top