BrewBlox Tilt Service

After getting the Tilt Service loaded and functioning, I’m having problems with calibration. I calibrated my Tilt to a floating glass hydrometer, and updated the SGCal.csv. That file looks like this:

image

As you can see, my Tilt is accurate at low gravity, and loses accuracy by up to 11 points as gravity increases. No big deal, that’s what calibration is for! However, when I reload the Tilt service, my Calibrated SG value in the UI is saying 1.004 when the Tilt is floating in a glass of water. Something doesn’t seem to be correct in the logic of reporting calibrated values. I dug through the python code to see if I could learn how calibration is performed, and found the cubic polynomial interpolation. I wrote a small python script to calculate my calibration coefficients and predict SG values based on a user-supplied raw value. This logic works and is not the issue. I get correct calibrated values out of this little model, which do not match what my Tilt service is reporting in the UI. That is far as I could get, since I understand numpy much better than how values are reported to the UI. Anyhow, here is the little model I made to test my calibration:

import numpy as np

# x = uncalibrated value, y = calibrated value 
x = np.array([1.00, 1.002, 1.007, 1.009, 1.017, 1.024, 1.027, 1.038, 1.044, 1.050, 1.056, 1.065, 1.076, 1.090])
y = np.array([1.00, 1.002, 1.011, 1.012, 1.022, 1.030, 1.034, 1.047, 1.055, 1.061, 1.067, 1.076, 1.087, 1.101])

# the cubic polynomial function:
z = np.polyfit(x,y,3)

while True:
    value = input("enter an uncalibrated SG value: ")
    if value == '':
        break
    # The calibrated value based on the raw value entered by the user:
    cal = round(np.poly1d(z)(float(value)), 3)
    print(f'Calibrated Value = {cal}')

I also did something similar in R:

range <- seq(from=0.99, to=1.110, by=0.001)

x <- c(1.00, 1.002, 1.007, 1.009, 1.017, 1.024, 1.027, 1.038, 1.044, 1.050, 1.056, 1.065, 1.076, 1.090)
y <- c(1.00, 1.002, 1.011, 1.012, 1.022, 1.030, 1.034, 1.047, 1.055, 1.061, 1.067, 1.076, 1.087, 1.101)

plot(range, range, type = 'n',xlab = "Uncalibrated", ylab = "Calibrated")
points(x, y)

model <- lm(y ~ poly(x, 3))
p <- predict(model, data.frame(x=range))

lines(range,p, col='red')

R output:

Could you please post the logs for the tilt service?
If convenient, we could also move the discussion to discord, as it is likely to involve quite some back and forth.

yes, discord is probably more appropriate.

EDIT: for anyone following along at home, I had a stupid misplaced comma in my csv :see_no_evil:

I just updated to the latest BrewBlox. I added the new Title names to my graph. However, the new SG tilt, is graphing as a straight line. The old is still on the graph, and the slight changes in SG are showing. The new, as I mouse along the graph, show the value a a tooltip, and it changes, but the graph line itself is straight. As you can see, the red line is the new Tilt SG, and the 2 tool tips 1.035 and 1.032 are a straight line.



Over the past few days I’ve been trying to integrate a few Tilts into my BrewPi system without much luck. For reference, I’ve attached a drawing to illustrate how my system is setup.

In short, Brewblox is hosted from a TrueNAS VM while the Tilts connect to an RPI. What I would like to do is view the Tilt data trends on my Brewblox dashboard. I have no issues connecting to the RPI web server to view their information so I know this is setup correctly. Just not too sure how to setup the messaging between the RPI and Brewblox.

So far:

  • Brewblox version is: 2021-11-29T16:59:47.708Z
  • Both the VM and RPI are up-to-date (apt-get update apt-get upgrade).
  • RPI has python, docker and docker-compose installed; no errors when running docker-compose up -d

Here is my docker-compose.yml file from the RPI:

version: ‘3.7’
services:
tilt:
image: brewblox/brewblox-tilt:${BREWBLOX_RELEASE:-edge}
restart: unless-stopped
privileged: true
network_mode: host
volumes: [’./tilt:/share’]
command: --mqtt-host=10.10.10.60

With this I have tried several variations of the --mqtt-port=<port> command. (used 80, 443, 1883). Not sure what to use here or if even need to specify a port? When I connect to my Brewblox dashboard I can use either http://10.10.10.60 or https://10.10.10.60 and both work.

Here is my docker-compose.yml from Brewblox:

services:
spark-left:
command: --name=spark-left --discovery=all --device-id=3C004D000851353532343835
image: brewblox/brewblox-devcon-spark:${BREWBLOX_RELEASE}
privileged: true
restart: unless-stopped
spark-right:
command: --name=spark-right --discovery=all --device-id=20002C001947383434353030
image: brewblox/brewblox-devcon-spark:${BREWBLOX_RELEASE}
privileged: true
restart: unless-stopped
tilt:
image: brewblox/brewblox-tilt:${BREWBLOX_RELEASE}
restart: unless-stopped
privileged: true
network_mode: host
volumes:
- type: bind
source: ./tilt
target: /share
labels:
- traefik.enable=false
version: ‘3.7’

Any thoughts on what I should do next?

