SmartScale is a smart IoT weight scale project based on ESP32 and Flask, designed to collect and store weight in Garmin account.
-
Clone the repository
git clone git@github.com:JonathanFricke/SmartScale.git cd SmartScale/backend -
Create a virtual environment
python3 -m venv .venv source .venv/bin/activate -
Upgrade pip (optional but recommended)
pip install --upgrade pip
-
Install libraries
pip install -r requirements.txt
-
Configure information
Create
.envinSmartScale/backend/, based on.env_template.Fill in your SSID, Wi-Fi password, and custom API-key.
Fill in server IP-address in
cert.conf. -
Create SSL certificats
Run the following command to generate a self-signed certificate and private key based on
cert.conf.openssl req -x509 -newkey rsa:2048 -keyout certs/key.pem -out certs/cert.pem -days 3650 -nodes -config cert.conf -extensions v3_req
⚠️ We needcert.pemcontent later for ESP32
-
Enable server startup on boot
Edit crontab file.
crontab -e
Add the following line at the end, replacing
PATH_TO_REPOwith the full path to your cloned repository:@reboot PATH_TO_REPO/backend/start_garmin_server.sh >> PATH_TO_REPO/backend/cron_log.txt 2>&1 &
This is a firmware project for PlatformIO, designed for embedded development on microcontrollers such as ESP32, Arduino, STM32, etc.
-
Clone the repository
git clone git@github.com:JonathanFricke/SmartScale.git cd SmartScale/firmware -
Configure
Create
secret.hinSmartScale/firmware/, based onsecret_template.h.Fill in your Garmin account credentials and the same API key used in the backend
.envfile.Copy content of the server
certs/cert.pemwith linebreaks\nintoROOT_CAExample:
constexpr const char *ROOT_CA = "-----BEGIN CERTIFICATE-----\n" "MIIFBTCCAu2gAwIBAgIQS6hSk/eaL6JzBkuoBI110DANBgkqhkiG9w0BAQsFADBP\n" ... "KPpdzvvtTnOPlC7SQZSYmdunr3Bf9b77AiC/ZidstK36dRILKz7OA54=\n" "-----END CERTIFICATE-----";
⚠️ If the certificate doesn't work, setSSL_INSECURE=true. This disables certificate verification and is a security risk — use only at your own risk! -
Set up PlatformIO
https://wiki.seeedstudio.com/xiao_esp32c6_with_platform_io/
Don't create new Project but open
SmartScale/firmware -
Upload to ESP32
Connect ESP32 via USB.
In PlatformIO, click the Upload button or run:
pio run --target upload
-
ESP32 will run automatically when powered on.
-
Server managed with bash scripts
cd SmartScale/backendManage server:
./start_server.sh # Start server ./restart_server.sh # Restart server ./kill_server.sh # Stop server
-
Check server status
Open
https://IP-ADDRESS:PORTin browser.You should see a status page confirming the server is available.
⚠️ If using a self-signed certificate, your browser may show a warning. You can proceed anyway.
Never commit .env or secret.h files to Git. They contain sensitive credentials.
Use tail -f nohup.out to view server logs in real time.
Use the serial monitor (baud rate 9600) to debug ESP32 output.
