Thank you for your reply, this is the code I'm using:
/* sample for digital weight scale of hx711
* library design: Weihong Guan (@aguegu)
* library host on
*https://github.com/aguegu/ardulibs/tree/3cdb78f3727d9682f7fd22156604fc1e4edd75d1/hx711
*/
// Hx711.DOUT - pin #A2
// Hx711.SCK - pin #A3
#include <Hx711.h>
Hx711 scale(A0, A1);
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print(scale.getGram(), 1);
Serial.println(" g");
delay(200);
}
Libraries:
Hx711.cpp
/*
* Hx711.cpp
*
* Created on: Oct 31, 2012
* Author: agu
*/
#include "Hx711.h"
Hx711::Hx711(uint8_t pin_dout, uint8_t pin_slk) :
_pin_dout(pin_dout), _pin_slk(pin_slk)
{
pinMode(_pin_slk, OUTPUT);
pinMode(_pin_dout, INPUT);
digitalWrite(_pin_slk, HIGH);
delayMicroseconds(100);
digitalWrite(_pin_slk, LOW);
averageValue();
this->setOffset(averageValue());
this->setScale();
}
Hx711::~Hx711()
{
}
long Hx711::averageValue(byte times)
{
long sum = 0;
for (byte i = 0; i < times; i++)
{
sum += getValue();
}
return sum / times;
}
long Hx711::getValue()
{
byte data[3];
while (digitalRead(_pin_dout))
;
for (byte j = 0; j < 3; j++)
{
for (byte i = 0; i < 8; i++)
{
digitalWrite(_pin_slk, HIGH);
bitWrite(data[2 - j], 7 - i, digitalRead(_pin_dout));
digitalWrite(_pin_slk, LOW);
}
}
digitalWrite(_pin_slk, HIGH);
digitalWrite(_pin_slk, LOW);
return ((long) data[2] << 16) | ((long) data[1] << 8) | (long) data[0];
}
void Hx711::setOffset(long offset)
{
_offset = offset;
}
void Hx711::setScale(float scale)
{
_scale = scale;
}
float Hx711::getGram()
{
long val = (averageValue() - _offset);
return (float) val / _scale;
}
Hx711.h
/* Arduino library for digital weight scale of hx711
*
* hardware design: syyyd
* available at http://syyyd.taobao.com
*
* library design: Weihong Guan (@aguegu)
* http://aguegu.net
*
* library host on
* https://github.com/aguegu/Arduino
*
* Created on: Oct 31, 2012
*/
#ifndef HX711_H_
#define HX711_H_
#include "Arduino.h"
class Hx711
{
public:
Hx711(uint8_t pin_din, uint8_t pin_slk);
virtual ~Hx711();
long getValue();
long averageValue(byte times = 25);
void setOffset(long offset);
void setScale(float scale = 1990.f); //1992
float getGram();
private:
const uint8_t _pin_dout;
const uint8_t _pin_slk;
long _offset;
float _scale;
};
#endif /* HX711_H_ */
Wiring diagram:
https://drive.google.com/open?id=0B4MeyqGd8vTvQ3loUnhUVnExVUU
(for some reason it doesn't display the picture, so I have to post the link)
Load cell specifications:
- Product name: load Cell; model: yzc-133; rated load: 10kg /22lb; rated output: 1+/-0. 15mV/V
- Input resistance: 1066 +/- 20 Ohm; output resistance: 1000 +/- 20 Ohm; insulation resistance: 2000 Ohm; working temperature: -20C to +65C
- Compensated temperature range: -10C to +50C; Safety overload: 120 percent F. S; recommend excitation Voltage: DC 5V; max excitation Voltage: DC 10V
- Total Size: 81 x 12. 5 x 12. 5mm /3. 1" x 0. 5" x 0. 5"(Lwt); thread diameter: 3. 4mm / 0. 12"; Hole center distance: 40mm/1. 6", 70mm/2. 8"; cable Length: 240mm/ 9. 4''
- Material: aluminum alloy; color: Silver Tone; weight: 32G; package content: 1 x load Cell
The sensor should be a full bridge (it's a bar load cell with 4 cables), and the amplifier's gain is set to 128, if I'm not mistaken.
I used a multimeter to test the jumper cables and they appear to work, same for the amplifier. However, when I tested the load cell's alimentation cables (red and black) I got a positive value, but then it dropped to 0 mV.
Now I'm waiting for a new load cell (yesterday I ripped off some connections of the one I was using), maybe the problem was the sensor all along.