Organize and Share your Electronics the way you want. Sign-Up for a free account now. It takes only 30 seconds!

ESP8266: Turn a $9 Body Scale into a Smart Scale – Part 1

ESP8266: Turn a $9 Body Scale into a Smart Scale – Part 1

In this project I will show you how you can build yourself a fancy Withings-like body scale. I divided the article into two parts: Part 1 describes the hardware hack and Part 2 the software. In this project I used a cheap scale I bought in the local super market for 9 Swiss Francs (which is currently about USD $9.-) and I am optimistic that other digital scales will work for you as well. This project was a lot of fun since I had to do reverse-engineering, soldering, programming and (optionally) even 3D modelling and printing. I hope you will enjoy it as much as did!

Splash Screen of the revamped SmartScale

Before we begin

Just a little word of warning: you might  be taking apart a working digital body scale. I cannot guarantee that your retrofitting will actually work and you might end up having just a broken body scale. Because of this I recommend that you are using a cheap or old digital scale rather than an expensive working one…
The other thing I’d like to mention: it took me many hours of my scarce free time to build and document this project. While I am not depending on income from this blog I still very much appreciate teleported beer (donation), you following one of my affiliate links or buying something from my shop. Thank you!
This is a write up of a project I started about a year ago. The project went back onto my “work-in-progress stack” and was waiting for a revival. Back then I also wrote a quick article about it.

What you will need

The components I used in my project set me back between USD $30-40 including the body scale. The following list should give you an idea what components you’ll need and what you should be looking for.

Image Description Costs Where to buy
Original Digital Body Scale

Original Digital Body Scale

Digital Body Scale: It is very practical if you can build your smart scale project on an existing digital scale. From what I can tell modern digital scales all use the same kind of sensor (load cell) but I cannot guarantee it ~$USD 10.- Switzerland: Coop.
IKEA also has a low-cost scale: IKEA
Wemos D1 Mini

Wemos D1 Mini

The ESP8266 module is the next important component. It is the brain and mouth of your smart scale. I recommend a small development module like the Wemos D1 Mini: it has enough pins and is small USD $6.50 Squix Shop
HX711 Amplifier Module

HX711 Amplifier Module

The HX711 module is a so called Load Cell Amplifier and will convert the weak analog signal from the weight sensor into bits and bytes the ESP8266 can understand. USD $3.00 Squix Shop
LifePo4Batteries

LifePo4Batteries

Power Source – I picked a Lifepo4 AA-type battery since it provides the perfect voltage and has a considerable amount of capacity. The AA packaging (14500) also helps to buy or 3d print a good holder. If you don’t own a 3d printer also buy a AA-cell holder ~USD $10.- AliExpress
SSD1306 0.96" OLED display

SSD1306 0.96″ OLED display

These OLED displays are just wonderful: since the pixels glow by themselves the contrast is very high. You can choose between the 0.96 inch SSD1306 display or the 1.3 inch SH1106 one. The smaller one you can buy in the Squix Shop, the other you’ll have to order from AliExpress or similar ~USD $6-7.- 0.96″ from Squix Shop

1.3″ from AliExpress

Besides these “core” components you will also require wires, solder and solder iron, screw drivers.

Understanding the Body Scale

So here is the plan: you open up your pretty body scale, remove everything you don’t need and keep the load cells (the components which measure the weight) in place. Then you connect the load cells to your HX711 amplifier module and connect the amplifier to your ESP8266. Then you’ll need to attach the OLED display to the ESP8266 as well and bring in some kind of power source with an on-off switch. Easy, isn’t it?

image

The mini PCB I re-used. Now I just had to connect the four wires to the HX711 (click to zoom)

For me the hardest part was to figure out how the load cells should be connected to the HX711. Luckily the load cells were attached to a mini PCB which in turn was soldered with only a few pins to the main board of the body scale. So I only had to figure out how to connect the four pins of the mini PCB to the HX711 module rather than figuring out how to connect the 12 wires of the load cells (3 wires and 4 load cells). I don’t know how your scale will look like. Maybe you will be lucky as well but it also could be that you have to do some hard core reverse engineering. Maybe the following pictures will help.

Load Cell Wiring (click to zoom)

Load Cell Wiring (click to zoom)

I suggest that you test the setup on a bread board before you take out the soldering iron. This way you can easily switch the wires until everything works. SparkFun has a very good introduction to load cells and the HX711: Sparkfun Load Cell Tutorial

 

Connecting the load cells and the HX711 Amp

Now that we (hopefully) have figured out how to use the existing load cells we have to connect them to the amplifier and the amplifier to the ESP8266.

image

The mini PCB that came with the digital scale connected to the HX711

image

A look to the other side of the boards: mini PCB connected to the HX711. I drew the labels V+, V-, S+ and S- on the mini PCB. Sometimes you see this naming scheme

Again, how you connect the load cells to the HX711 requires a bit of educated guessing. Read through the previous chapter, read the SparkFun tutorial about load cells, use the color codes of the wires. Then connect the HX711 to the ESP8266. The following image is just a zoomed in version of the complete wiring below:

