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

February 14, 2019 by
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Â Â that is very used in industrial applications.Â Â 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:Â Â Â HX711 Transmitter and its library : 5kg Load cell:Â

## Pin Mapping

How do connect the different devices?

The connections between the load cell andÂ Â 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Â Â and PIN2 or PIN3 forÂ Â !!!

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.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.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.

}

void loop() {

Â  Serial.print("Weight: ");

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

Â  Serial.println(" kg");

Â  delay(500);

}
```

## Â

>

#### â€‹Search in our Blog

Boot & Work Corp. S.L., Support Team February 14, 2019