Wi-Fi Body Scale with Arduino

By on November 13, 2012
Pin It

In this post we present the design of a scale that connects to the Internet and automatically sends weight info on a Google Document.

The project is composed of

 

Hardware

Taking a look at the diagram, we can distinguish three sections:

one for handling digital inputs (two buttons and scale’s switch),
the LCD manager
the analog signal acquisition from load cells


You may notice that P1 and P2 buttons are respectively managed by Arduino’s A3 and A4 inputs (configured as digital), while the INT switch reads the A5 signal (digital as well).

The LCD display used in our project belongs to the family of those based on HD44780 chipset, equipped with seven-pin control (RW, D4, D5, D6, D7, RS and Enable). As you can see from the diagram, RW is permanently connected to ground so it’s only operating in writing mode.

D4, D5, D6 and D7 pins are respectively managed by 3, 5, 6 and 7 digital pins of the Arduino Uno; RS is managed by pin 8 and the Enable pin from pin A0 (this configuration will also be specified in the software).

Besides the power supply (a VCC connected to 5V) and the ground (GND), the display requires a level of voltage between 0 and 5 volts to adjust the contrast in the input pin VO (adjustment made through R6 potentiometer).

Finally the display has 2 pin (A and K respectively anode and cathode) for switching on the backlight: feeding the pin with a voltage of 5V, the backlight is turned on, otherwise it is off.

The switching on and off is handled via a push-button switch that connects or disconnects the ground from the cathode.

Finally let’s analyze the part that manages the analog signal from the load cells: this is done by INA125 integrated component, a high precision amplifier developed specifically for measuring tools like scales.


The IC is fitted with two pins (6 and 7) representing the input of the differential amplification stage. These pins are connected to the two ends of the Wheatstone bridge (which in our project correspond to two of the load cell pins).

As you can figure out, the differential signal coming from the bridge has an absolute value of just a few millivolts: our project requires an amplification of about 500 times, obtained with a 120 ohm resistor.

The amplified output is provided at pins 10 and 11 of INA125; these pins are connected to A1 analog of the Arduino board, which therefore will be used for reading the value ADC.

[code]
R1: 39 ohm
R2: 1 kohm
R3: 4,7 kohm
R4: 4,7 kohm
R5: 330 ohm
R6: Trimmer 10 kohm
R7: 4,7 kohm

C1: 100 nF 63 VL
C2: 100 µF 25 VL

U1: INA125

P1: Microswitch
P2: Microswitch

LCD: Display LCD 8×2

[/code]

 

Hacking  the Velleman scale

Our system is designed to be matched to the high-capacity scale produced by Velleman. But you can using any scale usign 4 load cells. The original Velleman electronics and display must be phased out and replaced with our project.

The scale structure is made up of 4 load cells (arranged on the 4 corners), which are configured between them so as to create a single Wheatstone bridge.

To make the connection to our board you must disassemble the lower section of the scale in order to access the electronics.

Referring to Fig A, which shows the structure of the scale viewed from below, with a quick visual analysis is easy to figure out that some blue and red wires are connected to each other while the yellow wires are connected to the switches positioned on the front of the two cells that identify the presence of a person.


To hack the scale follow these steps:


  • unsolder or cut all the red and blue wires, push in short those that were already shorted previously,

  • unsolder or cut the yellow wires coming from the cells numbered 1 and 3, put them in parallel (possibly by welding), extend them and take them to the two terminals on the new INT printed board (Fig.B)

  • unsolder or cut the white wire that is referred to as G3 (Wheatstone bridge mass) on the original printed circuit, extend take it to terminal 1 on the new printed circuit;

  • unsolder or cut the white wire that is referred to as G2 (Wheatstone bridge positive) on the original printed circuit, extend take it to terminal 3 on the new printed circuit;

  • unsolder or cut the white wire that is referred to as G1 and G4 on the original printed circuit, extend take it to terminal 4 and 2 on the new printed circuit (differential signal on the Wheatstone bridge)

 


The Sketch

As for the LCD, Arduino provides a convenient library (<LiquidCrystal.h>) already supporting different kinds of LCD (both 8 and 16 chars for 2 lines) based on the parallel interface chipset HD44780.

After the inclusion of the library, you must initialize the connection to the display, through LiquidCrystal LCDDisplay (8, A0, 3, 5, 6, 7), in this command, the parameters passed to the function and indicate Arduino’s hardware pins used to connect RS, Enable, D4, D5, D6 and D7 pins of the display.

