Quantcast

Native Python BrewPi controller

HomeBrewTalk.com - Beer, Wine, Mead, & Cider Brewing Discussion Community.

Help Support Homebrew Talk:

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
After note 17 there is a suggestion for how to make fuscus run automatically at boot. There are many ways to do this, and a lot of people have their own preferred way, however, here's the suggestion:
Note that you can run fuscus in a screen session for experimenting, or you can add the command to start fuscus to the fuscus user's crontab in a @reboot entry. An example @reboot entry which discards normal output and logs everything sent to stderr is:
Code:
@reboot sudo //fuscus.py -c //fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &
I just copied and pasted the above @reboot code into the terminal under user fuscus. I got the output from terminal.

@reboot sudo //fuscus.py -c //fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &
[1] 2743

Upon reboot, fuscus does not start automatically. Any thoughts?
 

Thorrak

Supporting Member
HBT Supporter
Joined
Feb 7, 2016
Messages
2,653
Reaction score
1,595
Location
New York, NY
I just copied and pasted the above @reboot code into the terminal under user fuscus. I got the output from terminal.

@reboot sudo //fuscus.py -c //fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &
[1] 2743

Upon reboot, fuscus does not start automatically. Any thoughts?
Did you put this into crontab, or did you just paste it on the command line?
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
Did you put this into crontab, or did you just paste it on the command line?
Just pasted it into the command line...how do I enter it into crontab?

EDIT: Googling how to edit crontab, doing it now.

Edit: No luck yet, I added it to fuscus crontab. When I use crontab -l it lists it there and I verified against any typos still wont start. I think the problem lies whenever I try to run a sudo command it asks me for password.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Just pasted it into the command line...how do I enter it into crontab?

EDIT: Googling how to edit crontab, doing it now.

Edit: No luck yet, I added it to fuscus crontab. When I use crontab -l it lists it there and I verified against any typos still wont start. I think the problem lies whenever I try to run a sudo command it asks me for password.
Did you add the fuscus user to the list of allowed users? It's step number 9 in the notes:
Use sudo visudo to add this line to allow fuscus to run the Python file without needing a password
fuscus ALL = NOPASSWD: /home/fuscus/fuscus/fuscus.py
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
Did you add the fuscus user to the list of allowed users? It's step number 9 in the notes:


That was the first thing i checked.



# Allow members of group sudo to execute any command

%sudo ALL=(ALL:ALL) ALL



# See sudoers(5) for more information on "#include" directives:



#includedir /etc/sudoers.d



pi ALL=(ALL) NOPASSWD: ALL



fuscus ALL = NOPASSWD: /home/fuscus/fuscus/fuscus.py

Still asks for a password.
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
So I changed the entry in sudo visudo to fuscus ALL=(ALL) NOPASSWD: /home/fuscus/fuscus/fuscus.py now I can execute sudo commands without entering a password. But it still will not start at boot...making some progress at least.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
So I changed the entry in sudo visudo to fuscus ALL=(ALL) NOPASSWD: /home/fuscus/fuscus/fuscus.py now I can execute sudo commands without entering a password. But it still will not start at boot...making some progress at least.
I have found the problem. It's a problem with the display of the documentation.

You wrote that you did this:
@reboot sudo //fuscus.py -c //fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

Which is exactly what gitub is displaying when you read the notes file.

However, the raw notes file contains this:
@reboot sudo /<path to fuscus>/fuscus.py -c /<path to fuscus>/fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

As you can see <path to fuscus> is not visible.

I thought it looked odd, but it didn't register with me until now. I was sure I wrote it correctly (which I had) but I didn't realise that the markdown parsing in github would remove some of what I wrote.

So, you need something like this:
@reboot sudo /home/fuscus/fuscus/fuscus.py -c /home/fuscus/fuscus/fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

You can alter it if you put fuscus in a different place of course.

Very sorry for not noticing the subtle error in the notes file. I will fix it for future readers.
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
I have found the problem. It's a problem with the display of the documentation.

You wrote that you did this:
@reboot sudo //fuscus.py -c //fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

Which is exactly what gitub is displaying when you read the notes file.

However, the raw notes file contains this:
@reboot sudo /<path to fuscus>/fuscus.py -c /<path to fuscus>/fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

As you can see <path to fuscus> is not visible.

I thought it looked odd, but it didn't register with me until now. I was sure I wrote it correctly (which I had) but I didn't realise that the markdown parsing in github would remove some of what I wrote.

So, you need something like this:
@reboot sudo /home/fuscus/fuscus/fuscus.py -c /home/fuscus/fuscus/fuscus.ini 1>/dev/null 2>>/home/fuscus/stderr.txt &

