Case study

Stock tools scale

An ESP32 scale that reports weight and temperature to ThingsBoard. A phone sets Wi-Fi and the server over BLE, so the unit does not need a laptop after the first flash.

HX711 + MCP9700 → BLE setup → MQTT → ThingsBoard

Record
Public repository
Stack
ESP32, BLE, MQTT, ThingsBoard, HX711
Hardware
ESP32 · HX711 load cell amplifier · MCP9700 temperature sensor · RGB status LED
Links
GitHub

The problem

A stock scale in the field cannot depend on someone plugging in USB every time the Wi-Fi or the server address changes. The device still has to show up on a dashboard, accept a remote tare, and make its own state obvious when nobody is watching a serial log.

What I built

Firmware on ESP32, in PlatformIO with the Arduino framework, that reads an HX711 every second and an MCP9700 every 30 seconds. Weight, temperature, and Wi-Fi RSSI go to ThingsBoard over MQTT. The phone talks to a Nordic UART-style BLE service advertised as “Stock Tools Scale”. Commands are plain text: set Wi-Fi, set the server and device token, restart, or clear the stored network.

ThingsBoard can call back into the device: tare the scale, reboot, or wipe the config and return to BLE setup.

Decisions

BLE is the setup path, and it is also the fallback. Credentials live in NVS, so a power cycle does not forget the shop network. If Wi-Fi or ThingsBoard does not connect inside the timeout (120 seconds by default), the firmware clears the config flag and boots back into BLE mode instead of sitting offline with a bad password.

The HX711 calibration factor is a build flag, not a magic number buried in the loop. Weight is published every second. Temperature and RSSI share a slower 30 second tick so the radio is not busy with values that do not move that fast.

An RGB LED is the field UI: blue while waiting for BLE setup, red while connecting or on error, green while telemetry is flowing. A red-green-blue sweep on boot checks the LED before anything else.

The battery sense pin is defined and left unconnected on the schematic this repository describes.

Pins

HX711 data is GPIO 23 and clock is GPIO 22. The MCP9700 is on GPIO 34. The RGB LED uses GPIO 13, 12, and 14, with a power LED on GPIO 27.

Back to work Start a project