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

mikeh77

New Member
View Badges
Joined
May 29, 2017
Messages
7
Reaction score
8
Rating - 0%
0   0   0

MaccaPopEye

Well-Known Member
View Badges
Joined
Jan 5, 2016
Messages
697
Reaction score
1,234
Rating - 0%
0   0   0
@Ranjib thank you for sharing your project and especially for writing it up well so that those with no experience in this area can try to make their own controller.

I am considering having a go at building my own controller towards the end of the year but I have never done anything remotely electrical before (I find messing with 230V a bit scary - but I will have an electrician check all my work) and my programming experience is extremely basic (and was 10 years ago), but for now I'm just doing a lot of research and learning as much as I can :)

I have a question about the relays, how many can a pi support? I have a 180gal tank and would like to know the maximum number of controllable outlets I could have.

And have you heard of "Node Red" before? I've seen another controller build that uses it and it seems like a really simple drag and drop logic tool to make commands, is it compatible with your software?

Cheers,

Macca
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
@MaccaPopEye thanks for the kind words. Dont worry about the learning curve, the community exist to help you with that, as long as there is a will, there will be a way.
Pi natively support upto 26 GPIO pins at max, we'll be using some of them for additional electronics other than the relay, I'll say 17 is a safe upper limit.
Also, Pi's GPIO can be very easily extended with a GPIO expander like this . What it means, is you can pretty much control tens if not hundreds of relays using raspberry Pi. I would be more concerned about the electrical aspects of it (i.e. surge protection, GFCI & fuse etc) for larger number of electrical outlets. Theres a electrical guru thread here, we can consult there for further guidance. I can help with the electronics (Pi & ICs) part.

I have used "Node Red" before, I was considering it seriously when starting the project, along side python. I went with go because 1) its more performant (reef-pi will run multiple concurrent things) than nodejs and python, hence we can do more with it in a single Raspberry Pi, 2) It makes packaging software easier (less things to do once you download the software), 3) Its easier to maintain projects in the long run due to less external dependencies .. there are several other reasons, but these are few. At the end, it was clear I'll be doing the basic stuff only once, but lot more device management as well as computation intensive (PID controlller, image recognition) in the long term with reef-pi, hence the ease of programming was not a very compelling factor.
To summarize: reef-pi is not compatible with node red. Node red is general purpose IoT framework, reef-pi is ground up built for reef tanks :)
 

MaccaPopEye

Well-Known Member
View Badges
Joined
Jan 5, 2016
Messages
697
Reaction score
1,234
Rating - 0%
0   0   0
@MaccaPopEye thanks for the kind words. Dont worry about the learning curve, the community exist to help you with that, as long as there is a will, there will be a way.
Pi natively support upto 26 GPIO pins at max, we'll be using some of them for additional electronics other than the relay, I'll say 17 is a safe upper limit.
Also, Pi's GPIO can be very easily extended with a GPIO expander like this . What it means, is you can pretty much control tens if not hundreds of relays using raspberry Pi. I would be more concerned about the electrical aspects of it (i.e. surge protection, GFCI & fuse etc) for larger number of electrical outlets. Theres a electrical guru thread here, we can consult there for further guidance. I can help with the electronics (Pi & ICs) part.

I have used "Node Red" before, I was considering it seriously when starting the project, along side python. I went with go because 1) its more performant (reef-pi will run multiple concurrent things) than nodejs and python, hence we can do more with it in a single Raspberry Pi, 2) It makes packaging software easier (less things to do once you download the software), 3) Its easier to maintain projects in the long run due to less external dependencies .. there are several other reasons, but these are few. At the end, it was clear I'll be doing the basic stuff only once, but lot more device management as well as computation intensive (PID controlller, image recognition) in the long term with reef-pi, hence the ease of programming was not a very compelling factor.
To summarize: reef-pi is not compatible with node red. Node red is general purpose IoT framework, reef-pi is ground up built for reef tanks :)

Thank you for the reply :)

I should easily be able to work with 17 or even 16. I think I hit 21 outlets used now but not all need to be controlled, or some can be combined by a Powerboard on a single controllable outlet. Especially if I can get the dimming on my lights (3x Mars aqua LEDs) somehow done by the controller then I could just plug them all into one power board (turns 6 plugs into 1).

