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

elysics

Valuable Member
View Badges
Joined
Jan 15, 2020
Messages
1,695
Reaction score
1,607
Rating - 0%
0   0   0
hi elysics so I registered the nous a1t and set it up in reef-pi. Thanks a lot for this. I assume that the a1t are only for switching and cannot use the power consumed in the ree-pi?
Hey sorry that I just come back to you now, you forgot the @ in front of my name for the tag to work.

yes it is possible.

I was going to change the code of the tasmota driver directly, but laziness won out and I used the file driver for that too. Didn't want to confuse you with even more code during setup

Again, this is only a lazy solution, not perfect code.

First, on your pi, install jq:

Code:
sudo apt-get install jq

Then, in your home folder, or somewhere else, create a folder just for the currents to keep everything neat, I chose /home/pi/currents, and then go into that folder:

Code:
mkdir /home/pi/currents
cd /home/pi/currents

Then create a script currscript.sh:

Code:
echo "curl -s http://\$1/cm?cmnd=STATUS+10 | jq '.StatusSNS.ENERGY.Current'>/home/pi/currents/snsCurr\$1">/home/pi/currents/currscript.sh

sudo chmod +x currscript.sh

Then create another script requestCurrs.sh that calls the first one for all the ips of your plugs, my ips are examples:

Code:
echo "/home/pi/currents/currscript.sh 192.168.178.25
/home/pi/currents/currscript.sh 192.168.178.26
/home/pi/currents/currscript.sh 192.168.178.27" >/home/pi/currents/requestCurrs.sh

sudo chmod +x requestCurrs.sh


Then, again, schedule the last script to run regularly, I chose every 20 seconds, but you can do every minute, it takes a couple seconds to run, type "crontab - e"
And add the following line at the end:
Code:
* * * * * /bin/bash -c ' for i in {1..3}; do /home/pi/currents/requestCurrs.sh; sleep 20; done'

Then you should have text files in the currents folder named something like snsCurr192.168.178.25 or whatever the ip address of that particular plug is, that text file contains the current measurement.

Go into reef pi, Configuration->Drivers

And add a file-analog driver per plug and and input the path to the corresponding file like /home/pi/currents/snsCurr192.168.178.25

Then configuration->connectors->analog inputs and add a input per newly created driver, pin 0

Then go into the pH menu and add a pH Probe per newly created connector, check frequency 20 seconds or whatever period you chose, chart minimum 0, chart maximum whatever makes sense for your device, chart unit you can use "A" for Ampere if you want.

Then you can add those "pH probes" to your dashboard and/or do logic with them or whatever you want.

And now my fingers are sore from typing this on a phone, I hope there are no typos in the code

Edit: if you don't want current but actually power that works too, use

Code:
.StatusSNS.ENERGY.Power

Or

Code:
.StatusSNS.ENERGY.ApparentPower

In the first script instead


Edit2: fixed the crontab code
 
Last edited:

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
Location
Germany
Rating - 0%
0   0   0
Yeah sorry rebooting was a bad term, In my case I have a failure even power cycle did not reset the pin, like I said I have it as a spare board and I can power that board up and its still on...:)
Interesting, that would suggest that the Pin is either fried internally, or that the settings are saved by an EEPROM or FLASH.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Interesting, that would suggest that the Pin is either fried internally, or that the settings are saved by an EEPROM or FLASH.
Yeah there is no eeprom or flash, I believe that pin has failed in a closed manner, @robsworld78 mention that it could be a resistor that the pca9685 uses in the pathway but I've just never taken the time to fully debug it, I had spares and swapped the whole board out its one of these - https://www.tindie.com/products/ranthalion/ml-reef-pi-hat-goby/#specs but it showed me that pca's can fail and in terms of dosing could be a bad thing so I no longer do any dosing with a pca9685 driven doser, thats just me being paranoid but once I saw it happen that was enough for me...:)