You can alter it if you put fuscus in a different place of course.

Very sorry for not noticing the subtle error in the notes file. I will fix it for future readers.
That got it working, thank you.
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
OK, so I am running into another issue. I have brewpi running, however it doesn't update the web browser, no setting changes are applied, and the relays are constantly switching on and off once a second. For example, I started a new brew changed the name, set beer constant to 19.5 apply. Nothing changes on the web browser but the script is still running. This happens on all setting changes, also the relay clicks repeatedly once a second until I stop the script. I have not made any changes to anything sense the last brew besides adding the auto start script for brewpi. See screenshot.

EDIT: I dont know why the picture is being uploaded upside down.

20161224_104333.jpg
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Sorry to hear that. So, it was working, and nothing changed, and now it doesn't?

Based on the screenshot it looks like the brewpi script is not running. That should restart automatically every minute if it's not already running.

In the terminal window I see that fuscus is running properly in the "Waiting to cool" state, which should have both relays off.

The main loop in fuscus runs once a second, but it shouldn't change the relay state if the "Waiting to cool" state does not change. Also, it shouldn't turn both relays on at the same time. Is there anything else running on the Pi?

I have run several brews consecutively by changing settings between "off" and "beer constant" and stopping and starting new brews without seeing a problem like this.

It's tricky to diagnose. Remember, BrewPi has three parts: the web interface, the BrewPi script, and the Arduino. In my design fuscus replaces the Arduino. It seems that in your case the brewpi script is not running. Are there any errors in the brewpi log?

It may be necessary to reboot to restart everything.
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
Well, I've ready tried restarting multiple times and the problem still persists. To me it's acting as if there are multiple brew pi scripts running at the same time, is that possible? I thought there was a self check already there.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Very strange. Yes, I suppose it's possible. Here is the list of processes on my pi (you get this by typing "ps ax" in a terminal):
Code:
 5025 pts/0    R+     0:00 ps ax
 6806 ?        S<     0:00 [kworker/3:1H]
 6811 ?        Ss   133:11 SCREEN
 6812 pts/1    Ss     0:00 /bin/bash
17582 pts/1    S+     0:00 sudo ./fuscus.py
17586 pts/1    Sl+  19645:14 python3 /home/fuscus/fuscus/fuscus.py
17599 ?        Sl   1758:04 python -u /home/brewpi/brewpi.py
32705 ?        S      0:00 /usr/sbin/apache2 -k start
32706 ?        S      0:00 /usr/sbin/apache2 -k start
32707 ?        S      0:00 /usr/sbin/apache2 -k start
32708 ?        S      0:00 /usr/sbin/apache2 -k start
32709 ?        S      0:00 /usr/sbin/apache2 -k start
I omitted some of the low-numbered processes, but as you can see there is only one copy of fuscus.py running (it is started by process 17582, and the actual process is 17586). And there is only one copy of brewpi.py running (process 17599).

So, if you use ps ax you can see a big list of all of your processes and you can see how many copies of fuscus and brewpi are running. There should be only one of each.
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
Well that was the problem, for some reason even after restarts I had three of every fuscus processes running. I'm not sure why it was happening. All I did was copy the auto start command and then delete it then save it. Opened it up again pasted the line back in, saved it, and it solved the issue.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Very strange that it should happen, but I'm happy you found it and fixed it. Thanks for reporting back.
 

mstutter

New Member
Joined
Jan 10, 2017
Messages
1
Reaction score
0
Location
NZ
Hi, just wanted to say I've managed (as a complete hack/newbie) to install and get this running on a Pi B+. I love how easy it is to enable/disable various parts of the system.

I had a bit of trouble getting yaml to work - turns out the command was :
sudo pip3.2 install spidev RPi.GPIO pyyaml

Then I had a fair bit of trouble getting the i2c LCD display working, but that had nothing to do with this. But I've got that working now too!

Nice work!
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Hi, just wanted to say I've managed (as a complete hack/newbie) to install and get this running on a Pi B+. I love how easy it is to enable/disable various parts of the system.

I had a bit of trouble getting yaml to work - turns out the command was :
sudo pip3.2 install spidev RPi.GPIO pyyaml

Then I had a fair bit of trouble getting the i2c LCD display working, but that had nothing to do with this. But I've got that working now too!

Nice work!
Great! Thanks for trying the software, and thanks for persevering with the install. The installation notes are a bit brief, and I wrote them so that I wouldn't forget things. I should probably add some more details.

I didn't know about pip3.2. Thanks for reporting it.

