5618

This smart tracker focuses on feline health. I continuously measure the weight of the cat litter in the litter box. My premise is that every change in weight provides insight into hygiene status. By monitoring in real time, I can detect health anomalies at an early stage. Using Edge AI, the system will soon be able to recognize individual cats based on their weight and behavior. If time allows, I will also explore whether integrating the smart camera from the STM32N6 development board enables visual identif

Link from here...

Prototype Smart Cat Litter Scale with Home Assistant Integration for ElektorMag and STM32 Edge AI Contest
June 2, 2025


Introduction: STM32 Edge AI

Earlier this year, STMicroelectronics announced the STM32 Edge AI Contest to introduce the new STM32N6 processor. This processor is at the heart of a development board designed for technical developers and makers to rapidly prototype new Edge AI concepts. As soon as I saw this competition, a practical idea immediately came to mind: the Edge AI-Powered Smart Cat Litter Home Assistant Monitor.


Smart Health Tracker

This smart tracker is focused on feline health. I continuously measure the weight of the cat litter in the litter box, working on the principle that every change in weight provides insight into hygiene status. By monitoring in real time, I can detect early signs of health anomalies. With Edge AI, the system will soon be able to recognize individual cats by their weight and behavior. If time permits, I also plan to explore whether smart camera integration with the STM32N6 development board enables visual identification. Additionally, my smart health tracker predicts the optimal moment to clean the litter box and integrates directly with my Home Assistant automation system.


Components and Tools

For this project, I use:

  • STM32N6 Discovery board

  • Four 50kg load cells

  • HX711 ADC converter

  • Arduino Uno or QT-Py ESP32S2

  • Mini breadboard

  • Various Dupont connectors

  • USB-A/USB-C connector

  • Arduino IDE

  • Home Assistant

  • MQTT/Mosquitto

  • Bambu X1C 3D printer with yellow PLA filament

  • Screws, nuts, soldering iron, and Kapton tape

  • Weller WE1010 soldering station


Development Board and Features

The STM32N6 Discovery Kit is a comprehensive toolkit for advanced AI vision prototyping. The board includes an STLINK v3 programming port, standard Arduino and ST morpho connectors, a MIPI camera interface, fast USB 2.0, gigabit Ethernet, 32MB RAM, audio, and SD card slot. The bright 5” touchscreen with NeoChrom GPU provides smooth graphics performance.


Hardware Integration

Once the board arrived, I immediately ordered the required load cells, HX711 amplifier, and ESP32 processor. For Home Assistant integration, I explored various options. Data can be read via USB, ESPHome, Modbus, I2C, REST API, or MQTT. Since I already use MQTT in my setup, I chose that as my initial approach.


Designing the Weighing Platform

For the hardware, I built a platform with four integrated load cells, similar to a bathroom scale. I opted for 50kg sensors to ensure the system can accommodate larger pets. Each load cell has three wires, and I connected them in a Wheatstone bridge configuration. The HX711 ADC amplifies the tiny voltage differences to measurable signals.


3D Design and Assembly

I took a top-down photo of the litter box, placed a measuring stick next to it, and imported the image into VCarve Pro for precise measurement. In the drawing, I strategically positioned the sensors and designed holes for mounting. A second plate houses the electronics, with cables routed neatly. The plates were laser-cut, and I designed and 3D-printed yellow caps on the Bambu X1C to cover the sensors. After assembly, I soldered the appropriate wires and connected everything to the breadboard.


Firmware Development

I began by writing the firmware. Each load cell configuration requires its own calibration. On startup, the system performs an automatic tare so that the empty litter box's weight is ignored. I carefully configured the pins for data and clock lines. In the code, I used several functions from the HX711 library:

  • begin(DOUT, SCK): initializes HX711 with selected pins

  • is_ready(): checks if data is available

  • read(): reads the raw 24-bit sensor value

  • tare(): sets the current weight to zero

  • set_scale(factor): sets the calibration factor

  • get_units(times): returns the averaged weight reading


Switching to ESP32 S2

The Arduino Uno quickly proved insufficient in both power and Wi-Fi capabilities, so I switched to the QT-Py ESP32 S2. After configuring the correct pins and flashing the firmware, I was able to measure weights accurately to the gram, even above 30kg. I used debug statements to monitor the program. With hardware working, the next step was integration with Home Assistant.


Home Assistant Integration

My goal is to monitor the Smart Cat Litter scale live in Home Assistant. I have used Home Assistant for five years now, after switching from Domoticz due to bugs and a hacking incident. Home Assistant offers countless integrations, including IKEA TRÅDFRI, Tuya IoT, Zigbee, Matter, and RFXcom. For this setup, I selected MQTT as the protocol since it was already running reliably in my environment.


MQTT Configuration

In the Arduino IDE, I implemented PubSubClient.h, a well-known MQTT client for ESP microcontrollers. To connect to the broker, I used:

  • mqtt_server (broker address)

  • mqtt_user (username)

  • mqtt_pass (password)

  • mqtt_topic (communication channel)

In Home Assistant, I validated the MQTT integration and created a dedicated user. In mqtt.yaml and configuration.yaml, I defined the sensor. The ESP32 now publishes weight data, which is visible in the MQTT console. I then set up a dashboard for monitoring.


Dashboard and Data Analysis

Home Assistant makes it easy to create dashboards for managing devices, sensors, and data at a glance. Initially, I record weight measurements over time. Later, I plan to recognize individual cats and detect abnormal behavior.


Smarter Application Through Data

To truly make the application intelligent, I collect and label measurement data. A litter box visit can be recognized by a temporary increase and decrease in weight within, for example, 60 seconds. The weight difference before and after the visit indicates the “output” left behind—I expect to distinguish between urine and feces events. With more data, these categories will become clearer. Unexplained values are marked as anomalies. Anomaly detection and Edge machine learning fit in perfectly here. My first step is building a reliable dataset.


Progress Summary

In recent days, I have made significant progress. The hardware is operational: the load cells and HX711 are assembled, the ESP32 firmware reads the sensors and publishes data via MQTT. Home Assistant neatly integrates everything with its own entities and dashboards. The next challenge will be porting this technology to the STM32N6 Discovery platform. To be continued…