I will drive lights with them but thats about it.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
Location
Germany
Rating - 0%
0   0   0
Yeah there is no eeprom or flash, I believe that pin has failed in a closed manner, @robsworld78 mention that it could be a resistor that the pca9685 uses in the pathway but I've just never taken the time to fully debug it, I had spares and swapped the whole board out its one of these - https://www.tindie.com/products/ranthalion/ml-reef-pi-hat-goby/#specs but it showed me that pca's can fail and in terms of dosing could be a bad thing so I no longer do any dosing with a pca9685 driven doser, thats just me being paranoid but once I saw it happen that was enough for me...:)

I will drive lights with them but thats about it.
Same here, I might use PWM to regulate the speed, but the ultimate on/off happens with an I/O Pin of the PI.
 

elysics

Valuable Member
View Badges
Joined
Jan 15, 2020
Messages
1,695
Reaction score
1,607
Rating - 0%
0   0   0
Same here, I might use PWM to regulate the speed, but the ultimate on/off happens with an I/O Pin of the PI.
Yep same, I have the l298n running the motors and it's successors only powered up separate to the PWM input by a gpio
 

eggi55

Community Member
View Badges
Joined
Sep 18, 2022
Messages
63
Reaction score
50
Location
germany
Rating - 0%
0   0   0
Hello @Ranjib
I have a 1-wire relay card there; 8 relays 220V with DS2408 chipset
if you would use that you would have 8 gpios freely available. I also have this card for USB
1666903789265.png
 

eggi55

Community Member
View Badges
Joined
Sep 18, 2022
Messages
63
Reaction score
50
Location
germany
Rating - 0%
0   0   0
Hey sorry that I just come back to you now, you forgot the @ in front of my name for the tag to work.

yes it is possible.

I was going to change the code of the tasmota driver directly, but laziness won out and I used the file driver for that too. Didn't want to confuse you with even more code during setup

Again, this is only a lazy solution, not perfect code.

First, on your pi, install jq:

Code:
sudo apt-get install jq

Then, in your home folder, or somewhere else, create a folder just for the currents to keep everything neat, I chose /home/pi/currents, and then go into that folder:

Code:
mkdir /home/pi/currents
cd /home/pi/currents

Then create a script currscript.sh:

Code:
echo "curl -s http://\$1/cm?cmnd=STATUS+10 | jq '.StatusSNS.ENERGY.Current'>/home/pi/currents/snsCurr\$1">/home/pi/currents/currscript.sh

sudo chmod +x currscript.sh

Then create another script requestCurrs.sh that calls the first one for all the ips of your plugs, my ips are examples:

Code:
echo "/home/pi/currents/currscript.sh 192.168.178.25
/home/pi/currents/currscript.sh 192.168.178.26
/home/pi/currents/currscript.sh 192.168.178.27" >/home/pi/currents/requestCurrs.sh

sudo chmod +x requestCurrs.sh


Then, again, schedule the last script to run regularly, I chose every 20 seconds, but you can do every minute, it takes a couple seconds to run, type "crontab - e"
And add the following line at the end:
Code:
* * * * * /bin/bash -c ' for i in {1..3}; do /home/pi/currents/requestCurrs.sh; sleep 20; done'

Then you should have text files in the currents folder named something like snsCurr192.168.178.25 or whatever the ip address of that particular plug is, that text file contains the current measurement.

Go into reef pi, Configuration->Drivers

And add a file-analog driver per plug and and input the path to the corresponding file like /home/pi/currents/snsCurr192.168.178.25

Then configuration->connectors->analog inputs and add a input per newly created driver, pin 0

Then go into the pH menu and add a pH Probe per newly created connector, check frequency 20 seconds or whatever period you chose, chart minimum 0, chart maximum whatever makes sense for your device, chart unit you can use "A" for Ampere if you want.

Then you can add those "pH probes" to your dashboard and/or do logic with them or whatever you want.