I hope the software works for you. I just turned mine off after 150 days of uptime. I have to move apartments, so everything is shut down and disconnected. I won't be able to do any development for a while, but maybe I won't have to.

Cheers!
 

joebob296

Well-Known Member
Joined
Jul 7, 2014
Messages
360
Reaction score
31
I won't be able to do any development for a while, but maybe I won't have to.

Cheers!
I was reading github and it said the most recent change was a month ago in the docs section. The software is stable and does what it supposed to, what other development of the software did you have in mind?
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
I was reading github and it said the most recent change was a month ago in the docs section. The software is stable and does what it supposed to, what other development of the software did you have in mind?
Yup. It's stable, and I am very happy with it. I have no plans to change anything.

It was just a heads-up that I can't do/won't be doing anything with the software for a while.
 

day_trippr

"Feeling much better now, thanks"
Joined
May 31, 2011
Messages
33,962
Reaction score
15,265
Location
Stow, MA
The "PID" functionality is expressed in firmware/software.
It's not a hardware element - neither Arduino nor R'Pi have hardware PIDs...

Cheers!
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
With the announcement of the Pi Zero W I'm very keen to try one with my software. It'll probably take a while to get one, but it would be ideal for building a wireless Brewpi at probably the lowest price. There's probably even no point using a multi-chamber setup. One Pi, one chamber.
 

SirCasio

Member
Joined
Jan 6, 2017
Messages
12
Reaction score
3
Just picked up a Pi Zero (no W) to try to build one of these...the W would be nice!
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Great! Let me know how you get on.
 

stbernts

Well-Known Member
Joined
May 20, 2016
Messages
254
Reaction score
41
Is this project on hold - finnished?

MultiChamber suppert - would be nice (y)
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Is this project on hold - finnished?

MultiChamber suppert - would be nice (y)
This project is finished, and has been for over a year. During that time I have moved countries and moved house so my hardware is in a box, unused at the moment.

I haven't tested multi-chamber support, but it should work. You can run as many instances of Fuscus as you like. Each one would have a different port, and you would run several instances of BrewPi too. Each of those would be configured to connect to the Fuscus ports.
 

dukedevil0

Well-Known Member
Joined
Jan 22, 2010
Messages
54
Reaction score
10
Location
Chicago
Got a $5 Pi Zero W just for this, and just ordered a good portion of the rest of the components. Looking forward to putting this together. I'll report back and will likely have questions too...
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Great! Thanks for trying it out. Let me know how you get on. I also have a Pi Zero W to try out but I haven't yet. My controller uses a Pi 2.
 

dukedevil0

Well-Known Member
Joined
Jan 22, 2010
Messages
54
Reaction score
10
Location
Chicago
Got the Pi Zero W set up, fuscus and brewpi software installed without much issue - instructions were very helpful...gotta get the hardware all connected so I can configure and get everything up and running!
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
That's great! I hope it all works when you are done building it, and pics, please, or it didn't happen. :)
 

dukedevil0

Well-Known Member
Joined
Jan 22, 2010
Messages
54
Reaction score
10
Location
Chicago
Making progress. For lack of a better word, I've done it kind of ghetto. Soldered some wires together so I wouldn't have to crimp my own connectors on or anything, or use terminals to junction. I'd like to think I'll go back and clean it up, to do things a little more professional, but who am I kidding? Once it works, probably slim chances I'll want to mess with it!

Basically doing the minimal implementation. Don't see the need for me to use the LCD, rotary encoder, buzzer, door switch, or even the 3rd temp probe for the Room Temperature. Beer and Fridge temp is all I really care about.

I saw in an earlier post on your blog about shorting the LEDs on the relay, is that not needed? Or how do I know? It's not listed on the current github wiring schematic. I'm using the common SainSmart relay.

Time to start hooking up the mains and find a box.

 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Looking good. Very minimal setup. Yes, it's fine to omit all those parts and just interact via the web browser.

I had one of those relay boards that would not actuate, which I believed to be caused by too much voltage drop across the indicator LED, so I shorted it. Other boards I bought worked fine, so I think it was a one-off and I think I removed it from the schematic.

Good luck.
 

uSlackr

Gaughan Brewing... gone brewing'
HBT Supporter
Joined
Jul 6, 2013
Messages
104
Reaction score
32
I have BrewPi, fuscus and BrewPi-brewometer installed. took some work, but I a finally logging data from the Tilt. BrewPi isn't graphng the data and the data files aren't looking quite right:

Feb 05 2018 20:55:51;null;null;null;NaN;null;null;1;null;null;null72.0;1.023;
Feb 05 2018 20:56:55;null;null;null;NaN;null;null;1;null;null;null72.0;1.023;
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
I have BrewPi, fuscus and BrewPi-brewometer installed. took some work, but I a finally logging data from the Tilt. BrewPi isn't graphng the data and the data files aren't looking quite right:

Feb 05 2018 20:55:51;null;null;null;NaN;null;null;1;null;null;null72.0;1.023;
Feb 05 2018 20:56:55;null;null;null;NaN;null;null;1;null;null;null72.0;1.023;
Um...

How have you integrated the Tilt? Fuscus does not support it, and the BrewPi web interface does not support it. I know there has been a lot of work in various places to integrate the Tilt, but I haven't been following them.

Uncoincidentally, I have literally just put a new brew into my Fuscus-controlled fridge, after about a year of no activity.
 

uSlackr

Gaughan Brewing... gone brewing'
HBT Supporter
Joined
Jul 6, 2013
Messages
104
Reaction score
32
I'm only trying to log data at this point, not control temps. Since I'm not running Arduino at his point, I loaded fuscus so the BrewPi script would run.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Ok, well the Arduino prints its temperatures out in response to a 't' command, as does Fuscus (in PiLink.py).

Do you have any temperature sensors attached to the Pi? If not then you will get the Python 'None' value for all sensors, which will translate to Java's 'null'.

I am guessing that the number '1' in the seventh field is the 'state' variable, which is maintained by tempControl.py. A value of 1 represents the 'Off' state, which is probably correct.

Whatever is splicing in the Tilt data is also missing a comma after the tenth field (before 72.0).
 

castreixanas

Active Member
Joined
Sep 14, 2014
Messages
33
Reaction score
2
Hello.

I'm using fuscus, but I have a problem: I do not have a refrigerator, only have a heater.
With this config fuscus-brewpi is not accurate, having variations over half a degree of temperature (1 degree or more in total).

In brewpi standard, this is solved removing the frigde device, and leaving only the heating device:

https://community.brewpi.com/t/pid-tuning-for-none-fridge-setup/216


But in fuscus I could not configure it. If I delete the fuscus.ini probe, it gives a script execution error. If I delete the gpio from the fridge in the same file, the script also fails. I have tried several configurations but I can not configure it.

Is there a way to configure it, or could this error be solved?

Thank you.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Hi there,

Thanks for your message. I did not expect a configuration without a heater or a cooler, so if the relay pin is not specified in the ini file then you will get an error.

I briefly looked at the code, and it seems that it will skip the cooling state if the 'cooler' device does not exist. However, there is no way to start the code without a 'cooler' device.

It may be possible to work around this by editing the source.

In constants.py edit line 221 from this:

cooler = relay.relay(relay_COLD, invert=invert_cold)

To this:

cooler = None

You must specify a pin for the cold relay, but it will be ignored.

Then comment out line 454 in tempControl.py

From this:
self.cooler.set_output(cooling)

To this:

#self.cooler.set_output(cooling)

This will prevent an error occurring here.

Finally, comments out line 141 in fuscus.py:

cooler.off

To this

#cooler.off

I think that is all that is necessary, but of course I have never tried it. I should make it possible to configure Fuscus with no cooler or no heater. Maybe I'll do that later, but I don't have time now. Sorry.
 

castreixanas

Active Member
Joined
Sep 14, 2014
Messages
33
Reaction score
2
Hi there,

Thanks for your message. I did not expect a configuration without a heater or a cooler, so if the relay pin is not specified in the ini file then you will get an error.

I briefly looked at the code, and it seems that it will skip the cooling state if the 'cooler' device does not exist. However, there is no way to start the code without a 'cooler' device.

It may be possible to work around this by editing the source.

In constants.py edit line 221 from this:

cooler = relay.relay(relay_COLD, invert=invert_cold)

To this:

cooler = None

You must specify a pin for the cold relay, but it will be ignored.

Then comment out line 454 in tempControl.py

From this:
self.cooler.set_output(cooling)

To this:

#self.cooler.set_output(cooling)

This will prevent an error occurring here.

Finally, comments out line 141 in fuscus.py:

cooler.off

To this

#cooler.off

I think that is all that is necessary, but of course I have never tried it. I should make it possible to configure Fuscus with no cooler or no heater. Maybe I'll do that later, but I don't have time now. Sorry.

Hi Ame.

I have made the changes you have recommended, and the cool option is no longer activated. It seems that everything it is OK.

Thank you for your correction.
 
OP
A

ame

Well-Known Member
Joined
Oct 25, 2015
Messages
378
Reaction score
60
Great! Thanks for reporting back. I have no immediate plans to implement this feature in the main codebase, although I probably should. At least I now know what to do, and that it works.
 
Top