🎉 Real-Time Scale and Weight Analytics 🎉
This repository contains all three components of the Piggy Scale system. The Scale component reads data from the load cells and publishes the measurements to the MQTT server. The MQTT server stores these real-time measurements and makes them available to all subscribed web clients. The web client subscribes to these real-time signals and loads previous weights from the database, allowing users to view, visualize, and analyze both current and historical measurements. The server handles requests from the client to read, write, and manipulate stored records.
- Real-time visualization of scale data
- Automatic weight estimation using real-time measurements
- Manual storage, retrieval, and manipulation of weight data
- View and analyze the history and trends of different pig batches
- Export measurement data to Excel
- Mosquitto: An open-source message broker that implements the MQTT protocol.
- Paho: A python library for interacting with the mosquitto MQTT broker.
- Angular: A platform for building web applications using TypeScript.
- TypeScript: The Client is written in TypeScript, a more statically typed version of JavaScrippt.
- Scale: Captures data from the hardware and publishes real-time measurements to the MQTT server.
- Client: An Angular-based web platform that subscribes to real-time updates from the scale and retrieves data from the server's database.
- MQTT Server: Buffers real-time measurements from the Scale and forwards them to subscribed clients.
- Solder each weight cell to a HX711
- Connect each HX711 to an individual GPIO
- Clone this repository to your local machine:
git clone https://github.com/Altishofer/piggyScale-Client.git
- Enter newly cloned directory
cd piggyScale-Client
- Install dependencies
yarn install
- Deploy Client
ng serve
-
Open UI in your favorite browser
- Clone this repository to your local machine:
git clone https://github.com/Altishofer/piggyScale-Client.git
- Enter newly cloned directory
cd piggyScale-Client
- Create Virtual Environment
python3.11 -m venv .venv
- Activate venv (Linux)
source .venv/bin/activate
- Install dependencies
pip install -r requirements
- Deploy REST-Server
python ./scale/measure.py
- Update and ugrade all packages:
sudo apt update && sudo apt upgrade
- Install mosquitto broker:
sudo apt install -y mosquitto mosquitto-clients
- Open mosquitto configuration:
sudo nano /etc/mosquitto/mosquitto.conf
- Replace mosquitto configuration:
# replace, save and close file
pid_file /run/mosquitto/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883 0.0.0.0
allow_anonymous true
protocol mqtt
listener 9001 0.0.0.0
allow_anonymous true
protocol websockets
connection_messages true
log_timestamp true
- Run MQTT-Broker in the background:
mosquitto -v -d
- Open NEW shell and test subscription:
mosquitto _sub -h localhost -t /test/topic
- Open NEW shell and test publishing:
# Switch to subscription shell and check if output is visible
mosquitto _pub -h localhost -t /test/topic -m "Hello World!"
Add all script to autostart (optional)
- Open Crontab with root rights:
sudo crontab -e
- Add automatic reset on reboot
@reboot sleep 60 && bash /home/pi/Desktop/startAll.sh
- Create new bash script on Desktop
cd /home/pi/Desktop && nano startAll.sh
- Insert Deployment code into bash file
#!/bin/bash
# Activate logger
#exec > /home/pi/Desktop/startAll.log 2>&1
source /home/pi/.nvm/nvm.sh
# Start Angular project
cd /home/pi/Desktop/piggyScale-Client
/usr/bin/git pull
/usr/local/bin/ng serve --configuration production &
# Start .NET project
cd /home/pi/Desktop/piggyScale-Client-Server/Project
/usr/bin/git pull
/home/pi/.dotnet/dotnet run --launch-profile Production &
# Start Python script
/home/pi/Desktop/piggyScale-Client/.venv/bin/python /home/pi/Desktop/piggyScale-Client/scale/measure.py &
- Make file executable
sudo chmod +x startAll.sh
- Reboot
sudo reboot
- If automatic deployment fails, uncomment logger in bash script and open log file after reboot.