In you bill of materials you link to a 4 channel solid state relay. Is there a reason to use them over the other kind of relays? ( I think they are electromagnetic relays). And is it better to get 2x banks of 8 relays of 1x bank of 16 relays (I've only found the 16 bank as electromagnetic relays, not ssr).

Thanks so much for answering a few questions :) I am thinking I might be able to get something off the ground before the end of the year now :D
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Things that you think will be on-off together, can be clubbed in same relays. Like I on/off my return, skimmer and ATO together (during water change), so i just use a dedicated power brick, which in turn controlled by a single relay. Something like this is also good, its optocoupler based, and the wiring is same, without the need of external relay.
Solid state relays last longer. In reality I started with mechanical relays (they make sound :) ) , and then during Makerfaire the man who grew the mechanical giraffe told me to go with solid state relays, they run longer and more stable (his giraffe is fairly old), this was echoed by others and my later internet reasearch :) . Hence i have mentioned them in the BoM , currently I have one with SSR other one mechanical. There are optocoupler based relays as welll,
 

ClaudioA

New Member
View Badges
Joined
Jun 7, 2017
Messages
16
Reaction score
13
Rating - 0%
0   0   0
Hi @Ranjib, I woul like to try the reef-pi. I have an 8 relay board, a PCA9685 board with 8channel and two temp.sensor DS18B20. I'm trying to configure but I have always errors: I set only one relay (on gpio5) for an simple configuration
Code:
---
controller:
  enable_gpio: true
  enable_pwm: false
  enable_adc: false
  enable_temperature_sensor: false
  database: "reef-pi.db"
  outlets:
  AC1:
  pin: 5
  equipments:
  Return: AC1
  lighting:
  enabled: true
  intensity_channel: 0
  spectrum_channel: 1
api:
  address: "localhost:8080"
  enable_auth: false
  auth:
  id: 35adsjfaksjfdhks5eun435b.apps.googleusercontent.com
  secret: adqwieuqiwue
  callback_url: http://localhost:8088/auth/callback/google
  domain: example.com
  users:
  - foobar
  gomni_auth_secret: sadfhsadfkh238asdf
  image_directory: /var/lib/reef-pi/images
  interface: eth0

but I have this message:

Code:
root@raspberrypi:/home/pi/reefpi# systemctl status reef-pi.service
● reef-pi.service - raspberry pi based reef tank controller
  Loaded: loaded (/lib/systemd/system/reef-pi.service; enabled)
  Active: failed (Result: exit-code) since mer 2017-06-07 13:00:16 CEST; 2s ago
  Process: 1427 ExecStart=/usr/bin/reef-pi -config /etc/reef-pi/config.yml (code=exited, status=1/FAILURE)
 Main PID: 1427 (code=exited, status=1/FAILURE)

giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Initializing DB for ato_configs bucket
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Initializing DB for inlets bucket
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Initializing DB for lightings bucket
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Enabled GPIO subsystem
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Creating equipment: Return
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Setting GPIO Pin: 5 On: false State: 0
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 Failed to precreate equioment: Return
giu 07 13:00:16 raspberrypi reef-pi[1427]: 2017/06/07 13:00:16 embd: your host ": ARMv7 Processor rev 5 (v7l)" is not supported at this moment. request support at https://git.../embd/issues
giu 07 13:00:16 raspberrypi systemd[1]: reef-pi.service: main process exited, code=exited, status=1/FAILURE
giu 07 13:00:16 raspberrypi systemd[1]: Unit reef-pi.service entered failed state.

