Fisch´s Projekte-Seite

Project start: February 2021

Weight Scale

By having an InfluxDB as database for collection various sensor data and Grafana to visualize them not every measurement has to have a direct usecase for home automation. Seeing how values progress over time enables me often to gain new insights. Especially values that are changing rather slowly, like my own body weight.
Producing a chart is not a real problem when buying a smart scale. Even the connection via MQTT and/or writing the values to a database is possible by building a bluetooth to MQTT bridge for example.
But because I already had some requirements in terms of functionality in mind a diy-project was the only way to go.

A 20mm thick piece of wood is used as a basis for this scale. It was milled to an outside dimension of 300mm x 300mm.

In the four corners pockets are milled to put the load cells into. The center part makes room for all the electronics. The slot, which on first glance looks like a carrying handle, will house a seven segment display.
Postprocessing was done by rounding off the edges with a hand router and oiling the surfaces.

You can find those load cells with the keywords "50kg Load Cell HX711". This set constists of four elements, which can hold and measure up to 50 kg each and a load cell amplifier chip "HX711". For a correct wiring I refered to the tutorial on Code wise I used the library from bogde.
Controlling is done again with an ESP8266 on a Wemos D1 mini board. A 370mAh 2S Lipos is used for power delivery.

Like for the lightmeter I again used a self holding transistor circuit for on/off switching with the difference that in this case a capacitive touch sensor is used instead of a mechanical switch. This module needs around 3V - 5V supply voltage which I reduced with an LED from the 6V - 8.4V from the 2s Lipo. Standby current for this sensor is very low in comparison to the consumption of the esp on daily usage. I previously had problems with the latching circuit and a switching dc-dc converter after it so here I used a diode to get the maximum voltage low enough to not fry the VCC (typically 5V) input of the Wemos board.
The finished code for the ESP can be viewed here:

To do the calibration I first used my kitchen scale to weigh eight full bottles. Twice the amount can fit on my new scale, which equates to 15.194 kg for 16 bottles. This resulted in 340090 units measured (function get_units). Dividing this by the weight results in a calibration value of 23960.

Lastly the components have to be mounted inside the scale body. A rotary tool was used to grind small slots for the wires. Those were then hot glued in.
The three boards (latch circuit, wemos, HX711) are mounted by gluing short spacer bolts to the inside with epoxy glue.
The red seven segment display with four digits "0.36" inch 7-Segment 4-Digit LED Display TM1637" is screwed to a plate of plywood which then is pressed into the slot hole. To charge the scale the 2S Lipo has to be taken off the velco strip to then charge it with a RC model charger. I didn't had a fitting charging circuit with a bms at hand. Because I am measuring and transmitting the battery voltage during every power up I can setup an early low voltage warning. As it currently seems a charge will last for several months.

The scale looks very plain from above. Which was what I was going for.
Banana for scale.

Below you can see an example chart over 30 days. The y-axis raster corresponds to 1 kg per line.
Once every morning and evening I put myself onto the scale. The scale measures the weight every 100 ms (MEASURE_INTERVAL) and saves it in a cyclic fashion to a 40 element long (READING_FILTER_SIZE) array. Filtering is then done by taking the 10 values from the middle (MEANVALUECOUNT*2) of the sorted array. This optimized median filter resulted in pretty stable values with the disadvantage of a rather high latency of 2 seconds (READING_FILTER_SIZE/2*MEASURE_INTERVAL).
A measurement is seen as stable as soon as the difference between highest and lowest value of the array is less than 200 g (MAXSPREAD). As long as the scale is powered on minimum an maximum measurements are saved. The difference of those is then the measured weight. When this measured weight is more than 50 kg (MIN_WEIGHT_DIFFERENCE) it is send via MQTT.
A response is then generated inside nodered and displayed. After that the scale shuts off.
All mentioned values are stored as defines inside the code. See src/main.cpp