Zoomed in sketch of the HX711 wiring. See full picture below (Click to zoom)

HX711 wiring. See full sketch below (Click to zoom)

Connecting the OLED display

If you are familiar with my WeatherStation project or the ESP8266 based plane spotter then the wiring of the OLED display should be straight forward. Just connect VCC on the display with 3V3 on the ESP8266, GND with GND, SDA on the display with D6 on the ESP and SCL with D7. In theory you can choose any D-pin for SDA and SCL, just make sure that they don’t have special functions. I think D8 is required for programming, others might be used for flash access. Also when you use the pins I suggest here you won’t have to change anything with my code. Please have a look at the complete sketch below for a graphical representation of the setup.

Connecting the power source

Now to my new favourite power source in the ESP8266 world: the LiFePo4 AA battery. After watching the excellent video of my fellow (Swiss) country man Andreas Spiess about ESP8266 battery sources I immediately ordered a few from AliExpress. The beauty is that their voltage range matches the 3V3 operation voltage of the ESP8266 perfectly. You don’t need any linear voltage regulator or boost up/down converter which just turn a considerable part of the battery’s capacity into heat. The discharge characteristic of the LiFePo4 also shows that it keeps providing a ESP8266 compatible voltage over a long time. For simplicity (and due to lack of necessary skills;-)) I decided to use a switch which was already built into the scale as on/off switch. An automatic power-saving circuit would have been nice but that would have complicated the project even more. In the original setup the built-in switch could be used to change between pounds and kilograms, now it will serve as the power switch.

The complete hardware setup

The following diagram shows you how to connect all the components together. As suggested earlier I recommend that you wire everything up on a breadboard first. In the next chapter we will to a first smoke test and also a quick calibration of the sensors. Let me know when you are ready;-).

Smart Scale Setup: HX711 - ESP8266 (Wemos D1 Mini) - SSD1306/ SH1106 - LiFePo4 battery

Smart Scale Setup: HX711 – ESP8266 (Wemos D1 Mini) – SSD1306/ SH1106 – LiFePo4 battery (click to zoom)

Smoke Test and Calibration

While I use the term “smoke test” quite often in my daily software engineering routine I only learned recently that the expression originates from electronics: if you turn the device on and there is no smoke coming from the circuit you passed the first phase.

Let’s do a bit more and use a little program to see if the load cells are responding. While the “real” smart scale project will be using the Platformio environment I decided to use the Arduino IDE for this smoke test. This way you will have a starting ground even if you don’t get adjusted to the Platformio IDE. OK? So let’s get started:

  1. If you haven’t done so, install the latest Arduino IDE. I am currently using 1.6.9
  2. Download this library as zip file: https://github.com/bogde/HX711 and add the zip to the Arduino IDE by Sketch > Include Library… > Add .ZIP library…
  3. For the testing of the OLED display also make sure you have my OLED library installed: Sketch > Include Library > Manage libraries… Search for “ESP8266 Oled Driver for SSD1306 display” by Daniel Eichhorn and Fabrice Weinberg. At the time of writing the last version is 3.2.6
  4. Compile and upload the following code:
    #include <HX711.h>
    
    // Scale Settings
    const int SCALE_DOUT_PIN = D2;
    const int SCALE_SCK_PIN = D3;
    
    HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);
    
    void setup() {
      Serial.begin(115200);
      scale.set_scale();// <- set here calibration factor!!!
      scale.tare();
    }
    
    void loop() {
      float weight = scale.get_units(1);
      Serial.println(String(weight, 2));
    }
    
  5. Now check the serial monitor. If you see some non-static numbers then the HX711 is probably setup correctly.
  6. Now to calibration. Basically you have to use a known weight and adjust the values by a certain factor. I used my kitchen scale and two tetra packs of milk which weight 2.120kg. Put the same weight on the body scale, take the readings and use the result of the reading divided by the expected value as factor in set_scale(..). If that was confusing, check out the following pictures. Note: at a later stage you should repeat calibration with bigger weights than just two kilograms, e.g. your own weight. This should increase accuracy…
Uncalibrated output. You have to call the set_scale with the proper factor

Uncalibrated output. You have to call the set_scale with the proper factor (click to zoom)

 

Kitchen Scale with two tetra packs of 2.12kg as a calibration value

Kitchen Scale with two tetra packs of 2.12kg as a calibration value

 

Calibrated output. Now the serial monitor shows the correct values in kg

Calibrated output. Now the serial monitor shows the correct values in kg (click to zoom)

And now as a last step of the smoke test let’s use the OLED display to show the weight:

// change if your are using SSD1306
//#include <SSD1306Wire.h>
#include <SH1106Wire.h>
#include <OLEDDisplayFonts.h>
#include <HX711.h>


// Scale Settings
const int SCALE_DOUT_PIN = D2;
const int SCALE_SCK_PIN = D3;

// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c;
const int SDA_PIN = D6;
const int SDC_PIN = D7;

HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);

// change if your are using SSD1306
SH1106Wire        display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
//SSD1306Wire      display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);

void setup() {
  Serial.begin(115200);
  display.init();
  display.flipScreenVertically();
  scale.set_scale(-47941.0 / 2.122);
  scale.tare();
}

void loop() {
  String weight = String(scale.get_units(1), 2);
  Serial.println(weight);
  display.setFont(ArialMT_Plain_24);
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.clear();
  display.drawString(0, 0, weight);
  display.display();
}
Simple weight output on the OLED display. Smoke test successful!

Simple weight output on the OLED display. Smoke test successful!

If you see now a frequently updated number on the OLED display then: congratulations! You have successfully destroyed a working body scale, removed a lot of parts and put new ones in and it works again! (Why did we do this again!?!)

Optional: 3D Printed Parts

There is a saying: when you have a hammer, everything looks like a nail. Well, my current hammer is a Printrbot Play and I am constantly looking for justifications why I spent (only) 400 bucks on a useless machine (my wife thinks so;-)). It so happens that I found two “nails” for 3D printing in this project: The AA battery holder and the foot mounts. The battery holder will accommodate the LiFePo4 battery, while the foot mounts became necessary since there wasn’t enough space beneath the scale for the battery. The battery holder is a wonderful parametric OpenScad project from Thingiverse: http://www.thingiverse.com/thing:456900 Since I only had a single cell I parametrized the print accordingly. The foot mounts I designed myself in OpenScad using the measurements from a digital caliper.

3D printed AA battery holder for a single cell from Thingiverse (click to zoom)

3D printed AA battery holder for a single cell from Thingiverse (click to zoom)

 

3D printed foot mount

3D printed foot mount

 

Foot Mount designed in OpenScad

Foot Mount designed in OpenScad

 

Hot glued battery holder, foot mount and IKEA gliders on the bottom of the scale

Hot glued battery holder, foot mount and IKEA gliders at the bottom of the scale

Summary and Outlook

This was part 1 of the SmartScale write-up which explained you the hardware setup. After working through this article you now have hopefully a working but still pretty dumb body scale. In part 2 I will guide you through the software setup. If you don’t want to miss it please sign up for my Newsletter here. You will only ever receive emails related to my project:



A few features that the SmartScale will have:

  • Over-the-Air Update: Just turn on the body scale in the bathroom and deploy a new version of the software
  • Blynk App Integration: see wonderful historical statistics and live data on your smart phone
  • Change between Kilograms and Pounds through the Blynk App
  • Energy saving mode: turn off the HX711 and the NodeMCU after 5min of inactivity. This will not be perfect but better than burning through the battery as quickly as possible;-)
  • Displaying the Weather Forecast, so that you know which clothes to pick after the shower
  • Do simple settings by using the load cell as input device
image

Over-The-Air Update

image

Live and historical data on your Smartphone by using Blynk

image

Weather ForeCast download from the internet

image

Choose the user by carefully applying the correct weight on the scale

Read more Here







 

More Articles to Read

Design for a Wideband, Differential Transimpedance DAC Output
Design for a Wideband, Differential Transimpedance DAC Output
Wrist thrusters let you fly through the water effortlessly
Wrist thrusters let you fly through the water effortlessly
Bertan/Spellman 225-20R HV power supply teardown
Bertan/Spellman 225-20R HV power supply teardown
Blinking Christmas Lights
Blinking Christmas Lights
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adjusting clock with alarm, hygrometer & thermometer on 1.8″ ST7735 display
Adding an “extra sense” with rangefinders
Adding an “extra sense” with rangefinders
This wireless game controller looks like a rug
This wireless game controller looks like a rug
How to run your ESP8266 for years on a battery
How to run your ESP8266 for years on a battery
Calibration of a 3-Phase Energy Meter Board on the ADE7754
Calibration of a 3-Phase Energy Meter Board on the ADE7754
Making beats on a tiny Arduino DJ controller
Making beats on a tiny Arduino DJ controller
Qinsi-QS5100 Sn63Pb37 solder profile
Qinsi-QS5100 Sn63Pb37 solder profile
Water Detection System
Water Detection System
Professional Hi-Fi 15W Tube Amplifier circuit
Professional Hi-Fi 15W Tube Amplifier circuit
This Arduino machine will judge how sick your ollies are
This Arduino machine will judge how sick your ollies are
Turn an old payphone into a boombox for ’90s hits
Turn an old payphone into a boombox for ’90s hits
Big F’n 3D printer build
Big F’n 3D printer build
Temperature alarm for boiling milk
Temperature alarm for boiling milk
QuadBot is a 3D-printable walking robot for everyone
QuadBot is a 3D-printable walking robot for everyone
MicroConverter I2C Compatible Interface
MicroConverter I2C Compatible Interface
An Arduino tachometer for your older vehicle
An Arduino tachometer for your older vehicle

Top


Shares