IoT Weighing Scale using Load cell HX711, ESP32, & New Blynk V2.0
Table of Contents
IoT Weighing Scale:
IoT Weighing Scale using Load cell HX711,ESP32, & New Blynk V2.0- In today’s article, you will learn how to make an IoT based digital weighing scale using ESP32 WiFi + Bluetooth module, HX711 amplifier board, a load cell, and the new Blynk V2.0.
Arduino and ESP32 are completely different controller boards. Arduino is a 5V compatible controller board while the ESP32 WiFi + Bluetooth module is a 3.3V compatible controller board. And this is the reason, the calibration value of the HX711 and Load cell that works with the Arduino doesn’t work with the ESP32 Controller board. For ESP32 we will need to repeat the same calibration procedure again and we will also need to reduce the speed of the ESP32 module. With this IoT weighing Scale you can monitor the values from any part of the world.
Previously, I used the same HX711 amplifier board and the same 5Kg Load cell with the Arduino and explained the most basic things including, the mechanical setup, Load cell working mechanism, HX711 amplifier board technical specifications and its interfacing with Arduino, how to calibrate the HX711, and its programming. I highly recommend, read my article on the Arduino Weighing Scale.
I am going to continue with the same setup, but it’s not compulsory, you can also get your Load cell fixed on a wooden sheet and it doesn’t matter if you have a 5Kg or 10Kg or any other load cell because the method I am going to explain can be implemented on similar load cells and HX711 amplifier boards.
Anyway, while fixing the Load cell, pay close attention to the Arrow head, it should be pointing in the downward direction.
You can use any of these HX711 amplifier boards as both modules have got the same pinouts. The only difference is in their size. So, without any further delay let’s get started!!!
Amazon Links:
ESP32 WiFi + Bluetooth Module(Recommended)
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
HX711 Load Cell interfacing with Arduino:
Connect the Red and Black wires of the Load cell to the HX711 amplifier board E+ and E-.
Connect the White and Green wires of the Load cell to the HX711 Amplifier board A- and A+ respectively.
Connect the VCC and GND pins of the HX711 board to the ESP32 3.3V and GND.
Connect the SCK and DT pins to the ESP32 pins 19 and 23.
ESP32 Board installation in the Arduino IDE:
If this is your first time using the ESP32 WiFi + Bluetooth, then first of all, you will need to install the ESP32 board in the Arduino IDE. You can also confirm this by going to the Tools Menu > then Board.
You can clearly see, the ESP32 board is not available in the list.
In order to program the ESP32 board using the Arduino IDE, first we need to install it. For this open my article on the ESP32 Arduino IDE Board Manager Installation. Scroll down and copy this link.
Go back to the Arduino IDE. Now, go to the File Menu > then to Preferences, and paste the URL link in the Additional Boards manager URLs.
Next, go to the Tools Menu, then to Board and click on the Boards Manager. Search for the ESP32.
While the latest version is selected click on the Install button and that’s it. It may take several minutes depending on the internet speed on your side. Anyway, once the installation is completed then you can go to the boards list to check if the ESP32 board has been installed.
If you can see ESP32 then it means you have done everything correctly.
Blynk Library Installation:
Next, we will install the Blynk Library. For this go to the sketch menu > then to Include Library > and click on the Manage Libraries.
Search for the Blynk and install it.
As you can see on my side its already installed.
HX711 Library:
While the Arduino IDE is open, go to the Sketch Menu > then to Include Library > and click on the Add .ZIP Library.
Browse to the location and select this zip folder.
And click the Open button.
The ESP32 board and all the required libraries have been installed; so, now we can start with the Blynk Web Dashboard and Blynk IoT application.
Blynk Web Dashboard Setup:
Open the Blynk web and click on the New Template
Write the Project name, select the hardware, and connection type. If you want you can also add a short description. After entering all the required details then click on the Done Button.
The home page will open for creating the Web dashboard. You can see the project name “IoT weighing Scale”.
Now click on the Datastreams > then click on the New Datastreams, and select the virtual pin
Then enter the Virtual pin Datastream details and click on the Create button. The max value is 5 because, the Load Cell I am using can measure maximum weights up to 5Kg.
After that click on the + New Datastream and select Virtual Pin. If you don’t want to add another Virtual Pin then you can skip this step. And if you want to add multiple Virtual Pins then you can create new virtual Pins by clicking on the + New Datastream. In my case I need another virtual pin.
Add the required details for the Virtual Pin.
Now the two virtual pins DataStream are created. Next, click Web Dashboard.
Then double click on the Gauge to add it to the Canvas or simply drag and drop.
Then click on the Gauge setting by clicking on the Gear icon.
Enter the Title and select the desired virtual pin and click on the save button.
The same way add label to the Canvas.
Follow the same steps. Enter the title, choose the Datastream, and finally click on the Save Button.
The two gauges are created for displaying the Weight values.
Skip the Automation, Metadata, Events tabs as these are not required in our project and click on the save button.
Click on the search.
Click on the new device.
Click on the from template.
Then choose the template and click on the Create button.
Then copy the New device Created! Credentials as you can see on the left side.
Paste these credentials in the code.
IoT Weighing Scale ESP32 Programming:
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 |
#define BLYNK_TEMPLATE_ID "TMPL6ZZGzftK4" #define BLYNK_TEMPLATE_NAME "IoT weighing Scale" #define BLYNK_AUTH_TOKEN "LS2SQqduYW3i-tW-OeT-cg4IG16XCtG2" #include <WiFi.h> #include <WiFiClient.h> #include <BlynkSimpleEsp32.h> #include "HX711.h" #define DOUT 23 #define CLK 19 HX711 scale(DOUT, CLK); // Comment this out to disable prints and save space #define BLYNK_PRINT Serial char auth[] = BLYNK_AUTH_TOKEN; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "AndroidAP3DEC"; char pass[] = "electroniclinic"; float weight; float calibration_factor = 211000; // for me this vlaue works just perfect 211000 void setup() { // Set up serial monitor Serial.begin(115200); Serial.println("HX711 calibration sketch"); Serial.println("Remove all weight from scale"); Serial.println("After readings begin, place known weight on scale"); Serial.println("Press + or a to increase calibration factor"); Serial.println("Press - or z to decrease calibration factor"); 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); Blynk.begin(auth, ssid, pass); } void loop() { Blynk.run(); measureweight(); } void measureweight(){ scale.set_scale(calibration_factor); //Adjust to this calibration factor Serial.print("Reading: "); weight = scale.get_units(5); if(weight<0) { weight=0.00; } //Serial.print(scale.get_units(), 2); // Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person Serial.print("Kilogram:"); Serial.print( weight); Serial.print(" Kg"); Serial.print(" calibration_factor: "); Serial.print(calibration_factor); Serial.println(); Blynk.virtualWrite(V0,weight); Blynk.virtualWrite(V1,weight); // Delay before repeating measurement delay(100); } |
Select the ESP32 Dev Module and the communication port, and finally, click on the Upload button M.ake sure you change the ssid and password. Anyway, once the program is uploaded, go back to your Blynk Web Dashboard, apply some force on the Load cell and you will see the weight value.
So, far everything is working. Now, let’s set up the Blynk IoT application.
IoT Weighing Scale Blynk application:
Open the Blynk IoT Application.
Then click on the IoT Weighing Scale.
Then click on the settings button.
Developer mode will open.
Then click on the add button to insert a Gauge.
The gauge will be added to the dashboard.
Click on the gauge the setting will be appeared
Then select the required Datastream for the gauge
After that click on the design button.
Then give a Title, align the text, and set the text size.
Then adjust the gauge size.
After adjusting the gauge size click on the add button and add the labeled value.
Click on labeled value widget
Then select the required DataStream.
Follow the same steps, enter the tile, align the text, and increase the fonts size, etc.
The IoT Weighing scale application is also ready.
IoT Weighing Scale Demonstration:
I am going to power up my ESP32 development board using my created 4S lithium Ion Battery. But you can also use a 12V adaptor, or even you can use your laptop to power up the ESP32 module.
The ESP32, my laptop, and cell phone all are connected to the Internet. You can use the same or different Wifi networks.
I am going to start with this 2Kg weight and let’s see if my IoT weighing scale can accurately measure this weight.
The weight value is a bit off.
Next, I am going to test my IoT weighing scale with this 3Kg weight; just to confirm whether the weight I am testing is wrong or if my IoT Weighing Scale calibration value is wrong.
The difference is almost the same .07 grams. This means we need to calibrate our weighing scale.
Open the programming and play with this calibration_factor value until you are happy with the final value. For me this value worked. So, you can start with this value. If it’s work for you then ok otherwise you can try different values. Anyway, I have already uploaded this program and now let’s check the calibrated version of the IoT Weighing Scale in action.
Now, I am pretty satisfied with the final value. .01 grams difference may be due to the rusting, paint, etc. This is not a standard weight. Anyway, I also tested it with Blynk Dashboard and it was working just perfectly.
For the step-by-step explanation and practical demonstration of the IoT weighing scale; watch my video tutorial. And don’t forget to like, share, and subscribe.
Read my article on how to make a DIY commercial-level Weighing Scale using Arduino. I compared my created Diy weighing scale with the commercial scale and was amazed by the final results. Diy Scale Vs. Comercial Scale.
Watch Video Tutorial: