In this project we will make an IOT Based Weighing Scale with HX711 Module Load Cell & NodeMCU ESP8266. The load cell will be capable of measuring any weight up to 40KG. We will display the measured weight in Blynk Application and also monitor the weight data remotely on Thingspeak Server.
Overview
In this IoT Project we are interfacing 40Kg load cell to the NodeMCU ESP8266 using the HX711 Load cell amplifier module. HX711 is a precision 24-bit analog to digital converter (ADC) designed for weighing scales and industrial control applications to interface directly with a bridge sensor. The HX711 load cell amplifier is used to get measurable data out from a load cell and strain gauge.
The electronic weighing machine uses a load cell to measure the weight produced by the load, here most load cells are following the method of a strain gauge, Which converts the pressure (force) into an electrical signal, these load cells have four strain gauges that are hooked up in a Wheatstone bridge formation.
We will make a Weighing Scale Machine which can measure weights up to higher-value like 40KG. We need to calibrate the load cell and find the calibration factor. Once the calibration is done, we can include that factor in our code. Thus this will make the scale precise and accurate. The greater is the mass the greater the error. So we will try to remove the error from the weighing scale. We will finally display the measured weight in the 16×2 I2C LCD Display. We will send the so obtained weight value on the IoT Cloud platform called Blynk Application. Thus, weight can be monitored from any part of the world simply by observation on the Blynk app dashboard. We will also send the data on another IoT platform called Thingspeak. The graphical and numerical analysis of weight will be done in Thingspeak.
You can follow our previous post in case you want to make a Simple Weight Measuring Scale.
1. Low-Value Weight Measurement upto 10 KG: Check Here
2. High-Value Weight Measurement upto 40 KG: Check Here
Bill of Materials
Following are the components required for this IoT Weighing Scale Project. All the components can be easily purchased from Amazon. The component purchase link is given below.
| S.N. | Components Name | Quantity | Purchase Links |
|---|---|---|---|
| 1 | NodeMCU ESP8266 | 1 | Amazon | AliExpress |
| 2 | 16x2 LCD Display | 1 | Amazon | AliExpress |
| 3 | Load Cell | 1 | Amazon | AliExpress |
| 4 | HX711 | 1 | Amazon | AliExpress |
| 5 | Push Button | 1 | Amazon | AliExpress |
| 6 | Connecting Wires | 10 | Amazon | AliExpress |
| 7 | Breadboard | 1 | Amazon | AliExpress |
Load Cell
A load cell is a type of transducer, specifically a force transducer. It converts a force such as tension, compression, pressure, or torque into an electrical signal that can be measured and standardized. As the force applied to the load cell increases, the electrical signal changes proportionally. Load cells are used to measure weight.
Load cells generally consist of a spring element on which strain gauges have been placed. The spring element is usually made of steel or aluminum. That means it is very sturdy, but also minimally elastic. As the name “spring element” suggests, the steel is slightly deformed under load, but then returns to its starting position, responding elastically to every load. These extremely small changes can be acquired with strain gauges. Then finally the deformation of the strain gauge is interpreted by analysis electronics to determine the weight.
HX711 Module
The HX711 Dual-Channel 24 Bit Precision A/D weight Pressure Sensor Load Cell Amplifier and ADC Module is a small breakout board for the HX711 IC that allows you to easily read load cells to measure weight. By connecting the module to your microcontroller you will be able to read the changes in the resistance of the load cell and with some calibration. You’ll be able to get very accurate weight measurements.
This can be handy for creating your own industrial scale, process control, or simple presence detection. The HX711 Weighing Sensor uses a two-wire interface (Clock and Data) for communication. Any microcontroller’s GPIO pins should work making it easy to read data from the HX711.
Each color corresponds to the conventional color coding of load cells :
1. Red (Excitation+ or VCC).
2. Black (Excitation- or GND).
3. White (Amplifier+, Signal+, or Output+).
4. Green (A-, S-, or O-).
5. Yellow (Shield).
The YLW pin acts as an optional input that not hook up to the strain gauge but is utilized to ground and shield against outside EMI (electromagnetic interference).
Base Design & Connections
Load Cell and HX711 Connection:
|
1 2 3 4 |
- RED Wire is connected to E+ - BLACK Wire is connected to E- - WHITE Wire is connected to A- - GREEN Wire is connected to A+ |
Load Cell Assembly on Base:
A base is also required to fix the load cell over it by using nuts and bolts. Here we have used a hard plyboard for the frame for placing things over it and a light wooden board as Base. This is required as load cell bends slightly when some weight is placed over it.
Circuit: IOT Weighing Scale with HX711 Load Cell & ESP8266
Here is a circuit diagram for interfacing 40KG Load Cell and HX711 Module with NodeMCU ESP8266 12E Board. You can follow the same circuit here and make your own Weighing Scale.
The connection between Load Cell & HX711 has been explained above. Connect the DT & SCK Pins of Load Cell to ESP8266 D5 & D6 Pins respectively. I have used a push-button tact switch to reset the weight to zero. Push-button Switch is a connected digital pin D4 of ESP8266. I used a 16X2 I2C LCD Display to minimize the connection. So, connect the SDA & SCL pin of I2C LCD Display to D2 & D1 of Nodemcu respectively.
Project PCB Gerber File & PCB Ordering Online
If you don’t want to assemble the circuit on breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for the IoT Based Weighing Scale is designed using EasyEDA online Circuit Schematics & PCB designing tool. The front side and back side of the PCB is given below.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.
You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
Setting Up Blynk IoT Application for Remote Weight Monitoring
Blynk is an application that runs over Android and IOS devices to control any IoT based application using Smartphones. It allows you to create your Graphical user interface for IoT application. Here we will set up the Blynk application to monitor Measured Weight over Wi-Fi using NodeMCU ESP8266.
So download and install the Blynk Application from Google Play store. IOS users can download from the App Store. Once the installation is completed, open the app & sign-up using your Email id and Password.
Now follow the photos below to setup the complete Blynk application.
So create gauge and value display. After the successful creation of the Project, go back to setting and click on Send Email. You will get an Authenticate ID on registered mail. Save the Authenticate ID. You will need to enter this on code.
Source Code/Program to Calibrate the Load Cell
After connecting the load cell as above, you need to calibrate it first before going for the final design. So first calibrate the whole assembly unit. You will need add HX711 library to make the code compile. Download HX711 Library from below.
You will need other libraries related to Blynk as well for compiling the final code below. So download and add the libraries from below.
1. Blynk ESP8266 Library
2. Liquid Crystal I2C Library
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#include "HX711.h" //You must have this library in your arduino library folder #define DOUT D5 #define CLK D6 HX711 scale(DOUT, CLK); //Change this calibration factor as per your load cell once it is found you many need to vary it in thousands float calibration_factor = -109525; //-106600 worked for my 40Kg max scale setup //============================================================================================= // SETUP //============================================================================================= void setup() { Serial.begin(9600); Serial.println("HX711 Calibration"); Serial.println("Remove all weight from scale"); Serial.println("After readings begin, place known weight on scale"); Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively"); Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively"); Serial.println("Press t for tare"); scale.set_scale(); scale.tare(); //Reset the scale to 0 long zero_factor = scale.read_average(); //Get a baseline reading Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects. Serial.println(zero_factor); } //============================================================================================= // LOOP //============================================================================================= void loop() { scale.set_scale(calibration_factor); //Adjust to this calibration factor Serial.print("Reading: "); Serial.print(scale.get_units(), 3); Serial.print(" kg"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person Serial.print(" calibration_factor: "); Serial.print(calibration_factor); Serial.println(); if(Serial.available()) { char temp = Serial.read(); if(temp == '+' || temp == 'a') calibration_factor += 10; else if(temp == '-' || temp == 'z') calibration_factor -= 10; else if(temp == 's') calibration_factor += 100; else if(temp == 'x') calibration_factor -= 100; else if(temp == 'd') calibration_factor += 1000; else if(temp == 'c') calibration_factor -= 1000; else if(temp == 'f') calibration_factor += 10000; else if(temp == 'v') calibration_factor -= 10000; else if(temp == 't') scale.tare(); //Reset the scale to zero } } |
Once you upload the calibration code, open the serial monitor and adjust your scale factor with known weight until you see the correct readings. Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively. Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively.
Once you see the placed weight is the same as shown weight note down the calibration factor and use it in the final code for Weighing Scale.
Source Code: IOT Weighing Scale with HX711 Load Cell & ESP8266 on Blynk
Once you find the calibration factor update it in below code. Then you can simply upload the code and hence your IoT Weighing Scale is ready.
Make sure to change WiFi SSID, Password & Blynk Authenticate Code on the code as well.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
#include <ESP8266WiFi.h> #include "HX711.h" #define BLYNK_PRINT Serial #include <Blynk.h> #include <BlynkSimpleEsp8266.h> #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); #define BLYNK_PRINT Serial const char *ssid = "Alexahome"; // replace with your wifi ssid and wpa2 key const char *pass = "12345678"; char auth[] = "hePTG-hzhuAzU2h59R90SjQUc98u2Kpb"; // You should get Auth Token in the Blynk App. WiFiClient client; HX711 scale(D5, D6); int rbutton = D4; // this button will be used to reset the scale to 0. float weight; float calibration_factor = -101525; // for me this vlaue works just perfect 419640 void setup() { Serial.begin(115200); pinMode(rbutton, INPUT_PULLUP); scale.set_scale(); scale.tare(); //Reset the scale to 0 long zero_factor = scale.read_average(); //Get a baseline reading Blynk.begin(auth, ssid, pass); Wire.begin(D2, D1); lcd.begin(); lcd.setCursor(6,0); lcd.print("IOT"); lcd.setCursor(1,1); lcd.print("Weighing Scale"); delay(3000); lcd.clear(); lcd.print("Connecting Wifi"); WiFi.begin(ssid, pass); { delay(1000); Serial.print("."); lcd.clear(); } Serial.println(""); Serial.println("WiFi connected"); lcd.clear(); lcd.print("WiFi connected"); delay(2000); } void loop() { Blynk.run(); scale.set_scale(calibration_factor); //Adjust to this calibration factor weight = scale.get_units(5); lcd.setCursor(0, 0); lcd.print("Measured Weight"); lcd.setCursor(0, 1); lcd.print(weight); lcd.print(" KG "); Blynk.virtualWrite(V3, weight); delay(2000); lcd.clear(); Serial.print("Weight: "); Serial.print(weight); Serial.println(" KG"); Serial.println(); if ( digitalRead(rbutton) == LOW) { scale.set_scale(); scale.tare(); //Reset the scale to 0 } } |
Results & Observations
When no weights are placed the Display will show the weight almost equal to zero.
When some weights are placed the Display will show the weight almost equal to the weight of the object.
Now you can power on your Blynk Application and you will see the changes in weight parameters both in label display as well as gauge.
Source Code: IOT Weighing Scale with HX711 Load Cell & ESP8266 on Thingspeak
Similarly if you want to monitor the weight online on Thingspeak platform you can use the code below.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
#include "HX711.h" #include <ESP8266WiFi.h>; #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); String apiKey = "3DHYLTJBZOF4DFTO"; // Enter your Write API key from ThingSpeak const char *ssid = "BYNARK"; // replace with your wifi ssid and wpa2 key const char *pass = "bynark@123"; const char* server = "api.thingspeak.com"; WiFiClient client; HX711 scale(D5, D6); int rbutton = D4; // this button will be used to reset the scale to 0. float weight; float calibration_factor = -101525; // for me this vlaue works just perfect 419640 void setup() { Serial.begin(115200); pinMode(rbutton, INPUT_PULLUP); scale.set_scale(); scale.tare(); //Reset the scale to 0 long zero_factor = scale.read_average(); //Get a baseline reading Wire.begin(D2, D1); lcd.begin(); lcd.setCursor(6,0); lcd.print("IOT"); lcd.setCursor(1,1); lcd.print("Weighing Scale"); delay(3000); lcd.clear(); lcd.print("Connecting Wifi"); lcd.setCursor(0,1); lcd.print("& Thingspeak"); WiFi.begin(ssid, pass); { delay(500); Serial.print("."); lcd.clear(); } Serial.println(""); Serial.println("WiFi connected"); lcd.clear(); lcd.print("WiFi connected"); delay(3000); } void loop() { scale.set_scale(calibration_factor); //Adjust to this calibration factor weight = scale.get_units(5); lcd.setCursor(0, 0); lcd.print("Measured Weight"); lcd.setCursor(0, 1); lcd.print(weight); lcd.print(" KG "); delay(1500); lcd.clear(); Serial.print("Weight: "); Serial.print(weight); Serial.println(" KG"); Serial.println(); if ( digitalRead(rbutton) == LOW) { scale.set_scale(); scale.tare(); //Reset the scale to 0 } if (client.connect(server, 80)) // "184.106.153.149" or api.thingspeak.com { String postStr = apiKey; postStr +="&field1="; postStr += String(weight); postStr += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); } client.stop(); Serial.println("Waiting..."); //delay(1500); // thingspeak needs minimum 15 sec delay between updates. } |
After uploading code with correct API key, you can monitor the data online on Thingspeak.























