Raspberry Pi Pico Smart Scale
Building a smart scale with a Raspberry Pi Pico that stores data in Supabase.
The Problemโ
I had made my own web and mobile app to track various things like schedule, goals, todos, food macros etc. Weight was one thing I added but had to manually enter data. I wanted a scale that would automatically update my own life assistant/todo app that has an AI assistant and could see that data.
I didn't like Bluetooth scales I had because I needed to open a phone app for them to record data historically.
Initial Approachโ
I set out to use an existing scale and tried to sniff the Bluetooth data they blast out. Unfortunately, I couldn't crack the encoding they used, so that approach was a dead end.
Solution: HX711 Load Cell Amplifierโ
I was able to find information on HX711 load cell amplifiers and decided to build my own scale. I used a Raspberry Pi Zero I had lying around to get a working scale that could read my weight and update Supabase automatically.
Later, I got a Raspberry Pi Pico and converted the code to work with it, which was more compact and power-efficient.
Resources That Helpedโ
- YouTube playlist: https://www.youtube.com/watch?v=cGFnwOccfeA&list=PLAmif_espMWkZZSdUxLtZqEoI_XKO2g5Y&index=8
- HX711 Python repository: https://github.com/gandalf15/HX711
- Example code for Pi Zero: https://github.com/gandalf15/HX711/blob/master/python_examples/example.py
- Wiring diagram: https://electronoobs.com/eng_arduino_tut115_2.php
- Connecting Pico to WiFi: https://projects.raspberrypi.org/en/projects/get-started-pico-w/2
Hardware Usedโ
- Original scale: https://www.amazon.com/dp/B092V8HWW5?ref_=ppx_hzsearch_conn_dt_b_fed_asin_title_5
- HX711 module: https://www.amazon.com/dp/B0BLND4VF6?ref=ppx_hzsearch_conn_dt_b_fed_asin_title_1
- Raspberry Pi Pico: https://www.amazon.com/dp/B0DP54FWX1?ref=ppx_yo2ov_dt_b_fed_asin_title
Issues I Ran Intoโ
Battery and Time Issuesโ
When going to battery power, I lost time functionality, the pico thought it was years in the past. I removed the Pico sending date to Supabase and just set a default value of the current date for that field in Supabase instead.
Python Module Problemsโ
The datetime Python module was causing the script to hit an exception but with no log or message on what the exception was - the program would just exit silently. I worked around needing the pico to know the date. The module wasn't microPython to begin with.
The JSON module wasn't working properly on the Pico either, so I had to work around not using it. Module wasn't microPython either.
Storage Constraintsโ
To make space for the necessary code, I had to remove some packages that weren't essential for the core functionality.
Github Repoโ
TBD