It uses a clock line and a data line. It's not serial (it doesn't have a clock). It has a data and a clock signal - does that mean it's I2C? But it doesn't call it SCL and SDA. If I need to reproduce that library for a different microcontroller, how do I do it?
The HX711 data sheet describes the serial protocol well enough that you should be able to write code for any processor, especially if you follow the C code example in the data sheet.
jremington:
The HX711 data sheet describes the serial protocol well enough that you should be able to write code for any processor, especially if you follow the C code example in the data sheet.
Yes, it uses a clock line to sequence the bits.
Yeah, they go into quite a lot of detail on the timing. But I was wondering if this falls into one of the named protocols? Just trying where it is in the list of different clocked protocols.
MarcosSM:
Hello, did you get the protocol? I also would like to know if it is I2C or SPI
1. If it would been an I2C Protocol, the HX711 chip should contain a provision to contain 7-bit I2C address and an I2C Logic/Interface. The Fig-1 shows a digital interface which is not an I2C Interface.
Figure-1: Typical connection diagram of HX711 chip with a load cell
2. If it would been a SPI Protocol, the HX711 chip should have a SPI interface; but, HX711does not contain such interface.
3. What is this interface for the HX711 chip?
It is a customized serial interface which has no standardized rules like the I2C Standard/protocol. The manufacturer has said that the HX711 chip is a free-running chip (it does not need any command to begin data conversion); the data lines remains at LH-state as long as data conversion is going on; at the end of data conversion, the data line assume LL-state; to bring out data bit one-after-another (with MSBit first, Fig-2) one has to assert clock pulse at the clock-pin.
4. The following sketch is the translation of the timing diagram of Fig-2. This sketch reads 10 samples of data from a load cell, averages them, and show the averaged value on the Serial Monitor.
/* This program takes 10 samples from LC + HX711B at
1-sec interval and then computes the average.
*/
unsigned long x = 0, y=0;
unsigned long dataArray[10];
int j = 0;
void setup()
{
Serial.begin(9600);
pinMode(A1, INPUT); //data line //Yellow cable
pinMode(A0, OUTPUT); //SCK line //Orange cable
}
void loop()
{
for (int j = 0; j < 10; j++)
{
digitalWrite(A0, LOW);//SCK is made LL
while (digitalRead(A1) != LOW) //wait until Data Line goes LOW
;
{
for (int i = 0; i < 24; i++) //read 24-bit data from HX711
{
clk(); //generate CLK pulse to get MSB-it at A1-pin
bitWrite(x, 0, digitalRead(A1));
x = x << 1;
}
clk(); //25th pulse
Serial.println(x, HEX);
y = x;
x = 0;
delay(1000);
}
dataArray[j] = y;
}
Serial.println("===averaging process=========");
unsigned long sum = 0;
for (j = 0; j < 10; j++)
{
sum += dataArray[j];
}
Serial.print("Average Count = ");
sum = sum / 10;
Serial.println(sum, HEX);
// float W = (float)0.90*(sum-901002)/946560 + 0.75;//0.005331 * sum - 1146.176;
//W = (float)W / 1000.00;
Serial.println(W, 2);
}
void clk()
{
digitalWrite(A0, HIGH);
digitalWrite(A0, LOW);
}