And now my fingers are sore from typing this on a phone, I hope there are no typos in the code

Edit: if you don't want current but actually power that works too, use

Code:
.StatusSNS.ENERGY.Power

Or

Code:
.StatusSNS.ENERGY.ApparentPower

In the first script instead


Edit2: fixed the crontab code
first of all thank you
I haven't forgotten, I didn't know
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Hi all,

Word of warning for all Reef Pi users. I went away for a couple of weeks with a neighbour watching over my tank and feeding every couple of days together with close my close monitoring via Reef Pi. He alerted me that the tank was a little quiet a couple of days ago, I tried to logon to Reef Pi (via VNC) but it didn't work (I didn't think anything of it and I assumed it was something with VNC). Unfortunately I retuned last night to a tank at 35/95 Celsius/Farenheight and full of dead livestock.

I tried logging into the app via the usual home WIFI - but I still couldn't and had to power cycle the whose raspberry pi and which point I was able to login and I received a flurry of emails that the temperature was too high.

It appears the app/raspberry pi crashed with the heater in the 'on' position. For reference, I'm using a full system built by robo-tank (although to be clear this wasn't hardware related - the relay is working perfectly).

This isn't a complaint or moan I am very grateful to Ranjib and all the other developers of this free platform but:

1. I would strongly advise everyone to invest in an audible temperature alarm (can be bought off Amazon for < $10). I have literally lost 000's of dollars by not having this.
2. I would advise against using a non-thermostatic heater (i had a 500W titanium heater)
3. I would be happy to share any files/more information from my Reef Pi instance that would help prevent this happening again
I'm really sorry to hear of your lose, some people here are good at spotting things in the logs, if you can post them maybe the why could be answered.
 
Last edited:

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
FYI I just wanted to throw this out there, YMMV and this is just my .02 but I had an issue long ago with pca9685 that was stuck in the on position on my doser port, in my case I was around when it happened and caught it but even a reboot and the port still runs...I still have that board and its still in the stuck position, no idea why but that was a valuable lesson at least for me, I no longer have my dosers hooked up to PCA/PWM ports since there are just IMHO to many failure modes that they can get stuck on. I have gone to outlet/timer controlled dosers and will not use the PCA9685 for anything but lights, if a light gets stuck on big deal but I will not use them for dosing ports. I have some posts that should what I am using for dosing but by choosing the rpm of the motor and swapping tubing I can dial in the rates that I need, I have nano tanks and doesn't take a lot to throw them off and a stuck doser is bad juju...:)

If anyone wants to know more about how I have things setup, I have extensive timers that force stuff off when it should be off regardless, timer/cron is great at that. :)
I think the pca9685 is a great chip, I don't ever remember hearing of an output going bad except in your case. :( The I2C communications can make it unreliable especially in DIY setups where wires are involved or if some piece of equipment is causing lots of interference such as an LED driver that was mentioned the other day. When a command is sent to the pca9685 it's basically figures crossed it made it in tact so it understands what it should do, if not the pin won't switch until another command is sent. I've played extensively with I2C in the past and quickly learned one shouldn't get carried away with too many devices connected and extra checks in the code is needed to verify things along the way. It is possible to read the state of any output and verify the command sent actually did what it was supposed to, here's a post explaining. If this was implemented chances of a pin not switching would be greatly reduced. Unfortunately I wasn't able to add it to reef-pi.




EDIT: It just hit me, I think the reason your doser port is stuck on is due to the mosfet. You must have something like that being driven by the pca9685 pin. If those are unprotected and get hit with ESD they will get stuck on even if the signal is LOW, I've seen this many times when I was still working out bugs in the controller. I would bet if you removed the mosfet that pin would read 0v.
 
