Brewometer integration

@sbowler Thanks for the work you’ve done on this. I managed to get it up and running. now I have a few questions that I can’t find answers for in the above discussion.
Your mods seem to have disabled the charts ability to switch back and forth from C to F temp format when changed in advanced options. I can see the values change but the tags on the graph, and in the set temperature mode windows remain constant,
I did find an entry in beer-chart.js that will change it but it still remains static. ( ylabel: ‘Temperature (F)’)
as you can see I changed it to F for my chart. How can we make it follow the advanced settings instead?

My second question is why doesn’t my Tilt temp convert to F? Its reading 25 deg which is still C How can I make it read correctly?

The downward spikes in the graph are where I tried changing values in advanced settings.

Hi @Ron_K,

Are you sure you’re using the latest set of files from my git repository (https://github.com/sibowler/brewpi-brewometer/)

Reason I ask, is that the beer-chart.js was changed a while ago to dynamically show (F) or © depending on what you’re using.

To record temperature values from the Tilt in F, you need to change the /home/brewpi/brewometer/settings.ini file and set the FahrenheitTemperatures: False line to read FahrenheitTemperatures: True. Then you’ll need to restart the script to reload the values from that file.

Since I’m running an arduino I am on the legacy branch. So I used this clone. https://github.com/jlvnyc/brewpi-brewometer.
I assume it does not have your latest files then.

In /home/brewpi/brewometer there is no settings.ini only GRAVITY.colour and TEMPERATURE.colour So I added this by copying yours from the repository.
Also I installed your beer-chart.js to replace mine, any other files needed?

There will be other changes, but I haven’t looked at the legacy branch, so I’m not sure. You can do a file by file comparison to work out what changed, but it might be easier to get the maintainer of the legacy repository to rebaseline. Potentially try asking @jvgolf?

It seems to be doing everything I would want at the moment. Still doesn’t convert the brewometer temp to F but I don’t see a need for that sensor anyway.
Thanks for your help.

@jvgolf It seems there are updates that need to be made for the legacy branch. could you rebaseline your repository?

@Ron_K My repository is https://github.com/jlvnyc/brewpi-brewometer but I haven’t updated for any recent changes because I haven’t touched my brewpi code in months. Were there major changes?

With respect to the temperature translation, I couldn’t figure out why it wasn’t working for me (it seemed to be ignoring the conversion flag) so I just set it to F because I never use C. I believe* I changed in the brewometer.py file the following:

def convertFtoC(self, temperatureF):
    return (int(temperatureF) - 32) * 5.0 / 9

to:

def convertFtoC(self, temperatureF):
    return int(temperatureF)

*I’m not 100% sure if this is the only thing I changed.

I don’t know what all changed. @sbowler indicated that he has made a few changes. For example the settings.ini file and the beer-chart.js was changed. Is there a way to compare?

Working great! Thanks, I’m running an arduino and rsp 3. I am on the legacy branch https://github.com/jlvnyc/brewpi-brewometer2.

Encounter any issues from following the readme instructions? I started the process, but haven’t completed.

I had some issues with the https://github.com/sibowler/brewpi-brewometer.git. But the legacy branch https://github.com/jlvnyc/brewpi-brewometer2 worked for me. I just followed the readme…

Hi All,

I’ve just updated the modification to:

  • Update brewpi.py to be compatible with the 0.4.4 firmware.
  • Update references to Brewometer -> Tilt Hydrometer.

When upgrading the source, need to do the following steps:

  1. Rename /home/brewpi/brewometer directory to /home/brewpi/tiltHydrometer
  2. Ensure the existing Brewometer.py file has been deleted (note the code will still work if this file remains - this is just a cleanup step). The Brewometer.py library has essentially been renamed to TiltHydrometer.py.

Very good integration this. Thanks for Sbowler for his code and of course Elco for the excellent brewpi base.

This is my hacked attempt at doing some real time monitoring. This pic was taken exactly 48 hours after pitching. The Tilt is accurate to .1 points (I took a hydro sample and it was 1.018 compared to the Tilt’s 1.017). I can live with that accuracy! :slight_smile:

The battery level is taken every 12 hours via Gatttool and stored in my monitoring sqlite database along with the Tilt gravity samples.

4 Likes

I like the dials, or even just the extra information in the Brewpi header. Care to share with us how to arrange that, please?

Stefan

sure - I would post my code to github but it is part of a bigger process within my home virtual environment that includes custom monitoring etc based on a sqlite database. I need to spend some time in the new year seeing if I can refactor this into a standard facility as such. Need to think about this as the code base is changing soon via Elco and I am on Arduino.

But in outline:

  1. I created a sqlite database holding a brew/brewlog/brew_device table structure. The brew_device table contains the Tilt address and current battery level reading. This is used for other purposes too - hence the database approach.

  2. I added a new subroutine to the brewpi.py python script that inserts the current tilt SG and temp readings to the new brewlog table every x mins along with the standard brewpi logging data.

  3. I added a new python script that is run via cron twice a day and this runs gatttool to grab the battery status and updates the device table with this.

  4. I wrote a new php page called get_brew_status.php to just return a JSON array of the brew data from the sqlite database upon each call.

  5. I use canvas-gauges javascript library to display the brewtemp/sg/calculated ABV/battery level.

  6. each page or graph refresh updates the canvas gauges and the additional header values via a new javascript function which makes a ajax call to the new php - function getBeerStatus is at the bottom…

  7. Alterations to beer-panel.php for the new header fields as well as making the page public facing without exposing unauthorised admin functions.

function getBeerStatus(){

$.ajax({
    type: "POST",
    dataType:"json",
    cache: false,
    url: 'get_brew_status.php',
    success: function(brewStatusJson){
	
		var beerTemp=brewStatusJson[0].BeerTemp;
		
		var tiltSG=brewStatusJson[0].TiltSG;
		
		var startSG = brewStatusJson[0].StartSG;

		var currentAbv = brewStatusJson[0].CurrentAbv;
		
		var currentBattery = brewStatusJson[0].BatteryLevel;
		
		var tempGaugeElement = document.getElementById('beerTempGauge');
		
		tempGaugeElement.setAttribute('data-value', beerTemp);
		tempGaugeElement.setAttribute('data-animation', "true");
		
		var sgGaugeElement = document.getElementById('beerSgGauge');
		sgGaugeElement.setAttribute('data-value', tiltSG);
		
		var abvGaugeElement = document.getElementById('abvGauge');
		abvGaugeElement.setAttribute('data-value', currentAbv);

		var batteryGaugeElement = document.getElementById('batteryGauge');
		batteryGaugeElement.setAttribute('data-value', currentBattery);

					
		var startSgLineAttr = document.getElementById('abv-line-2');
		var currSgLineAttr = document.getElementById('abv-line-3');
		var currAbvLineAttr = document.getElementById('abv-line-4');
		
		//update the panel display:
		startSgLineAttr.innerHTML = "Starting Gravity: "+startSG;
		currSgLineAttr.innerHTML = "Current Gravity: "+tiltSG;
		currAbvLineAttr.innerHTML = "Current Alcohol % : "+currentAbv;
		
	}
 });  //end ajax post.

}

//json object returned by new php page looks like this:

[{“BrewID”:“2”,“BeerName”:“Meteor Dec2016”,“BeerTemp”:“17.94”,“BeerSet”:“18”,“FridgeTemp”:“18.32”,“FridgeSet”:“18.76”,“TiltSG”:“1.013”,“TiltTemp”:“18.33”,“StartSG”:“1.042”,“RoomTemp”:“3.19”,“CurrentAbv”:“3.81”,“StartDate”:“2016-12-17 13:23:29”,“EndDate”:null,“BatteryLevel”:“60”,“BatteryLastChecked”:“2016-12-20 12:00:03”}]

thanks for the comprehensive explanation, but to be honest, for my meager capabilities, TMI. I am nowhere near experienced enough to do 1/2 of what you suggested. I am just glad that can download from github and install the software or the updates. Maybe in the future, I can take some time to learn more or teach myself.

But thanks anyway for showing how, I am sure there are others who can use this immediately.

Stefan

I would also be interested in your process for the dial display and battery gauge. But wouldn’t have a clue how to do what you described.

Nappy New Year Mr. Bowler,
Apologize that I have to inconvenience you during the holidays but I was trying to install your Tilt integration, finally, after receiving my Tilt this Christmas. I am really looking forward to getting this working, your changes to the standard BrewPi look really good. However, I am getting an error in one of the early steps in the read.me file in Github.

Then you need to enable python to query bluetooth without being root.

sudo setcap cap_net_raw+eip $(eval readlink -f which python)

Failed to set capabilities on file ‘/home/pi/whic’ (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not as regular (non-symlink) file

I am a total Linux noob, so have no idea where to start on correcting this. Any help that you (or any other forum members) can provide would be much appreciated.

Stefan

Stupid me, I am obviously a noob. I used ordinary ticks instead of back ticks. So now the setcap worked. But how and where do I load the files in @sbowler’s github? :confused:

apt-get install is not right, do I use git clone or another kind of git command?

@sbowler Maybe something to add to your read me?
:wink:

So I had my BrewPi all set up, added in the extra “security” features (to allow for Public/Private viewing) as well as hosting 2 web servers on my RaspPi. Below should be the steps to get you back up and brewing with the Tilt Hydrometer working.

  1. cd /home/brewpi

  2. sudo git clone https://github.com/sibowler/brewpi-brewometer.git

  3. sudo apt-get install bluez python-bluez python-scipy python-numpy libcap2-bin

  4. sudo setcap cap_net_raw+eip $(eval readlink -f ``which python)`

  5. python /brewpi-brewometer/tiltHydrometer-test/TiltHydrometerTest.py

  6. cd brewpi-brewometer/brewpi-web/

  7. cp index.php admin.php (this copy/pastes the index pages as the new admin page, due to Public/Admin setup; the goal is to replace the admin.php page [current] with this new page)

  8. rm -r index.php (this deletes the index.php page from the Tilt additional code, so it won’t overwrite the current index.php page)

  9. sudo cp -r * /var/www/html/BrewPi/ (This is because I am running 2 web servers and this is where BrewPi is at)

  10. sudo chown -R www-data:www-data /var/www/html/BrewPi/

  11. cd /home/brewpi/brewpi-brewometer/brewpi-script/

  12. sudo cp -r * /home/brewpi/

  13. sudo chown -R brewpi:brewpi /home/brewpi

  14. sudo shutdown -r