21 Comments
I need to know where to dump the code, is it in the blynk application?
No.
Its in nodemcu
I need to know that how to do this without having the push button switch because due to this crisis situation we are not allowed to go out. I’ve other equipment except push button switch. Is it possible? If yes please help!
Thanks in advance!
Use any wire,and connect one end to the gpio pin. Leave other end unconnected. Whenever you want to reset, connect the other end of wire to gnd for 1-2 seconds. It will reset.
GPIO pin? where?
See the push button end connected to one of the pin of nodemcu. Same pin
Thank you! means a lot!
i have done all connections… -99109525 this is the calibration factor which i am getting.. now after calibration it shows -0.001 kg in serial monitor… after that i am not getting what to do.
and also i think i am not getting readings from load cell still i am using a 40 kg load cell
please help me out
Hi,
Can I use this Blynk application on more than one android device to watch the weight (load cell) ?
“D5” was not declared ???? … was the message after compiling. i make a copy of the code, but there is always the message for a mistake
#include “HX711.h”
#include ;
#include
#include
LiquidCrystal_I2C lcd(0x27, 16, 2);
String apiKey = “3DHYLTJBZOF4DFTO”; // Enter your Write API key from ThingSpeak
const char ssid = “BYNARK”; // replace with your wifi ssid and wpa2 key
const char *pass = “bynark@123”;
const char server = “api.thingspeak.com”;
WiFiClient client;
HX711 scale(D5, D6);
i also get like that
D5 in not declared
hi,
i need help with this error message ” no matching function for call to ‘HX711::HX711(const uint8_t&, const uint8_t&)’ “
es en la aprte de codigo hx711 scala el codigo esta asi:
Escala HX711 (D5, D6);
intente asi:
byte DOUT=D6;
byte CLK=D5;
HX711 escala;
void setup{
escala.begin(DOUT, CLK);
}
saludos
Hi Axel,
Can you help me with the code for replacing the Blyk App, to display weight on PHP website, I want to use NodeMcu Wifi to do so.
Regards,
Kaushik
I have installed Hx711 library properly still gives fatal error: HX711.h: No such file or directory please help
сдравствуйте отличный проект.а как добавить датчик bme280 в скетч и возможность сбросить весы с приложения?
awesome, i got this weight sensor from a defect scale
hi i want to know if this code will work on 4 load cell and also how to wire them thanks
hello…i have made connections and used code in arduino IDE the same way shown..but for the callibration code, my serial monitor is returning garbage value. i have checked the baud rate and connections. yet no solution. please help….
Mr. Alam!
Thank you for this project, is usefull, working like a charm,but I have a problem….when restart.
Can you help me,with a code with eeprom, because when the scale is restart, and on scale have something(eg: a beehive), the scale start with zero. So, I like to save the tare in eeprom, but I!m newbye, and I don’t know how… Thank you for your time!
Soft WDT reset
Exception (4):
epc1=0x4010057c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
need help