Last edited:

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I think the pca9685 is a great chip, I don't ever remember hearing of an output going bad except in your case. :( The I2C communications can make it unreliable especially in DIY setups where wires are involved or if some piece of equipment is causing lots of interference such as an LED driver that was mentioned the other day. When a command is sent to the pca9685 it's basically figures crossed it made it in tact so it understands what it should do, if not the pin won't switch until another command is sent. I've played extensively with I2C in the past and quickly learned one shouldn't get carried away with too many devices connected and extra checks in the code is needed to verify things along the way. It is possible to read the state of any output and verify the command sent actually did what it was supposed to, here's a post explaining. If this was implemented chances of a pin not switching would be greatly reduced. Unfortunately I wasn't able to add it to reef-pi.




EDIT: It just hit me, I think the reason your doser port is stuck on is due to the mosfet. You must have something like that being driven by the pca9685 pin. If those are unprotected and get hit with ESD they will get stuck on even if the signal is LOW, I've seen this many times when I was still working out bugs in the controller. I would bet if you removed the mosfet that pin would read 0v.
Ok you know me I just know enough to be semi dangerous but which mosfet....https://www.tindie.com/products/ranthalion/ml-reef-pi-hat-goby/#specs and the schematic is hosted there too, I do have spare parts and can replace whatever is on the board but I am intrigued now as to whit component you think went south.

Here is the annotated pic with the pins that i was using, I do not see a mosfet in relation to these pins, looks like the traces do go through a resistor, can't remember which pin it was but it was one of these:

2019-11-03T18_49_19.928Z-goby-front-annotated.jpg
 
Last edited:

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,015
Reaction score
943
Location
Germany
Rating - 0%
0   0   0
Ok you know me I just know enough to be semi dangerous but which mosfet....https://www.tindie.com/products/ranthalion/ml-reef-pi-hat-goby/#specs and the schematic is hosted there too, I do have spare parts and can replace whatever is on the board but I am intrigued now as to whit component you think went south.

Here is the annotated pic with the pins that i was using, I do not see a mosfet in relation to these pins, looks like the traces do go through a resistor, can't remember which pin it was but it was one of these:

2019-11-03T18_49_19.928Z-goby-front-annotated.jpg
Hmm, you are right. There doser pins are fed directly by the PCA9685 through a 220Ohm resistor. Supposedly only by the 3.3V from the PI‘s regulator as well.

Although I think the output of the PCA9685 has to be generated internally from VDD by a MOSFET as well, so the internal MOSFET might be shot.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Hmm, you are right. There doser pins are fed directly by the PCA9685 through a 220Ohm resistor. Supposedly only by the 3.3V from the PI‘s regulator as well.

Although I think the output of the PCA9685 has to be generated internally from VDD by a MOSFET as well, so the internal MOSFET might be shot.
Yeah I actually think the pca9685 is shot, I have spares and I was going to replace the resistor first and then the pca9685 but my guess its the pca9685 thats bad, now how that happened I have no idea...
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Ok you know me I just know enough to be semi dangerous but which mosfet....https://www.tindie.com/products/ranthalion/ml-reef-pi-hat-goby/#specs and the schematic is hosted there too, I do have spare parts and can replace whatever is on the board but I am intrigued now as to whit component you think went south.

Here is the annotated pic with the pins that i was using, I do not see a mosfet in relation to these pins, looks like the traces do go through a resistor, can't remember which pin it was but it was one of these:

2019-11-03T18_49_19.928Z-goby-front-annotated.jpg
Now I'm confused. I would have guessed you were using the outputs in the bottom right corner as those go through the ULN2803A. The doser connector you circled is 3 PWM outputs which can only handle very little current and only put out 3.3v, definitely no motors connected directly would work. Did you have a circuit between the board and the pump? What pump are you using, is it PWM controllable?



EDIT: Just noticed he has a dosing adapter, that also has the ULN2803A which explains things. Have you checked the voltage coming out of the plug you circled, if it's stuck on 3.3v there then yeah either resistor or more likely the pca9685 output.
 
