Hacking Weighing Scale to Upload Weight to Plotly using Raspberry Pi

Weighing scale

I have been interested in monitoring and keep track of my weight. In the past, I have used phone apps for this purpose, works OK but I was thinking of reading weight information using some microcontroller from my weighing scale and upload the data to an online database. That means that microcontroller should connect to my wi-fi connection at home and upload the data. I have seen some projects online that use an arduino for this purpose. They use arduino to serially send information to computer. The information on the computer can be potentially sent to an online database. One could also upload data directly from arduino to internet using a wifi shield, but this makes it more expensive. I was therefore more inclined towards Raspberry pi because it connects to wifi easily and can read data from weighing scale. I was also inclined in programming in python on raspberry pi rather than C, which I am not very proficient.

Choice of weighing scale: I looked around some projects online and found a weighing scale here (http://fivevolt.blogspot.com/2011/01/hacking-scale-to-add-zigbee-goodness.html) that seemed easy to get data from by reading the LED signals. I bought the same model for around 20 bucks at my local target. The first thing I notice after opening this scale was that it did not look similar to what was described at fivevolt blog. I did not see the four transistors and HC164 of which the author talks about in his blog. May be the manufacturer changed the design or they have different versions of it. I was disappointed.

The PCB on the weighing scale had a epoxy covered region, which I presume is the microcontroller and it is connected to a big chip on the board. I looked at the name of the big chip on the pcb board and I can barely read TM1628. A simple google search revealed that it was an LED controller for the led display. The led display has four grids (digits). Each of this digit is a 8 segment display . TM1628 controls which grids and segments were to be lit or not (HI or LOW) . So I can see 12 wires going from LED controller to LED display ( four for grids and 8 for the 7 segment display). I could figure out which wires correspond to which grid and which segment and tried to solder wires. But that meant I have to read 12 digital signals (Hi or Low) using raspberry pi GPIO. This also looks very ugly too. So I decided to take a different route instead.

A close inspection revealed that the microcontroller onboard was sending instructions to TM1628 with SPI protocol. So I intercept the voltage pulses (3.3V) using Raspberry Pi as shown in figure below. SPI bus consists of master and slave and has four lines in between them, which are MOSI, MISO, SCLK and SS (for more information see https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi).  In this case, the TM1628 is the slave and the microcontroller on board is the master. The slave does not send any data to the microcontroller so there is no MISO line. SCLK is the clock signal. MOSI and SS line are referred as DIO and STB respectively in the TM1628 manual.


Schematic of the hacked weighing scale



After intercepting the STB, SCLK and DIO with raspberry pi as shown in the above figure, I used bitscope () to read these signals. A type pattern looks like this:


Each green line in the DIO contains data that is synced to STB and SCLK. When I zoom on the each green line I see the following:


Bits of data are being sent out in the DIO line at the rising edge of the clock signal.To decode these bytes, I wrote a python program (source code link at the bottom of this post) that would capture those bits very fast using PIGPIO library. When I just step on the weighing scale and get down, weighing scale displayed “0.0” for some time and then the display turns off. I was able to get the bytes for this action and start to decode according to the TM1628 manual. Below are the bytes being sent and the decoded information for the action of just stepping on and stepping of the weighing scale.

Order of commands being sent

Command 1 and command 2 prepare the display. Command3 helps in preparing the grid/digit. It can be seen from the above figure, once a grid is prepared, a character is being written to that grid/digit. This process starts from the first grid and ends at the fifth grid. This cycle repeats many times. The cycle repeats so fast that we think the display is not changing.  I used the following cheat sheets for decoding the above data bytes. Following table is for command 3 where a certain grid/digit has to being chosen.

Grid command

Following table is the bytes for displaying a certain character on a certain grid/digit

Decoding the bytes on weighing scale

Once I understood the commands being sent and how to interpret them, i wrote a python code that uses PIGPIO to read these commands. I also added the capability to select a user with a rotary switch and assign weight information. A user can be guest, myself or my wife. Weight information is written to a file. Finally I also added code to upload the file to plotly for visualization.

This is my final product



Hacked Weighing scale and control box


Housing for Raspberry pi and Rotarty switch

Below is the youtube video of how the program works (without plotly integration)

Below is an image of my weight on plotly since last year. I am still overweight :(

 Python Source code can be downloaded here.


3 thoughts on “Hacking Weighing Scale to Upload Weight to Plotly using Raspberry Pi

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>