Depending on the Arduino setup could be necessary to execute LCDDisplay.begin (width, height) in which the parameters indicate the physical dimensions of the display: LCDDisplay.begin (8, 2) in this case.

The library makes available instructions:

  • LCDDisplay.setCursor (x, y) to position the cursor in a certain position
  • LCDDisplay.print (String) to print strings


Management of Arduino’s EEPROM is done by the <EEPROM.h> library  that, once included, provides the functions:


  • EEPROM.write (add, date) to write a byte in a particular cell and

  • EEPROM.read (add) that the instead reads a byte from one cell (the add parameter specifies the address of the EEPROM cell).


Wi-Fi network and internet connection are managed thanks to the <WiServer.h> library; you just need to define some variables to configure the network (like IP’s and Network masks).


The adapter to connect and publish data on Google Documents shall operate as a Web Client: this configuration is done in the setup instruction WiServer.init (NULL) in which the NULL parameter specifies client mode.


You must create a function that will receive and handle the response from the server, this is done by the googlePublish.setReturnFunc  (Gestione_Risposte_Web) instruction  in our example. This function must be defined later in the code: in our example is void Gestione_Risposte_Web (char * data, int len) and receives as parameters both a pointer to a string containing the response and the length (in bytes) of the response.


Sending information requires to make a POST request to Google’s servers: WiServer library makes available a POSTrequest just to do this.


You must define the IP address of the server to which you want to connect (Google in our case) and define a structure of the POSTrequest (in our case, the variable is called googlePublish) containing the IP address of the server, the TCP / IP port the server name (spreadsheets.google.com), URL of POST execution and finally a function (SearchQuery in our case) that builds POST request body.

 

 

Install the WiShield libraries


To work properly, the Wifi shield requires specific libraries that must be installed in the Arduino IDE used to compile the sources so you’ll need to put these libraries in the Arduino libraries path.


The library supports multiple operating modes (APP_WEBSERVER, APP_WEBCLIENT, APP_SOCKAPP, APP_UDPAPP and APP_WISERVER).

The default value is APP_WEBSERVER, which runs on most Arduino systems but has several limitations. The main limitation is that it can’t function both as a client and server simultaneously.


It is therefore recommended the APP_WISERVER (in the library named “WiServer.h“) which allows the Arduino shield equipped with Wi-Fi to be configured and operated either as a Web Server as a Web Client.


In the first case, you can serve connection requests from external web clients and send HTML pages in response, in the second it will be possible to connect to a web server and send GET or POST requests.


To configure the WiShield library as APP_WISERVER you must open the apps-conf.h file, comment the “#define” APP_WEBSERVER row and uncomment the “#define” of APP_WISERVER row.


Something like:


/ / # define APP_WEBSERVER

/ / # define APP_WEBCLIENT

/ / # define APP_SOCKAPP

/ / # define APP_UDPAPP

# defineAPP_WISERVER


Configuring publishing

Performing data publication on Google Documents requires three distinct steps:


  1. Configuring Wi-Fi network access;
  2. Creating a Google Docs form module: each module is characterized by an identifying 34 characters string – FormKey) and each field is characterized by an identification number (called Entry).
  3. Inserting the FormKey / Entry in the Arduino software.



Configuring network parameters

First you must configure and update the IP address, Subnet Mask, Gateway IP and Network SSID, then select the encryption mode and change password information for your network. Save all, compile and run the upload Software tab.

Creating the Google  module doc

Create a form on Google Docs, modify the form with two fields (username and weight, both of type string) and save the job. (the result is something like the one shown in Figure). In our case, we left the default file name and called the two fields “User Name” and “User weight”

