sethsteenken / keg-monitor

Keg monitoring system using smart scale weight recording and MQTT communication.
MIT License
1 stars 1 forks source link

Logo Keg Monitor

Keg monitoring and management system using an MQTT broker and IoT smart scales to report keg weight values and changes. Compliment a kegerator with this system to display what beer is on tap, how much beer remains within each keg, and detect when a beer is poured.

Workflow Status Docker Pulls Docker Image Version (latest semver)

Display Screen

Inspirational Credit

After homebrewing for many years, I was able to acquire a kegerator with two taps to enjoy the beer I would brew. Gone are the bottling days! After a year or so of not really knowing how much was left in a keg, I wanted to have a more sophisticated and technically focused solution. This project was born.

Also, massive shoutout and credit to Matt over at the Troubled Brewing YouTube Channel for the instructional video on building the smart scales that helped jumpstart this project. Seriously could not have completed this project without Matt's amazing video.

Architecture

The Keg Monitor application is a .NET Blazor web application that is compiled via a Dockerfile to run as a container. The latest container image for the application is pulled from Docker Hub when deploying. The keg scale readings come from load cells connected to an amplifier which connects to a microchip like a NodeMCU. The microchip connects to the network wirelessly to periodically push the current weight reading from the load cells via the MQTT protocol. These readings are received by an MQTT broker. The Keg Monitor application subscribes to this broker in order to be notified of weight changes. A PostgreSQL database is used by the application to store weight changes and beer data.

Architecture diagram

Getting Started

Getting the full keg monitoring application and dependences installed and running will require some hardware, minor technical and networking knowledge, and some beer of course.

Prerequisites

Installation

First, clone the repository or copy out the docker-compose.yml.

git clone https://github.com/sethsteenken/keg-monitor.git

Create new directory and copy docker-compose.yml.

mkdir server
cp docker-compose.yml /server/docker-compose.yml

Create an .env file in this directory. Note: you will not see the file in the directory.

touch .env

Set .env with the following content. Fill in the empty environment variables with values related to your setup. Feel free to change any of these defaults.

MQTT_HEALTH_PROBE_USER=healthcheck_user
MQTT_HEALTH_PROBE_PASSWORD=<password for health probe for the mqtt broker>
POSTGRES_USER=<postgres user>
POSTGRES_PASSWORD=<postgres password>
POSTGRES_VERSION=15.4
KEGMONITOR_CONN_STRING="Host=postgresql;Database=keg-monitor;Username=<postgres user>;Password=<postgres password>"
KEGMONITOR_DOMAIN=<custom local domain or IP address for the web application>
KEGMONITOR_MQTT_PASSWORD=<password for the mqtt broker app user>
TIMEZONE=America/New_York

Deploy the application and dependent containers using Docker Compose

sudo docker compose up -d

The containers should deploy successfully, but may result in unhealthy or stopped status. Perform the following setup steps:

Additional Setup Steps

Docker Troubleshooting

Review Docker commands (there's also a cheat sheet for these) to troubleshoot containers that may fail to start.

Can optionally install a GUI application like Portainer to help manage your containers.

Testing MQTT Communications

Use a tool like MQTT Explorer or MQTTx to test the MQTT broker connection and see the messages being sent from the scales.

Features

Dashboard to view detailed keg scale information, weight changes, connection status, and pours at a glance. Review weight recordings and average calculations to note differences in subtle weight changes due to varying temperatures in the kegerator.

Dashboard Screen

Display page to display active keg scales, the beer in those kegs, percentage remaining, and a pour popup indicator.

Display Screen

Add and edit scales for as many kegs as you need

Scale Edit Screen

And keep a list of beers to assign to your keg scales

Beer List Screen