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

Michael Lane

Active Member
View Badges
Joined
Aug 11, 2018
Messages
254
Reaction score
510
@Ranjib I just got one of @Michael Lane 's HATs (v2) and hooked it up to my Pi 3, however, when I went into config tab (3.0.0-pre-alpha-2 ) there doesn't seem to be a way to enable the PCA9685? When I tried to add a PCA9685 driver (PCA9685 from dropdown, channel 68, freq1500) I received an error, which I'm assuming is due to PCA9685 not being enabled.

Is this something that needs to be done manually?

config.JPG driver.JPG 20190731_085831 (1).jpg
I don't see any of the pca9685 address pins soldered, so that means is it using the default address of 0x40. Instead of entering 68 as the address, please enter 64.
 
Get Fish & Corals directly for the suppliers

Coastal Aquatics

Member
View Badges
Joined
May 16, 2019
Messages
48
Reaction score
15
Welcome to the development thread of reef-pi, an open-source, affordable, modular DIY reef-tank controller based on Raspberry Pi.

aio.jpg

If you are trying to build a reef-pi controller, please check out the build guides linked below. You can use this thread to seek help and to stay updated with the latest development.

Screen Shot 2018-11-04 at 8.38.50 PM.png



reef-pi provides following functionalities:
  • Equipment control or automated power strip (including digital timers to switch on/off equipment at periodic intervals)
  • LED light control (24 hour cycle), diurnal cycle, fixed dimmig
  • Auto Top Off (based on photoelectric water level sensor or float switch)
  • Temperature monitoring and control (switch on/off heater & chiller)
  • pH monitoring
  • Dosing automation
  • Macro (feed mode etc)
  • And several other features like camera controls (periodic image capture and upload on google drive), telemetry (dashboard and alerting based on sensor values using adafruit.io), mobile friendly UI etc.
A beginner friendly list of reef-pi build guides are available on adafruit.io, if you are planning to build a reef-pi controller start with them.
  1. Setup and installation
  2. Power controller
  3. Temperature controller
  4. Auto Top Off
  5. Light controller
  6. pH monitor
Since reef-pi is modular and customizable, the cost of individual builds varies. In our experience reef-pi controller are almost always cheaper than the commercial alternatives and costs anywhere between 100 to 550 USD. An example bill of materials can be found here as amazon list. If you are building a reef-pi controller, I highly encorage you start a build thread and tag it with #reefpi to seek help with your build


--------------------------- Original thread start ---------------------
Hello friends,
I am starting a master thread for a DIY reef tank controller that is based on all opensource software and hardware. I had started with this project with following goals:
- Build an opensource software and hardware based reeftank controller that anyone can use and hack
- Keep the controller well tested against a set of standard equipment I use, while make it possible for other equipment to be used
- Maintain my own tank build threads and their evolution, backed by this controller.
- Learn electronics and reef keeping along the way (I am biologist by education & software engineer by occupation)

Following are the details of what I have developed & tested till now:
Controller software:
- The main controller software is called reef-pi. It is written in go, its fast and performant. It used embd for hardware communication. It also runs a little web server which provides the UI for the controller. UI is written in React , and can be accessed from anything that has web browser. As of now, the reef-pi supports following things:
- AC 110/220 V socket on/off (uses optocoupled relays underneath). This is used to remotely switch on/off return pump, LED bulb, heater etc.
- 0-20 Volt DC PWM. This is used to control things like dimmable LEDs, DC pumps. I use it to control my Kessil A80, A360. As well as a 5V DC pump (i use it as wave maker in one of my pico with SPS). PWM is done using PCA9685 breakout board from adafruit. This board supports 16 channels. I am using only 5 at max, as of now.
- Analog sensor support using MCP3008 analog to digital converter. This supports 8 channels. i.e. I can use up to 8 sensors/probes. As of now, I have only tested temperature sensor with it.
Other than the following basic hardware/equipment support, the controller software provides following additional features:
- Setting up daily/weekly/monthly scheduled jobs. Like turning on/off certain equipment. I use this feature to run my AC20 HOB filter nightly.
- Setting up dusk-to-dawn like lighting using PWM. The UI gives 12 vertical slider based 0-24 hours (each slider representing 2 hours gaps). I combine two of these two control the kessil LEDs.
- Authentication using Google OAuth. Since the whole controller runs on raspberry pi and provides an web frontend, security of one of my concern. To mitigate this, I have added google authentication support, which when configured will allow only certain users to log in (email specified in the configuration value).

This is the summary of the core controller software and what features it has as of now. I am constantly writing/improving things around it. As of now, I have two reef tank powered by this. I 'll have seperate threads on the individual builds that will include the housing and ancillary hardware in nano-reef.com, as my tank build threads are there, but I'll share all the controller specific common bits here, including UI screen shots, and tank pics :)

20161115_081550.jpg
This is awesome thanks!
 

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
Just to repair my first Q: i2cdetect is working now BUT i got 3 addresses 0x40 ,0x70 ,and 5x45, how to figure out what is what?Thank you for your time and help.
 

Michael Lane

Active Member
View Badges
Joined
Aug 11, 2018
Messages
254
Reaction score
510
Just to repair my first Q: i2cdetect is working now BUT i got 3 addresses 0x40 ,0x70 ,and 5x45, how to figure out what is what?Thank you for your time and help.
0x40 - pca9685 PWM chip normal address
0x70 - pca9685 PWM chip "All Call" address
0x45 - probably pH board with both jumpers connected [post edited for correction]

Addresses are usually specified in data sheets, but it's often easier to figure out by disconnecting components when working with modules.
 
