Difference between revisions of "Interface the HX711 to Pi"

From HiveTool
Jump to: navigation, search
(Required Parts)
(Testing and Calibration)
Line 103: Line 103:
 
<br clear=all>
 
<br clear=all>
 
==Testing and Calibration==
 
==Testing and Calibration==
 +
There is a README file with the HX711 software.  After the HX711 software is installed run the hx711 program with no arguments:
 +
 +
sudo hx711
 +
 +
It will spit out 64 lines and after the last line, there will be a number (in this case 146640):
 +
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 n:    1546646    - 
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 n:    1546794    - 
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 0 0 n:    1547088    - 
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 n:    1546168    - 
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 n:    1546118    - 
 +
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 n:    1546014    - 
 +
1546640
 +
 +
The numbers you get will be totally different (this was run with a 57 lb hive on the load cells)
 +
 +
The last number 1546640 is the average of the 64 reads. The numbers may be negative.  That is OK.
 +
 +
You should be able to put some weight on the load cells, run hx711 again and the numbers should be different.
  
 
<br clear=all>
 
<br clear=all>
 +
 
==Temperature Compensation==
 
==Temperature Compensation==
 
[[File:XP003_HX711_20140424.gif|thumb|right|600px|Temperature drift using the HX711 and CZL635.  This is a 37.9 lb piece of railroad track]]
 
[[File:XP003_HX711_20140424.gif|thumb|right|600px|Temperature drift using the HX711 and CZL635.  This is a 37.9 lb piece of railroad track]]

Revision as of 04:27, 29 December 2014

Building a Raspberry based electronic scale using the DCT Electronic HX711 board is as easy as Pi!

The DCT board comes with a metal shield and two sets of male headers: straight and right angle.

Required Parts

HX711 board without driver chip
Hx711 board with driver chip

There are several HX711 boards available. We have been testing the brown boards that have a metal shield. There appear to be two versions of those available. Some only have one chip, some have two.



Installation

Method 1: Connect HX711 to P1/J8

HX711 with screw terminals and metal shield installed connected to P1/J8 on the Pi.
P1/J8 close up

This will work with all models of the Pi: A, B, A+, B+.

Prepare the HX711 board

First prepare the HX711 board by soldering the shield and connectors.


Pins 2, 16, 18, 20 on P1 (Model A and B) or J8 (Model A+ and B+)are used:

P1/J8 Pi HX711 Color
Pin 2 +5 Vcc Red
Pin 16 GPIO28 DO/RX White
Pin 18 GPIO30 CK/TX Green
Pin 20 Ground GND Black


#define CLOCK_PIN 24
#define DATA_PIN 23


Method 2: Connect HX711 to P5

Two DCT Electronic HX711 boards with metal shield.
DCT Electronic HX711 board plugged into P5

You will need a 1x4 female header (2.54mm Pitch Straight Single Row PCB Female Pin Headers) and load cells.

  1. Order the board for $6.99 on Ebay
    This one for $2.17 should work, too.
  2. Download the software from gitHub
    git clone https://github.com/ggurov/hx711
  3. Solder a 1x4 straight female header in P5 on Pi (bottom side of board) and a 1x4 male header on the DCT board
  4. Solder the load cells to the DCT board.
  5. Plug the DTC board into the Pi.
  6. Change the GPIO pins in hx711.c from 30 and 31 to 28 and 30. This way they are all on one side of P5:
P5 Pi HX711
P5-1 +5 Vcc
P5-3 GPIO28 DO/RX
P5-5 GPIO30 CK/TX
P5-7 Ground GND


#define CLOCK_PIN       30
#define DATA_PIN        28


Testing and Calibration

There is a README file with the HX711 software. After the HX711 software is installed run the hx711 program with no arguments:

sudo hx711

It will spit out 64 lines and after the last line, there will be a number (in this case 146640):

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 n:    1546646     -  
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 n:    1546794     -  
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 0 0 n:    1547088     -  
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 n:    1546168     -  
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 n:    1546118     -  
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 n:    1546014     -  
1546640

The numbers you get will be totally different (this was run with a 57 lb hive on the load cells)

The last number 1546640 is the average of the 64 reads. The numbers may be negative. That is OK.

You should be able to put some weight on the load cells, run hx711 again and the numbers should be different.


Temperature Compensation

Temperature drift using the HX711 and CZL635. This is a 37.9 lb piece of railroad track

Temperature Sensitivity

From the CZL635 Spec Sheet link below:

Temperature Effect on Span 2.5 g/°C
Temperature Effect on Zero 5 g/°C

From the CZL602X Spec Sheet link below:

Temperature Effect on Span 0.02%F.S/10℃
Temperature Effect on Zero 0.03%F.S/10℃

Full Scale = 50 kg 

.02% F.S/10℃
.0002 * 50 kg = .01 kg / 10℃
              = .001 kg / 1℃
              = 1 g/ 1℃

So the CZL602X are 2.5 times more stable than the CZL635

HX711 Spec Sheets

http://hivetool.org/w/images/d/d2/Hx711_english.pdf

Load Cells

Spec Sheets

  1. CZL635 Spec Sheet (from Phidgets.com)
  2. CZL602X Spec Sheet

Theory and Application Notes

  1. LOAD CELL TECHNOLOGY IN PRACTICE by REVERE TRANSDUCERS APPLICATION NOTE 07/6-13/01