How to connect and configure a load cell using HX711 transmitter with Arduino based PLCs

February 14, 2019 by
How to connect and configure a load cell using HX711 transmitter with Arduino based PLCs
Boot & Work Corp. S.L., Support Team

Introduction

This post is showed how to use a load cell transductor using our equipments. The load cell is a transductor that generates an electrical signal directly proportional to the measured force.

On market, there are different transmitters that can convert this analog signal to digital. In this example is used the HX711 that is very used in industrial applications. HX711 gets and converts the analog signal from the load cell to digital with his intern converter A/D of 24 bits.

Requirements

Ethernet or 20 I/Os PLC:  
Ethernet PLC >>>20IOs PLC >>> 
HX711 Transmitter and its library :
HX711 Transmitter >>>HX711.h Arduino Library >>>
5kg Load cell: 
Load Cell >>>


Pin Mapping

How do connect the different devices?

The connections between the load cell and HX711 are shown below:

Load Cell

HX711

Red wire

E+

Black wire

E-

White wire

A+

Green wire

A-

 

And the connections between HX711 and one of our PLC’s are shown below:

HX711

Industrial Shields PLC

GND

GND

DT

PIN 2

SCK

PIN 3

VCC

5V

 

IMPORTANT: The frequency of the clock is quite high, so we must use PIN3 for Ardbox and PIN2 or PIN3 for M-Duino !!!

Once there are all the wires connected we can proceed with the software to get the rights values from the HX711.

Once the HX711 library is installed, we can proceed to calibrate the weighing scales. Basically, to find the value of the scale, that is to find the conversion factor to convert the read value to weight unit.

After that, we need to find an object with a known weight. It is better if the known weight is closer to the maximum value of the working range of our load cell. In this example has been used a weight of 4 kg because the maximum value of the working range of our load cell is 5 kg.

The next step is to upload the next sketch to our PLC:

#include "HX711.h"

#define DOUT  2

#define CLK  3

HX711 weighingScales(DOUT, CLK);

void setup() {

  Serial.begin(9600);

  while(!Serial); // This is not necessary if you have an M-Duino

  Serial.print("Read ADC value:  ");

  Serial.println(weighingScales.read());

  Serial.println("Don't put any weight to the weighing scale");

  weighingScales.set_scale(); //The default scale is 1

  weighingScales.tare(20);  //The actual weight is Tare.

  Serial.println("Put the known weight:");

}

void loop() {

  Serial.print("Read Value:  ");

  Serial.println(weighingScales.get_value(10),0);

  delay(500);

}

 

The program has to run without the known weight, because when the program begins to calculate de tare. After opening the serial monitor and waiting to restart the tare, we can put the known weight.

After putting the known weight, on the serial monitor we will see the weight readings values, this value is without scale. This means that the values must be big numbers.

With an average of these values we can calculate the value of the scale, following that formula:

Once the scale value has been calculated we have all the requirements to configure the load cell.  We just have to write the scale value on the HX711 function set_scale(). Next is showed an example of how can look a final program for a load cell:

#include "HX711.h"

#define DOUT  2

#define CLK  3

HX711 weighingScales(DOUT, CLK);

void setup() {

  Serial.begin(9600);

  while(!Serial); // This is not necessary if you have an M-Duino


  Serial.println("Calculating tare...");

  Serial.println("...");

  weighingScales.set_scale(433456.25); // Set up our scale

  weighingScales.tare(20);  //The actual weight is Tare.

  Serial.println("Ready to weigh"); 

}

void loop() {

  Serial.print("Weight: ");

  Serial.print(weighingScales.get_units(20),3);

  Serial.println(" kg");

  delay(500);

}

Video

 
 

​Search in our Blog

How to connect and configure a load cell using HX711 transmitter with Arduino based PLCs
Boot & Work Corp. S.L., Support Team February 14, 2019

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>