Brewometer integration

Hi all, I have just recently purchased the new BrewPi and currently running the latest Firmware and software on Raspbian Jessie.
Is it possible to integrate the Tilt hydrometer ?

So Iā€™m having a web interface issue with my integrated Tiltmeter version. Anyone else? Iā€™ve been running the Tiltmeter with my BrewPi (Arduino) successfully since July. Iā€™ve been setting my data logging to 10 minutes (following the earlier thread with @sbowler and @NottingHill). As long as the brew session is less than about 2 weeks, Iā€™ve not had any problems until about 3 brew ago (Iā€™ve probably done 15 brews since July, total). It started out that the web interface would time-out after a couple of days. Could not gain access to the BrewPi via a number devices and web software programs nor could I get in via PuTTY. On this current brew session, which I started about 12 hours ago, the Web Interface is non-responsive. My only option is to re-cycle power (unplug), which we all know is not a good thing. However, I do get access back to the BrewPi. I

Again, wondering if anyone is having the same issue? Wondering if this is tied to the Tiltmeter logging (it is a new session)? Or is this corrupted software somewhere?

Is there anyway at all to get this data into the arduino to actually use for the temp control? I have a fermentasarus and it doesnā€™t have a thermowell so starting to look at wireless ones.

Can the pi for example mimic the one wire protocol and just send the signal to the arduino via a wire that appears like a thermometer? Is there a simpler way?

Edit: Iā€™ve just found this:

Which extends the pi zero (which my brewpi runs on) to be able to communcate over a 1 wire bus. So, in theory this could be used to send the temp data to the arduino or spark?

Tutorial here: https://www.packtpub.com/books/content/raspberry-pi-and-1-wire

Thanks
Si

After a few months away from brewing Iā€™m ready to start again so I did a clean install on a RPi3. I have the docker installation running and can see the Web UI. All looks good so far.

I want to integrate the Tilt into the setup so I went to git and began the install.

This is the first sign of trouble:
$ sudo apt-get install bluez python-bluez python-scipy python-numpy libcap2-bin
Reading package listsā€¦ Done
Building dependency tree
Reading state informationā€¦ Done
E: Unable to locate package python-bluez
E: Unable to locate package python-scipy
E: Unable to locate package python-numpy

Which leads to this:
$ python TiltHydrometerTest.py
Traceback (most recent call last):
File ā€œTiltHydrometerTest.pyā€, line 2, in
import TiltHydrometer
File ā€œ/home/pirate/brewpi-brewometer/tiltHydrometer-test/TiltHydrometer.pyā€, line 12, in
import blescan
File ā€œ/home/pirate/brewpi-brewometer/tiltHydrometer-test/blescan.pyā€, line 21, in
import bluetooth._bluetooth as bluez

I have checked to see if the Tilt is recognized:
$ sudo hcitool lescan
LE Scan ā€¦
88:C2:55:AC:26:BF (unknown)
88:C2:55:AC:26:BF Tilt
30:8C:FB:29:3E:EE (unknown)
05:5B:D9:E4:D7:1A (unknown)
C8:69:CD:2C:A1:74 (unknown)
C8:69:CD:2C:A1:74 (unknown)
88:C2:55:AC:31:87 (unknown)
88:C2:55:AC:31:87 Tilt

And now Iā€™m at a dead end.
Has this already been addressed?

did you do an apt-get update & apt-get dist-upgrade before your install?

I did the fresh install about a month ago.

At the time I did the standard docker pull to build the container.

Doing and upgrade and update now.

It might not fix things but you should always do an update & upgrade before installing other software on linux. At the very least the update.

Update will update the package list on your computer, dist-upgrade will upgrade the installed packages & dependencies. If you donā€™t do the update, youā€™ll be working off an out of date package list which might give you the problems above when apt canā€™t find the packages in the out of date location. dist-upgrade will bring in security/bug fixes. It will also give you the most up to date version which can help if packages youā€™re newly installing donā€™t specify dependencies properly. Unless those badly written packages want an old version of a dependency, in which case itā€™ll make things worse :stuck_out_tongue:

With the implementation of the container itā€™s a bit ambiguous as to what to update first.
There is the pirate account on the actual pi and then the brewpi container.

This also leads to confusion as to where the installation should occur.

After a bit of doing and redoing I finally made it through all the instructions.

The UI shows all the possible colors of the Tilt but doesnā€™t show any data for the 2 I have.
This is the log just after start up?
Jan 26 2018 11:24:40 Fresh start! Log files erased.
Jan 26 2018 11:25:15 Notification: Script started for beer 'Tilt Testā€™
Jan 26 2018 11:25:15 Connecting to controllerā€¦
Jan 26 2018 11:25:15 Opening serial port
Jan 26 2018 11:25:15 Checking software version on controllerā€¦
Jan 26 2018 11:25:15 Found BrewPi v0.5.2 build 0.5.2-0-g72e633171, running on a Particle Photon with a V2 shield on port /dev/ttyACM0

