I have been having issues with communicating with a HX711 over the past few months, which I have attempted to resolve in another thread. HERE I have opened a new thread, as I believe this is an SPI communication issue. Please see the following investigation.
Case #1: Historically there were no issues using the HX711 with an Arduino Uno. In this scenario, I have connected an Arduino & a HX711. In the image below, I have measured both the DOUT pin (in YELLOW), and the CLK pin (in GREEN) using an oscilloscope. NOTE: Immediately after DOUT goes LOW, the Arduino pulses the CLK pin 25 times, at a frequency of 2.5kHz. This returns perfect consistent results from the HX711.
Case #2: When this experiment is conducted with the exact same code (and library) on a Boron I get the following result.
NOTE: Similarly, after DOUT goes LOW, the Boron pulses the CLK pin 25 times. But does this with a considerably different frequency of 881Hz. Although this communication was 500ms slower, nevertheless, it also returns perfect consistent results from the HX711.
The BUG/PROBLEM lies in 20% of communications from the Boron to the HX711. See the below image:
NOTE: In this case, pulse #6 pauses on HIGH for a considerable amount of time. Unfortunately this time is greater than the 60us which puts the HX711 into sleep mode, and therefore, no more data is transferred. This results in a large amount of bogus data. This issue can happen on any one of the 25 pulses used to communicated with the HX711. As stated, this happens during 20% of attempts. (80% are good clean pulses). The clock sometimes (but rarely) pauses on LOW.
The code I am using is very straight forward:
#include "HX711.h"
#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT 3
#define CLK 2
HX711 scale;
long time1 = 0;
long time2 = 0;
long time31 = 0;
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.begin(DOUT, CLK);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
time1 = millis();
Serial.print("R= ");
Serial.print(scale.read()); //scale.get_units() returns a float
Serial.println();
}
I am unsure how I can address the current issue. I would appreciate any advice available.