Can you also explain to me exactly what these parameters refer to?
  • enable_gpio: true (enable the gpio control from outlets?)
  • enable_pwm: false (enable PCA9685 control?)
  • enable_adc: false (?)
  • enable_temperature_sensor: false (which kind of sensor do you manage? is possible to mange the ds18b20?
  • lighting:
    enabled: true
    intensity_channel: 0
    spectrum_channel: 1
Thanks for your great work.
 

sbash

Valuable Member
View Badges
Joined
Mar 17, 2014
Messages
1,659
Reaction score
1,123
Location
Ottawa, Canada
Rating - 0%
0   0   0
Hi @Ranjib I have an 8 relay board, a PCA9685 board with 8channel and two temp.sensor DS18B20.

Have you had the DS18B20 submerged for long? All mine rusted in the tip within the first month in my tanks... If you have had success, I might just have a bad (or cheaper made) batch...
 

sbash

Valuable Member
View Badges
Joined
Mar 17, 2014
Messages
1,659
Reaction score
1,123
Location
Ottawa, Canada
Rating - 0%
0   0   0
Sincerely I still have to start and then dip it

What do you mean 'dip it'?

Also, looking at the error, it looks like the service itself is just bailing; quite possibly due to the processor... What generation of pi are you using? It looks like there might be an issue with Pi 3's and Go at the moment...

https://github.com/kidoman/embd/pull/79
 

ClaudioA

New Member
View Badges
Joined
Jun 7, 2017
Messages
16
Reaction score
13
Rating - 0%
0   0   0
What do you mean 'dip it'?
I have not tried it yet.

Also, looking at the error, it looks like the service itself is just bailing; quite possibly due to the processor... What generation of pi are you using? It looks like there might be an issue with Pi 3's and Go at the moment...

https://github.com/kidoman/embd/pull/79

I have a RPi v2. Is there a way to bypass this problem?
 

sbash

Valuable Member
View Badges
Joined
Mar 17, 2014
Messages
1,659
Reaction score
1,123
Location
Ottawa, Canada
Rating - 0%
0   0   0
I have a RPi v2. Is there a way to bypass this problem?

Good question, if you installed from a .deb file (as mentioned in this thread), it is likely due to OP compiling the software on his Pi v3... It looks like he might need to recompile it to support older Raspberry Pi's...

I would rather not speculate further, as I am not very familiar with using GO (I do all my Pi work with bash, php and python, so I am not that progressive, lol)... Best wait for @Ranjib to respond if you do not have a Pi v3 handy...
 

ClaudioA

New Member
View Badges
Joined
Jun 7, 2017
Messages
16
Reaction score
13
Rating - 0%
0   0   0
I would rather not speculate further, as I am not very familiar with using GO (I do all my Pi work with bash, php and python, so I am not that progressive, lol)... Best wait for @Ranjib to respond if you do not have a Pi v3 handy...
Me too...I try to recompile and if I don't enable pwm:
Code:
root@raspberrypi:~# systemctl status reef-pi.service
● reef-pi.service - raspberry pi based reef tank controller
  Loaded: loaded (/lib/systemd/system/reef-pi.service; enabled)
  Active: active (running) since mer 2017-06-07 17:16:40 CEST; 1s ago
 Main PID: 7639 (reef-pi)
  CGroup: /system.slice/reef-pi.service
  └─7639 /usr/bin/reef-pi -config /etc/reef-pi/config.yml

giu 07 17:16:40 raspberrypi systemd[1]: Started raspberry pi based reef tank controller.
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Enabled GPIO subsystem
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Setting GPIO Pin: 5 On: false State: 0
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 ERROR: Failed to sync equipment:Return . Error:embd: your host ": ARMv7 Processor rev 5 (v7l)" is not supported.../embd/issues
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Started Controller
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Starting http server at: localhost:8080
I'm out and I can open only ssh, later I'll try to connet on webpage

but when I try to enable PWM:
Code:
● reef-pi.service - raspberry pi based reef tank controller
  Loaded: loaded (/lib/systemd/system/reef-pi.service; enabled)
  Active: failed (Result: exit-code) since mer 2017-06-07 17:17:58 CEST; 1s ago
  Process: 7675 ExecStart=/usr/bin/reef-pi -config /etc/reef-pi/config.yml (code=exited, status=2)
 Main PID: 7675 (code=exited, status=2)

giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/kidoman/embd.NewI2CBus(0x7efb01, 0x17, 0x10b61d80)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/kidoman/embd/i2c.go:75 +0x70
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.NewPWM(0x7c0f50, 0x10b0c058, 0x1)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/pwm.go:23 +0x1c
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.(*State).Bootup(0x10b61b80, 0x0, 0x0)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/state.go:43 +0x3bc
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.(*Controller).Start(0x10b61cc0, 0x0, 0x10c085a0)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/controller.go:57 +0x48
giu 07 17:17:58 raspberrypi reef-pi[7675]: main.main()
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/commands/main.go:50 +0x17c
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Nice job!

What temperature sensor have you been using? I am having a hard time finding one that is safe with salt water. (can you post an amazon, or aliexpress link???)
I'll recommend using any probe from bulkreefsupply or marinedepot (or some other reef/saltwater specificshop) that uses bnc connector.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Have you had the DS18B20 submerged for long? All mine rusted in the tip within the first month in my tanks... If you have had success, I might just have a bad (or cheaper made) batch...
I don't use ds18b20 . I am currently using a coralife digital thermometer's probe (i cut off the probe from the rest and connected a barrel jack to it, if i do it again I'll go with BNC connector instead)
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Me too...I try to recompile and if I don't enable pwm:
Code:
root@raspberrypi:~# systemctl status reef-pi.service
● reef-pi.service - raspberry pi based reef tank controller
  Loaded: loaded (/lib/systemd/system/reef-pi.service; enabled)
  Active: active (running) since mer 2017-06-07 17:16:40 CEST; 1s ago
Main PID: 7639 (reef-pi)
  CGroup: /system.slice/reef-pi.service
  └─7639 /usr/bin/reef-pi -config /etc/reef-pi/config.yml

giu 07 17:16:40 raspberrypi systemd[1]: Started raspberry pi based reef tank controller.
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Enabled GPIO subsystem
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Setting GPIO Pin: 5 On: false State: 0
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 ERROR: Failed to sync equipment:Return . Error:embd: your host ": ARMv7 Processor rev 5 (v7l)" is not supported.../embd/issues
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Started Controller
giu 07 17:16:40 raspberrypi reef-pi[7639]: 2017/06/07 17:16:40 Starting http server at: localhost:8080
I'm out and I can open only ssh, later I'll try to connet on webpage

but when I try to enable PWM:
Code:
● reef-pi.service - raspberry pi based reef tank controller
  Loaded: loaded (/lib/systemd/system/reef-pi.service; enabled)
  Active: failed (Result: exit-code) since mer 2017-06-07 17:17:58 CEST; 1s ago
  Process: 7675 ExecStart=/usr/bin/reef-pi -config /etc/reef-pi/config.yml (code=exited, status=2)
Main PID: 7675 (code=exited, status=2)

giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/kidoman/embd.NewI2CBus(0x7efb01, 0x17, 0x10b61d80)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/kidoman/embd/i2c.go:75 +0x70
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.NewPWM(0x7c0f50, 0x10b0c058, 0x1)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/pwm.go:23 +0x1c
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.(*State).Bootup(0x10b61b80, 0x0, 0x0)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/state.go:43 +0x3bc
giu 07 17:17:58 raspberrypi reef-pi[7675]: github.com/ranjib/reef-pi/controller.(*Controller).Start(0x10b61cc0, 0x0, 0x10c085a0)
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/controller/controller.go:57 +0x48
giu 07 17:17:58 raspberrypi reef-pi[7675]: main.main()
giu 07 17:17:58 raspberrypi reef-pi[7675]: /Users/ranjib/gocode/src/github.com/ranjib/reef-pi/commands/main.go:50 +0x17c
do you have i2c enabled ? your /boot/config.txt should have these.
remember to delete the database file (sudo rm /var/lib/reef-pi/reef-pi.db) every time you change output/equipments in /etc/reefpi/config.yml
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Good question, if you installed from a .deb file (as mentioned in this thread), it is likely due to OP compiling the software on his Pi v3... It looks like he might need to recompile it to support older Raspberry Pi's...

I would rather not speculate further, as I am not very familiar with using GO (I do all my Pi work with bash, php and python, so I am not that progressive, lol)... Best wait for @Ranjib to respond if you do not have a Pi v3 handy...
reef-pi should work on rpi 2 just fine. I used to run it on Pi 2 almost 10 months back. But since then I have moved to pi 3 (due to on-board wifi) and never tested with Pi2 . I suspect I have introduced a software bug that is causing this.

@ClaudioA if you can wait till weekend, I can get reef-pi tested on Rpi 2 and fix the issues (Pi zero is broken too, fixing that is also on my list).
I would highly appreciate raising an issue with details of you setup in github if you can. That will help me track these bugs and squash them before the next release
 

ClaudioA

New Member
View Badges
Joined
Jun 7, 2017
Messages
16
Reaction score
13
Rating - 0%
0   0   0
do you have i2c enabled ? your /boot/config.txt should have these.
remember to delete the database file (sudo rm /var/lib/reef-pi/reef-pi.db) every time you change output/equipments in /etc/reefpi/config.yml
yes, it is enable

Code:
root@raspberrypi:~# i2cdetect -y 1
  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:  -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
 

ClaudioA

New Member
View Badges
Joined
Jun 7, 2017
Messages
16
Reaction score
13
Rating - 0%
0   0   0
reef-pi should work on rpi 2 just fine. I used to run it on Pi 2 almost 10 months back. But since then I have moved to pi 3 (due to on-board wifi) and never tested with Pi2 . I suspect I have introduced a software bug that is causing this.

@ClaudioA if you can wait till weekend, I can get reef-pi tested on Rpi 2 and fix the issues (Pi zero is broken too, fixing that is also on my list).
I would highly appreciate raising an issue with details of you setup in github if you can. That will help me track these bugs and squash them before the next release

Which kind of info about the setup do you need?
 

HAVE YOU EVER KEPT A RARE/UNCOMMON FISH, CORAL, OR INVERT? SHOW IT OFF IN THE THREAD!

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%
Back
Top