Last edited:

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
Thank you Michael i do not have 0x75 ,but on the PH board both jumper is on.What i have
0x40
0x70
and not sure 0x45 but the 45 is in the 5th line.
 

Michael Lane

Active Member
View Badges
Joined
Aug 11, 2018
Messages
254
Reaction score
510
Thank you Michael i do not have 0x75 ,but on the PH board both jumper is on.What i have
0x40
0x70
and not sure 0x45 but the 45 is in the 5th line.
That was a typo, I meant 0x45
 
Corals.com
OP
Ranjib

Ranjib

Valuable Member
View Badges
Joined
Apr 16, 2016
Messages
6,811
Reaction score
11,829
Location
Palo Alto, Bay Area
Testing out the new tplink drivers. Here is the chart for current draw from the heater that I used during new saltwater mix.

The resident current draw is 0.0169A, without any device attached to the outlet,
Screen Shot 2019-08-03 at 12.39.00 AM.png


when on the heater is drawing 0.111A .
Screen Shot 2019-08-03 at 12.33.25 AM.png


If I zoom in on the data, I can see some variation,
Screen Shot 2019-08-03 at 12.32.51 AM.png


At this point, I don't know how to interpret the data other than computing raw wattage and cross-check if that matches with the heater rating. I have a kill a watt, and I plan to do some cross-check with that as well. Being an analog input (exposed as ph probe) I should be able to apply one or two-point calibration if needed.
 

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
Hi to all,why do i got unauthorized when i try to calibrate with curl? Thank you and this is the log:
03/08/2019, 18:48:40UIERROR{"error":"json: cannot unmarshal object into Go value of type []hal.Measurement"} | HTTP 400

Screenshot from 2019-08-03 18-45-56.png Screenshot from 2019-08-03 18-10-59.png
 
OP
Ranjib

Ranjib

Valuable Member
View Badges
Joined
Apr 16, 2016
Messages
6,811
Reaction score
11,829
Location
Palo Alto, Bay Area
Hi to all,why do i got unauthorized when i try to calibrate with curl? Thank you and this is the log:
03/08/2019, 18:48:40UIERROR{"error":"json: cannot unmarshal object into Go value of type []hal.Measurement"} | HTTP 400

Screenshot from 2019-08-03 18-45-56.png Screenshot from 2019-08-03 18-10-59.png
The error is confusing. You are not unauthorized, your request is failing because the api is wrong, theres no /api/calibrate , i think its /api/phprobes/{id}/calibrate (replace id with your phprobe id)
 
OP
Ranjib

Ranjib

Valuable Member
View Badges
Joined
Apr 16, 2016
Messages
6,811
Reaction score
11,829
Location
Palo Alto, Bay Area
The error is confusing. You are not unauthorized, your request is failing because the api is wrong, theres no /api/calibrate , i think its /api/phprobes/{id}/calibrate (replace id with your phprobe id)
For the non-existent /api/calibrate behavior, I just cross checked, with 2.4 I am not getting unuathorized error, I'm seeing 404 resource not found error, as expected
 

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
Thank you Ranjib i try to copy paste everything from your earlier post and could not calibrate all day long.Deleted everything reinstalled and still not working. Followed your post and could not do.Could you redirect me to read something how to create that calibrate.json file? Why my try is always unauthorized ?
Screenshot from 2019-08-02 08-44-28.png
Screenshot from 2019-08-02 08-44-28.png
 

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
This is what i try all day long.
Code:
[/LIST]
[
{"expected":8.21, "observed": -8768},
{"expected":8.12, "observed": -8189}
]
reef-pi requires authentication for api, we'll use one curl command to get the authentication token, and another to use the token to apply our calibration data. Remember to disable the ph monitor before applying calibration.
Code:
curl -d @creds.json -X POST http://<IP>/auth/signin -c cookie.txt
curl -X POST -d @calibration.json -b cookie.txt http://<IP>/api/phprobes/1/calibrate

Note, the last command assumes the ph monitor id is 1, which will be the case if you create a ph monitor first. If you delete and create another one it will be 2 and so on.. so if you are making a re-attempt then update the command accrodingly. Calibration details are specific to individual probes/ph monitors. You can always checkout your existing ph probes and their ids using this command

Code:
curl -b cookie.txt http://<IP>/api/phprobes/
 
OP
Ranjib

Ranjib

Valuable Member
View Badges
Joined
Apr 16, 2016
Messages
6,811
Reaction score
11,829
Location
Palo Alto, Bay Area
Why is the sign in is null,and the equipment []

Screenshot from 2019-08-03 21-04-50.png
"null" is ok. It does not mean anything is wrong, it means signin was successfull. [] stands for empty list in equipment, i.e. there is no equipment present yet
 

janos

Active Member
View Badges
Joined
Jun 4, 2017
Messages
252
Reaction score
236
Location
Toronto,Canada
Thank you Ranjib,so what is that mean?do i have the right setup for calibration?Where to save the calibration.json. Ask because when i try to calibrate i got error msg.:
TimeEmitterTypeContent
04/08/2019, 06:57:06UIERROR{"error":"json: cannot unmarshal object into Go value of type []hal.Measurement"} | HTTP 400

Screenshot from 2019-08-04 06-54-53.png
 
Top Shelf Aquatics

Do you use Instagram for reefing stuff? What’s your handle?

  • Yes I follow people

    Votes: 27 23.7%
  • Yes and I post reefing content

    Votes: 20 17.5%
  • No IG isn’t for me

    Votes: 60 52.6%
  • What is IG?

    Votes: 7 6.1%

Online statistics

Members online
806
Guests online
2,242
Total visitors
3,048
Underwatergardeners
Battlecorals
Top