take note of this key string because then it will be inserted in the Arduino software: as you can see from the picture, the link shows the form key assigned to the module (in this example, the link is: https://docs.google.com/spreadsheet/viewform?formkey=dDFPcWhxNlZxMEpnUnhNdE5fT1lDcWc6MQ which implies that the form assigned key is “dDFPcWhxNlZxMEpnUnhNdE5fT1lDcWc6MQ”);

 

Clicking on the link will open a new page that shows the data entry form: within this form text fields are marked with “entry.0.single“, “entry.1.single“, etc … (basically with an integer id)

 To see which number has been assigned to our fields you need to display the HTML source of the form (the result is something like the one shown in this Figure).

You can easily find the ID numbers assigned to different fields (in our example “entry.0.single” is the “Name” and “entry.1.single” is the “weight“).

Take note of this information because it will be included in the source Arduino as well.

Formkey / entry

Once you have created the form, the Arduino source will be configured so that it is compatible with the form you created.

A variable is defined in Arduino source named newURL[]: the variable is initialized with a standard format then modified to perform publication (refer to Figure 11 to identify it in the code).


Replace the default values with those obtained at the time of the creation of the form, compile and download it to the Arduino board.

 

 

 

How to program user names

The configuration of user names can be made via serial port and Serial Monitor. To program it, connect to the board (via USB cable) and open the Arduino Serial Monitor. As a first step the card sends a summary of the current configuration.


To program a new user name you must send a string in the format “P_USER_NAME_xx = User Name” with xx between 01 and 10 ID (put an empty string to delete the selected user.) If all the posted information is correct, this is confirmed by the message “Ok” otherwise “Fault”.

 

Using the scale


The scale software is able to distinguish up to 10 users (each identified by its name) and, for each one, it stores the last measured weight.


If you want to clear the memory (which we recommend at first use) is sufficient to hold down either of the two buttons (the display indicates the operation with “EEP init in progress”).

Later, you can configure names following the procedure described in the “Programming user names” section.


As the next step the Web management interface will start and the system will enter its normal operation. The user selection is done by pressing button P1.


Going over the scale starts the weighing procedure (lasting several seconds): weight is displayed and stored and the scale asks for publishing on the web: by pressing P2 the operation is performed.

About Boris Landoni

Boris Landoni is the technical manager of Open-Electronics.org. Skilled in the GSM field, embraces the Open Source philosophy and its projects are available to the community.
  • Andy

    What language was the code written in?

    • gcarpenterv

      Arduinos run C++.

    • BorisLandoni

      The shield WiFi is plugin for Arduino.
      Arduino.cc

      • e

        hey Boris i bought a scale i ope it an does not have the blue cables can you send me a diagram on how to hack it
        enriquemorquecho@hotmail.com

        • BorisLandoni

          Hi,
          we used a Vellaman scale, not all scale have the same cables colors. I suggest you to refer to the diagram

  • Pingback: Electronics-Lab.com Blog » Wi-Fi Body Scale with Arduino()

  • Frank

    Great article! How did you come to the conclusion that the analog signal required an amplification of 500 times?

    • BorisLandoni

      I tested it :-)

  • ivdechev

    Hi,
    is it possible the system you have described here to measure the weight on the scale in every 5 seconds and send data to MySQL database.

    • BorisLandoni

      Yes of course, you can modify the sketch

      • ivdechev

        Can you just mention the parts of the sketch I have to modify. It is difficult to me to find them as your comments are not in English. Thank you in advance.

        • BorisLandoni

          “You must create a function that will receive and handle the response from the server, this is done by the googlePublish.setReturnFunc (Gestione_Risposte_Web) instruction in our example. This function must be defined later in the code: in our example is void Gestione_Risposte_Web (char * data, int len) and receives as parameters both a pointer to a string containing the response and the length (in bytes) of the response.” you have to call this function when you need.

  • Amazing work, i have a question can i use a 7 segment led display? i find those easier to read. Or maybe a LoL shield that i founded in adafruit website? thanks

  • Pingback: Arduino | Pearltrees()

  • Pingback: Wi-Fi Body Scale with Arduino | Arduino progz | Scoop.it()

  • Pingback: Wi-Fi Body Scale with Arduino | Projet TS1 Chinon | Scoop.it()

  • huuubert

    Hi! This article rocks!

    My wires load cells don’t have the same color as your velleman model. For the INT switch, no problem, I found the wires easily. But for the others wires, I’m lost! The 2 load cells in the back are: Red, White, Black wires. The 2 others near the LCD are : Green, Blue, Yellow. Hope this description will be sufficient to help me.

    Moreover, will I have to change R1 & R2 values as the load cells are not the same as you ?

    Cheers.

    • BorisLandoni

      Hi, the boby scale normaly use 4 half load cells, and 2 half load cells are connected to have one half cell.
      I’m sorry but I don’t know all body scale in the market :-D

  • Alesh

    Greate article, is it posibble to rewrite the sketch in English? Would you be so kind to update it? I would like to order the scale shield, but without understanding the sketch I am a bit stucked.

    • BorisLandoni

      I’m sorry,

      this sketch have some part in italian language.

      But I think the functionality is understandable

  • nesnduma

    It’s strange because the cable’s colors for sensors are not the same on the picture of the opened but unmodified scale and the picture with the hacked scale. Have you worked with several scales ?

    • BorisLandoni

      As can be seen from the figures, the cables were too short and had them stretched

  • Greg

    Boris, great project. If you used your own wheatstone bridge, any ideas on how this could be used to calibrate zero and span? Any ideas on how to retain calibration data after power cycling?

    • BorisLandoni

      The result from bridge is elaborated from the sketch.

      • Greg

        Thanks! I should have looked for “calibrazione”.

  • wwahhabi

    Hi @BorisLandoni:disqus,
    I am a french student and I am preparing a challenge. I want to know more about your futuristic scale. Can you please contact me on my e-mail : wahhabi.wissam@gmail.com
    See you soon !

    • BorisLandoni

      Hi use contacts form ;-)

  • Pingback: pocket #2: programowanie MSP430 z Launchpad, AVR (bez IDE) z Arduino, zegarek LED i elektroniczna waga WIFI | kabelkowo.pl()

  • morquehco

    Boris: to what diagram i need to make refrence to?

    my scale has not the same colors

    • BorisLandoni

      Yes could be. But all scale use half cell load. I’m sorry but I can’t give you the color

  • simf

    Hi Boris,

    Great shield – nicely polished.
    I have a similar set of scales fed into an INA 125p. Similar set-up to yours minus the capacitors, R2 and a different value for R1.
    I am using the original wheatstone bridge (green circuit in pic 1) and have discarded the rest of the circuit.
    Using this code:http://www.instructables.com/id/Arduino-Load-Cell-Scale/step3/The-Code/
    I do not get any response from force on the scale.
    Can I get your trouble shooting advice?
    Also,a few questions:
    1) How do you power your scales? external? 5v? I’m getting the excitation voltage from the Arduino
    2) Is it best to make the wheatstone bridge rather than using the one I’ve broken off the board?
    3) How would you map the wire colours from yours to pic 2? red=red, green=your blue, black = your white?
    4) Also, I’m not sure what you mean by load cell 1 and 3, and G1, G2, G3, G4. Did I miss a diagram?

  • Guest

    Smaller pictures.

    Is there an admin that can you delete the others?

  • simf

    Hi Boris,

    Great shield – nicely polished.
    I have a similar set of scales fed into an INA 125p. Similar set-up to yours minus the capacitors, R2 and a different value for R1.
    I am using the original wheatstone bridge (green circuit in pic 1) and have discarded the rest of the circuit.
    Using this code:http://www.instructables.com/id/Arduino-Load-Cell-Scale/step3/The-Code/
    I do not get any response from force on the scale.
    Can I get your trouble shooting advice?
    Also,a few questions:
    1) How do you power your scales? external? 5v? I’m getting the excitation voltage from the Arduino
    2) Is it best to make the wheatstone bridge rather than using the one I’ve broken off the board?
    3) How would you map the wire colours from yours to pic 2? red=red, green=your blue, black = your white?
    4) Also, I’m not sure what you mean by load cell 1 and 3, and G1, G2, G3, G4. Did I miss a diagram?

    • BorisLandoni

      1) The original Velleman electronics and display must be phased out and replaced with our project.
      2) we are using the shield
      3)the cells 1 and 3 are the front cells (near the original display)

      4)G1, G2 acc.. are the name in our scale, probably you have a different name

      5)https://store.open-electronics.org/index.php?_route_=Arduino/Shield/Weight_shield

      • simf

        Thanks Boris, I will order one for testing.

        I have managed to get another in-amp to work (AD623) but not the INA125p.
        Again, great work with this.
        simf

      • Joy

        I want to buy this shield.

        I have got a 4 sensors digital scale from store but can you please guide me how to connect it with your shield? Above diagram isn’t clear enough.

        Thanks Joy

  • simf

    Hmm. Seems like my posting went wrong – it’s posted both as guest and as my user name ‘simf’.
    Please delete this post and the other two guest posts.

  • pyfi12

    Hi, where can I buy all the components for this project? Namely the two shells. Thanks!

  • Sam

    Hey there!

    I am trying to do a similar project but with the readings being written to an sd card shield. How might I connect the wires (G1, G2,G3, G4) to an HX711 unit correctly?

    Any help is greatly appreciated. Thanks!