Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

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

Introduction

In this post is showed how to use a load cell transductor using our equipments. Load cell is a transductor that generate 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 get and convert 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 PLC20IOs PLC
HX711 Transmitter and its library :
HX711 TransmitterHX711.h Arduino Library
5kg Load cell: 
Load Cell


Pin Mapping

How to connect the different devices?

The connections between load cell and HX711 are showed 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 showed 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 known weight. It is better if the known weight is closer with the maximum value of the working range of our load cell. On this example has been used a weight of 4 kg because 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 begin to calculate de tare. After open the serial monitor and wait for restart the tare, we can put the known weight.

After put the known weight, on the serial monitor we will see the weight readings values, this value are 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

 
 

Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send