Unhandled exception in thread started by >
Traceback (most recent call last):
File ā€œ/home/brewpi/TiltHydrometer.pyā€, line 373, in scan
blescan.hci_le_set_scan_parameters(sock)
File ā€œ/home/brewpi/blescan.pyā€, line 107, in hci_le_set_scan_parameters
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
_bluetooth.error: (9, ā€˜Bad file descriptorā€™)

Iā€™m going to start over with a fresh install and then decide if I want to pursue the integration again. Iā€™m zero for 2 on installations so far and think this is actually taking away from my brew time.

The updates and modifications should be performed within the container. Iā€™ve not updated the instructions for a container install as Iā€™m not running my pi that way. It seems that you need to make sure you run the container in privileged network mode to get access to the bluetooth device.

If you run the test script, this needs to also be run inside the container to confirm the setup will work.

Unfortunately, Not with the current version of Brewpi. The temperature control is implemented in the Spark, not in the Raspberry pi. I believe this was done for reliability reasons.

The accuracy of the one wire temperature sensors is a lot greater than th etemperature readings from the Tilt. Iā€™ve also switched to a Fermentasaurus and have put a thermowell through the pressure lid.

Thatā€™s my point. The pi has the temp data and could send it to the spark/arduino via the one wire protocol. The spark / arduino just sees this as a normal temp sensor with correct one wire ID and does its thing. The pi can read / write data to a one wire bus so I am sure this is possible and it can mimic a temp sensor. And Iā€™m sure the brewometer in the beer is more accurate than a one wire strapped to the side of it.

Anyway, besides all this, can you ferment under pressure with the thermowell in? Coz if you can this is a moot point I guess :slight_smile:

Fair enough then. I indeed missed that point. It should be possible, just need to do the coding.

You can (and I have) ferment under pressure with the thermowell. Before i did it, I spoke with the Fermentasaurus manufacturer and they said it should be possible. Iā€™ve drilled a hole in the lid, and have the thermowell going through a grommet. Iā€™ve pressure tested to 70 PSI and after about 10 mins, the lid gasket failed (due to incorrect seating) with no leakage around the thermowell. :slight_smile:

Interesting. So did you drill the hole and bond the thermowell to the lid? If not how did you make a good seal. I doubt Iā€™ll ever need more than 20psi to be honest. Though that said if the lid fails anywhere in the future it will surely be where I drill it. And they arenā€™t cheap!

Anyway, besides all this I think Iā€™m just trying to find an excuse to buy a tilt hydrometer when I go the states in march!

I might buy one of them one wire boards for my pi zero, play about and report back if I can mimic a thermometer. Almost certain itā€™s possible as one wire is digital so itā€™s just a case of working out what to send. And an actual one wire thermometer will help with that.

So to satisfy my curiosity I did a clean install.

I followed the directions in the wiki to create the boot disk (the wifi setup and machine name are now in /boot/user-data).
I did apt-get upgrade and updates.
I created the brewpi container using the --privilege option.
I create the Portainer container.

I entered the console on the container and did apt-get upgrade and updates.
I cloned the git directory: root@f9648c4b9a69:/home/brewpi# git clone https://github.com/sibowler/brewpi-brewometer.git
I added the required libraries: root@f9648c4b9a69:/home/brewpi# sudo apt-get install bluez python-bluez python-scipy python-numpy libcap2-bin
I executed the permissions update: root@f9648c4b9a69:/home/brewpi# sudo setcap cap_net_raw+eip $(eval readlink -f which python)
Up to this point I had no hard errors, only a couple of:
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.

I attempted the test script:
root@f9648c4b9a69:/home/brewpi/brewpi-brewometer/tiltHydrometer-test# python TiltHydrometerTest.py
Scanning - 20 Secs (Control+C to exit early)
Red: None
Green: None
Black: None
Purple: None
Orange: None
Blue: None
Yellow: None
Pink: None
Unhandled exception in thread started by <bound method TiltHydrometerManager.scan of <TiltHydrometer.TiltHydrometerManager instance at 0x76b67940>>
Traceback (most recent call last):
File ā€œ/home/brewpi/brewpi-brewometer/tiltHydrometer-test/TiltHydrometer.pyā€, line 360, in scan
blescan.hci_le_set_scan_parameters(sock)
File ā€œ/home/brewpi/brewpi-brewometer/tiltHydrometer-test/blescan.pyā€, line 107, in hci_le_set_scan_parameters
old_filter = sock.getsockopt( bluez.SOL_HCI, bluez.HCI_FILTER, 14)
_bluetooth.error: (9, ā€˜Bad file descriptorā€™)

Just for fun I tied the scan tool:
root@f9648c4b9a69:/home/brewpi/brewpi-brewometer/tiltHydrometer-test# sudo hcitool lescan
Could not open device: No such device

