Brewometer integration

Yes
You need to install the legacy branch of brewpi. The current version for the spark does not work with the Arduino builds.
Follow the instruction to run updater. Py --ask. When prompted choose legacy.

sudo ~/brewpi-tools/updater.py --ask

Hi @andylytical,

If the other colours aren’t dissappearing, then this indicates that the modifications to the js/beer-chart.js file potentially haven’t been made (or the browser is using a cached version).

Can you check that you’ve updated this file to be the same as the one from git?

Hi @frizzo,

Unfortunately the Brewpi extension to the data structure for the current version of BrewPi means that it gets significantly slower after a few days of logging. Slowing down the logging frequency can help with this.

I believe than when @Elco releases the newer version, this should allow more efficient rendering of the graph even with additional data points.

1 Like

yea… thanks for taking the time to be helpful with your response about this.
been on this merry-go-round for a while now. just whining while waiting for my beer.:cry:

@Ron_K @sbowler Battery monitoring for the Tilt? Where, how? That would be nice! missed that…

Hi @sbowler, My installer script checks all copied files with a diff

pi@brewpi:~ $ sudo brewpi-scripts/tilt_install.sh -v
... ... (skip a few lines)
Get brewometer code... Cloning into '/tmp/tilt-install/brewpi-brewometer'...
... ...
Installing tilt web files... sending incremental file list
... ...
Files /tmp/tilt-install/brewpi-brewometer/brewpi-web/js/beer-chart.js and /var/www/html/js/beer-chart.js are identical

and checking by hand:

pi@brewpi:~ $ ls -l /tmp/tilt-install/brewpi-brewometer/brewpi-web/js/beer-chart.js /var/www/html/js/beer-chart.js
-rwxr-xr-x 1 www-data www-data 26035 Jan 24 08:52 /tmp/tilt-install/brewpi-brewometer/brewpi-web/js/beer-chart.js
-rw-rwxr-- 1 www-data www-data 26035 Jan 24 08:52 /var/www/html/js/beer-chart.js

I even had the idea last night that maybe it wasn’t working because I hadn’t reattached the “beerTemp” temp probe, but alas, one reboot and two new brew logs later, still no luck.

@sbowler YAY! Got it working! It was (potentially) the dumbest thing … I had to FORCE RELOAD (Ctl-F5) the brewpi page in Chrome browser. Thanks for your comments, I don’t think I ever would have found that. So simple yet so evasive.

Thanks @Ron_K, but I run on the legacy platform already, but I did an update today anyway and it looks like this. (after that, I also got the same message)

*** Updating BrewPi web interface repository ***
You are on branch legacy

Available branches on the remote ‘origin’ for /var/www/html:
[0] beta
[1] develop
[2] feature/chart-export
[3] feature/notifications
[4] legacy
[5] master
[6] Skip updating this repository
Enter the number of the branch you wish to update [legacy]:4
The latest commit in /var/www/html is 398f1b50c71904f69e836b26299dd178d9d4515a on Mon, 11 Jan 2016 14:16:11
The latest commit on origin/legacy is 398f1b50c71904f69e836b26299dd178d9d4515a on Mon, 11 Jan 2016 14:16:11
Your local version of /var/www/html is up to date!

No changes were made, skipping runAfterUpdate.sh.
If you encounter problems, you can start it manually with:
sudo /home/brewpi/utils/runAfterUpdate.sh

The update script can automatically check your controller firmware version and program it with the latest release on GitHub, would you like to do this now? [Y/n]:y
_ Stopping any running instances of BrewPi to check/update controller…_
_ _
Checking current firmware version…
_ Jan 24 2017 17:08:50 Opening serial port_
_ Found BrewPi v0.2.10 build unknown, running on an Arduino Uno with a revC shield on port /dev/ttyACM0_

_ Current firmware version on controller: 0.2.10_
_ _
Checking GitHub for available release…

Available releases:

[0] 0.2.10
[1] 0.2.9
[2] 0.2.8
[3] Cancel firmware update

Should I clone his (supercow) repository, or just as descripe in his Readme, copy the files in all folder.

Hi @frizzo,

It looks like it’s possible, but without a different data logging mechanism, that will just make the page load times slower. @Raptor has done this using a database. I could implement something similar but I’d prefer to wait for the overall BrewPi UI changes which will use a database to store logging data instead of a flat file.

You can get the battery level by the gatttool command (installed from bluez-tools package):

The following command will give you the battery level in hex.
sudo gatttool -b <brewometer address> --char-read -a 0x0048 | cut -d ' ' -f 3

@Ron_K @frizzo @sbowler Here is my getTiltBatteryStatus script for getting the Tilt battery level every 12 hours:

Note however that each time gatttool is used, this causes a ble subsystem issue and you will have to change the brewpi script so that it restarts the tilt integration properly. I had to make quite a few changes for this. Unfortunately due to starting a new job and doign a lot of travelling means I don’t currently have time to refactor all my code away from the other stuff I am doing in order to build a github release for this.


#BrewpiTilt - getTiltBatteryStatus - gets the current battery status
import subprocess
import shlex
import re
import sqlite3
#needs the following cron file entry in: /etc/cron.d/tiltBatteryStatus to run every 12 hours.
#0 */12 * * * root python /home/brewpi/BrewpiTilt/getTiltBatteryStatus.py >/dev/null 2>&1
#

sqlite_file = '/home/brewpi/BrewpiTilt/BrewpiTilt.db'
hwaddr = '88:C2:55:AC:2F:42'

def call_gatttool():
    hexcmd = '0x48'
    cmd = 'gatttool -b %s --char-read -a %s' % (hwaddr,hexcmd)
    res = subprocess.check_output(shlex.split(cmd))

    if not res.startswith('Characteristic value/descriptor:'):
        return None
    res = re.match('Characteristic value/descriptor: (.*)', res).groups()[0]
    byte_values = res # .split()
    return int(byte_values, 16) #convert to int value for battery percent

def log_to_DB(battery_level):
    try:
    
        #set up the db connection
        conn = sqlite3.connect(sqlite_file)
        cur = conn.cursor()
        #update the battery level in the brewdevice table
        sqlstr = 'UPDATE brewdevice set BatteryLevel = ?,BatteryLastChecked = CURRENT_TIMESTAMP WHERE Address = ?'
        params = (battery_level,hwaddr)
        cur.execute(sqlstr, params)
        #close the connection
        conn.commit()
        #print "Number of rows updated: %d" % cur.rowcount
        conn.close()
    except Exception, e:
        print("ERROR: BrewpiTilt - getTiltBatteryStatus - log_to_DB function - error is - " + e.message)

    return;
    
result = call_gatttool()

print result

if not result == None :
    log_to_DB(result)
2 Likes

Thank you for sharing. I’m sure someone on this thread will be able to find a solution for the ble subsytem issue.

What I suggest you do first is check the logs in brewpi just to make sure your running on legacy correctly. because the message you pasted from the previous log indicated you were not. Once you know that brewpi is running correctly then I would clone the repo from supercow. check again before making the permission changes that they say to do in the readme. When I made the permission changes as directed in the readme I broke my brewpi. I had to use Elcos fix permissions script to get it working again. Work this in phases and check after each change that it works or not. ITs easy to do too much at one time then when it doesn’t work you really don’t know where to look.

Thanks again @Ron_K.

I’m pretty sure I’m running legacy, the flash firmware on Genuino are 0.2.10, and says that is in legacy branch when run the updatescript.
Anyway, I took another SD card, installed a fresh Debian, install Brewpi recording to the docs, automatic script, flash the Genuino card automatic and copy that files like readme says in supercow repository. Run the FixPermision script…

I did get the same exit error, it says I’m not on legacy.

So I did a test, I comment the IF…Exit… chapter in the brewpi.py script, and woila… it then the script start, and I got the logging… strange?

So, I remove this from Brewpi.py , and then the script run and Brewometer logg… to me it seems that the script are made for not Arduino?

if hwVersion.family == ‘Arduino’:
_ exit("\n ERROR: the newest version of BrewPi is not compatible with Arduino. \n" +_
_ “You can use our legacy branch with your Arduino, in which we only include the backwards compatible changes. \n” +_
“To change to the legacy branch, run: sudo ~/brewpi-tools/updater.py --ask , and choose the legacy branch.”)

Where can I see, if I not running the Legacy ? Does give any meaning ?

Hi guys,

I haven’t seen it addressed since the middle of last year, so I don’t think anything has changed.

But I’m going to ask anyway - can the temp returned from the Tilt be used to control fermenters? Seems it would require integration with the Arduino code that has been ‘frozen’.

Thanks,
Paul

I would love to know how to change the logging intervals of the tilt. It seems to slow up displaying the graph after a week of logging.
Cheers stew

@Tom_StewarT, If I’m not mistaken you do this under the Maintenance Panel, Settings.

I agree with @rbpalmer, chnage the BrewPi logging to a lower frequency. I have set mine to every 2 minutes, but have only been logging for two days, so I will have to wait a bit to see if it has a positive impact.
Stefan

Woo Hoo, it is working. Now to get my GRAVITY.blue and TEMPERATURE.blue set up correctly (GRAVITY was adjusted just before noon yesterday, accounts for the jump). Interesting to see the temporary drop last night, I suspect it is the results of the 1098 yeast getting very active and Co2 or krausen affecting the Tilt.

Thanks again @sbowler for your changes to Elco’s software

Stefan

Simon, I really have to thank you for your changes to Elco’s software. I ferment in corny kegs, so cannot watch my wort swirling as the yeast bugs do their thing. However, watching the Tilt SG drop is almost as good, look at the drop of 20 points in less than 24 hours, That WY1098 is going gangbusters!

Thanks again
Stefan

:slight_smile: Glad it’s working well for you. My changes are really s scratch on the surface of all the BrewPi work that Elco’s done. It’s an awesome bit of kit.

@prmurphy63026 - It’s still not possible to control the fermentation temp using the Tilt’s thermometer as input.

@Raptor - I’ve got a change coming that will automatically restart the Tilt connection without needing to restart the script. I hit a hurdle when I went to test and found that my BrewPi SD card had corrupted itself over Christmas. Almost there now though.