Simple things first:

  • If you’re using the tilt service on a separate Pi, you don’t also need it on your brewblox install.
  • to paste code on the forum, you can put it between triple backticks. This preserves whitespace.
    ```
    (Code block)
    ```
  • by default, the tilt service uses websockets on port 443. You can change this to mqtt with command line flags (it will use 1883 by default)

I pushed a bugfix for the tilt service a few days ago. If you pull the service on your Pi, is it up to date?

What is the output from docker-compose logs tilt?

In another topic I posted instructions for checking host bluetooth settings: Brewblox release 2021/11/29 - #6 by Bob_Steers

  • I’ve removed the tilt service from the brewblox install and now the only service is on pi.
  • ran docker-compose pull tilt and it was up-to-date. “Pulling tilt … done”. Ran docker-compose up -d again just in case.
  • output from docker-compose logs tilt is rather short.
pi@tiltpi:~/tilt $ docker-compose logs -f -t tilt
Attaching to tilt_tilt_1
tilt_tilt_1 exited with code 139
  • from my understanding i am not having issues between the tilts and pi, i’m just not able to see the services on brewblox. in reviewing the topic you posted, the only real difference i noticed was that my HCI version was 4.1.
  • tried adding different ports again to docker-compose.yml example: command: --mqtt-host=10.10.10.60 --mqtt-port=1883 (used 443 also) then restarted everything. still no luck.

Your service appears to immediately exit with a segfault (the exit 139).
You can check service status with docker-compose ps.

I assume you’ve restarted your Pi after updating?
What is the output from docker version?
Does your Pi have enough disk space left?

If you run docker hello world, does that work?

docker run --rm hello-world

You can remove and redownload the image to fix any data corruption with:

docker-compose down
docker image rm brewblox/brewblox-tilt:edge
docker-compose up -d
pi@tiltpi:~ $ docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:14 2021
 OS/Arch:           linux/arm
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:32 2021
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Hello world works and I’m only using 19% of a 16GB card.

pi@tiltpi:~/tilt $ docker-compose ps
   Name                  Command               State   Ports
------------------------------------------------------------
tilt_tilt_1   python3 -m brewblox_tilt - ...   Up           

I ran this command a few times… Sometimes State is Up, sometimes State is Restarting…

Logs still show a segfault after redownloading the image?

Correct. Still get the exit with code 139. I edited my previous post after your reply apparently, docker-compose ps cycles between an Up state and Restarting state.

If you stop docker-compose, and convert the service to a docker command, does that run?

docker run --rm -it --privileged --net host brewblox/brewblox-tilt:edge

If that doesn’t, try the above, but with --entrypoint python3 to check whether the issue reproduces if you don’t run the actual code.

If you still get a segfault, you’ll want to nuke all docker data and retry:

sudo rm -rf /var/lib/docker

My bad here. I didn’t set it to the correct Y axis. defaulted to Y1 and should have been Y2

1 Like
pi@tiltpi:~ $ docker run --rm -it --privileged --net host brewblox/brewblox-tilt:edge --entrypoint python3
WARNING: The requested image's platform (linux/arm/v7) does not match the detected host platform (linux/arm/v6) and no specific platform was requested

Hahaha. That led me on a road to hell. While I was there reflecting on my life choices, I realized that PI Zero’s were not good for me… So I hit the reset button, came back to life, and started over with a PI 3 B+. Installed the TiltPi image, updated, installed Brewblox then docker-compose. Used the same docker-compose.yml file and voila! The service showed up in my Brewblox VM and life is good again. Thanks @Bob_Steers!

1 Like

I am having difficulty getting the Tilt to show in my graph. From the main control, tilt is displayed, and showing reading from the Tilt (Green is active, purple is not in range currently)


I have the tilt added to the graph

But it is not displaying anything.

Any Idea what I can do to get it back to displaying?

Could you please run brewblox-ctl log?

In the UI, could you please open dev tools (ctrl+shift+i), go to console tab, refresh the page, and check whether any errors are shown?

here is the logs https://termbin.com/ue9h

There are no errors on the page. and overnight the tilt started to display again. So currently working, and nothing in the setup changed.

https://termbin.com/y8zc

Just did a fresh install on a Pi 4 and Spark 4 and now Im having trouble getting the tilt service to appear in the dashboard. The logs look as though its discovering the tilt but not sure what to do from here. I see a broken pipe error but not sure if that means anything…

I had a few errors during the tilt install that caused me to have to install yaml and the click module but after that the install seemed fine.
ModuleNotFoundError: No module named ‘yaml’
ModuleNotFoundError: No module named ‘click’

Thanks

This was handled on discord, but I’m curious about those module not found errors. Was this during installation, and was the virtual env active?

As noted above, my problem was fixed via Discord. Problem was my fault. I installed the tilt using the old j616 code on github instead of the newer method of just using brewblox-ctl add-tilt.

As for the errors, this was during the installation of the incorrect tilt code. Not sure if they would have ocurred on the newer, correct, code. Im not sure what a virtual env is. When I tried to run “python3 ./install_tilt.py” I got the first error, ModuleNotFoundError: No module named ‘yaml’. I think I installed python3 and pip3 to fix it. Then I tried to install again and got “ModuleNotFoundError: No module named ‘click’” I ran “sudo pip3 install Click” to fix that one. Again, not sure if it would have been needed if I installed the tilt correctly the first time.