Also for fun, I then did the same steps on the actual pi.
The results from the scan worked correctly.
HypriotOS/armv7: pirate@brewpi1 in ~
$ sudo hcitool lescan
LE Scan ā€¦
05:5B:D9:E4:D7:1A (unknown)
88:C2:55:AC:31:87 (unknown)
88:C2:55:AC:31:87 Tilt
1C:1A:C0:87:89:82 (unknown)
1C:1A:C0:87:89:82 (unknown)
18:AF:61:B8:0F:E3 (unknown)
18:AF:61:B8:0F:E3 (unknown)
C8:69:CD:2C:A1:74 (unknown)
C8:69:CD:2C:A1:74 (unknown)
88:C2:55:AC:26:BF (unknown)
88:C2:55:AC:26:BF Tilt
76:C2:62:3B:71:05 (unknown)
76:C2:62:3B:71:05 (unknown)
D4:DF:DD:62:13:CE (unknown)
D4:DF:DD:62:13:CE (unknown)
E0:36:E2:CB:F7:94 N0F47
E0:36:E2:CB:F7:94 (unknown)
DE:9D:5C:00:E7:40 (unknown)
DE:9D:5C:00:E7:40 (unknown)

And Iā€™m now zero for 3 attempts for using this feature.
Currently there are several very different platforms running brewpi and itā€™s nearly impossible to verify compatibility in each environment.
Thanks to all those that spent the effort creating it but until the bluetooth/container interface is easily connected, this seems out of my reach.

You seem to be quite close to getting it to work. I believe the problem youā€™re now facing is how/if the docker container can access the bluetooth stack. Have you launched your Brewpi container with the networking host mode?

If you havenā€™t, Iā€™d try there and then attempt to run the sudo hcitool lescan command to see if youā€™ve got access to the device. Assuming this now works, then youā€™ll probably need to re-run the sudo setcap... command as well then you can re-attempt the TiltHydrometerTest.py command.

I deleted my previous container and used this command to create a new brewpi instance:
docker run -d --privileged --net=host --name brewpi -p 80:80 -v ~/brewpi-data:/data -v /etc/timezone:/etc/timezone -v /etc/localtime:/etc/localtime --restart always brewpi/brewpi-raspbian

After doing the updates and git clone and installing the additional libraries this is the result:

root@brewpi1:/home/brewpi# sudo hcitool lescan
LE Scan ā€¦
C8:69:CD:2C:A1:74 (unknown)
C8:69:CD:2C:A1:74 (unknown)
05:5B:D9:E4:D7:1A (unknown)
1C:1A:C0:87:89:82 (unknown)
1C:1A:C0:87:89:82 (unknown)
E1:AF:D6:55:D5:2E Tile
E1:AF:D6:55:D5:2E (unknown)
E0:36:E2:CB:F7:94 N0F47
E0:36:E2:CB:F7:94 (unknown)
F4:5A:59:56:E1:1D (unknown)
F4:5A:59:56:E1:1D (unknown)
FD:F4:22:7B:C2:9C Tile
FD:F4:22:7B:C2:9C (unknown)

The scan does indeed work. Building the container in host mode shares the resources on the pi. Notice the prompt is now root@brewpi1 instead of root@f9648c4b9a69 as was created using the run command listed in the wiki. Additional research shows this option might not be available to other non pi platforms.

When I return home Iā€™ll be able to wake the Tilt and start checking the graphs.

Thanks for the help.

Hey @sbowler, so Iā€™m having a hell of a time trying to figure this out. Iā€™m just trying to get the hex value for the battery from my tilt. When I first tried doing the lescan I was getting input/output errors. So I did a hcitool hci0 down/up and the lescan started to work. It gives me only one result / MAC address titled (unknown). But being that my setup is in my garage, Iā€™m pretty sure itā€™s my tilt. So I try to run the gatttool command (with that one MAC address) to get the hex value for 0x0048 and I get: ā€œconnect error: Connection refused (111)ā€. My bluez package is running 5.23-2+rpi2. I have ran this command as pi and root with the same results. Any ideas?

FWIW, Iā€™m pretty sure the Tilt ships from the UK.

I too would love to control temp with the Tilt. Iā€™ve found that it floating in the wort is much more accurate than the temp prob taped to the outside of my bucket.

@sbowler and others. New to the whole BrewPi and having little luck getting it all running with tilt integration.
I bought the Tilt, RPI 3 and Arduino in the hope of logging fermentation progress and eventually controlling temp. Iā€™ve built the Pi and BrewPi and brewometer integration. I didnā€™t add the arduino controller as yet. I can run the TiltHyrometertest script and get results. I cannot get data to log for BrewPi.
Based on an earlier post, I added fuscus (in lieu of Arduino) and can now get data to log, but not graph Error is ā€œcould not parse dataā€. Looking at the data, I see this:

Feb 05 2018 20:55:51;null;null;null;NaN;null;null;1;null;null;null72.0;1.023;
Thoughts? Am I doing it wrnog using the fuscus device?