Last edited:

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Now I'm confused. I would have guessed you were using the outputs in the bottom right corner as those go through the ULN2803A. The doser connector you circled is 3 PWM outputs which can only handle very little current and only put out 3.3v, definitely no motors connected directly would work. Did you have a circuit between the board and the pump? What pump are you using, is it PWM controllable?



EDIT: Just noticed he has a dosing adapter, that also has the ULN2803A which explains things. Have you checked the voltage coming out of the plug you circled, if it's stuck on 3.3v there then yeah either resistor or more likely the pca9685 output.
Yup he had a uln2803a module coming off the pwm pins which was also fed 12v. I never measured voltage all I know is if I hook it up its on, always on. Could the resistor failing cause that or is it most likely the pca9685? My other question is what would have caused it to go belly up....
 

geekengineer

Active Member
View Badges
Joined
Feb 10, 2019
Messages
427
Reaction score
528
Location
South Aurora
Rating - 0%
0   0   0
Just realized that pi pico has a wifi variant. I‘ll get it and get started with the driver development. If you can wait, don’t buy esp32, ill get this done,
thank you for calling this out. I don’t know how I missed it , I guess I was just aware of esp32 and didn’t pay attention to pi pico family
I was just curious how was your esp32 driver project going and if you were still going to do a driver for the pi Pico W as well?

Also is it possble or a plan to be able to interface with another rasberry pi via wifi? Sort of in a simmilar manor to the ESP32 or pi pico W. I was wondering if it would just be a matter of coding a slave interface up on the raspberry pi even. I was thinking of a few things I could do remotly in my water mixing area that might need some more CPU horse power to do.
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
Yup he had a uln2803a module coming off the pwm pins which was also fed 12v. I never measured voltage all I know is if I hook it up its on, always on. Could the resistor failing cause that or is it most likely the pca9685? My other question is what would have caused it to go belly up....
Based on that I think it's more likely the ULN2803A is damaged, either by ESD or high kickback voltage. If you check the 3 PWM pins on doser plug with the ground all 3 should read 0v, if so it'll be the ULN. To verify if you turn the pumps on those 3 pins on doser plug should be 3.3v.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Based on that I think it's more likely the ULN2803A is damaged, either by ESD or high kickback voltage. If you check the 3 PWM pins on doser plug with the ground all 3 should read 0v, if so it'll be the ULN. To verify if you turn the pumps on those 3 pins on doser plug should be 3.3v.
Thats a good idea and I can do that, will do that this weekend and see what I find out...thanks for the clarity. :)
 

dadarara

Community Member
View Badges
Joined
Nov 16, 2020
Messages
88
Reaction score
35
Location
Israel
Rating - 0%
0   0   0
last night we had a summer time change. moved 1 hour back. since this morning , the lights are not switching on per the schedule.
if the setting in lights configuration is manual, then its working. so its not electrical issue
the date/time in linux is ok.
rebooted
upgraded to reefpi5.3 from 5.2

what else should I check ?
reinstall from scratch ?
 

Martin Lowry

Community Member
View Badges
Joined
Sep 19, 2017
Messages
60
Reaction score
65
Location
Dover, NH
Rating - 0%
0   0   0
So I need to figure out a automatic feeder for when I need to leave things unattended, I know @robsworld78 has a diagram for wiring up the Ehiem but was wondering if anyone else had done something differently. Havent made up my mind yet but would be nice to be able to time shutting the pumps off etc when feeding, just thought I would ask. :)
If it's of any value, I used Robs EHEIM diag with one that I had laying around and it works great. I have a single feeding instance macro set up and I also set the EHEIM to feed once a day as well just in case anything goes sideways with the RPi macro while I'm away.
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 38 27.3%
  • 100% dry rock + 100% live sand

    Votes: 47 33.8%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 30 21.6%
  • 75% live rock, 25% live sand

    Votes: 14 10.1%
  • 25% live rock, 75% live sand

    Votes: 10 7.2%
Back
Top