Bug in use of HX710 sensor

We are currently trying to create a device that would generate negative pressure inside a container by extracting air using a pump. At the moment, we are facing an issue with the use of this sensor. When we run the code, it continuously outputs the following message: “sensor not ready”.

Has anyone already encountered this problem and knows how to solve it? Unfortunately, I couldn’t find anything about this issue online, and I am currently completely stuck in the development of this device.

The code we are using is the following:

#include "HX710B.h"

const int DOUT = 2;
const int CLK_PIN = 3;

HX710B sensor;

void setup() {
  Serial.begin(115200);
  sensor.begin(DOUT, CLK_PIN);
}

void loop() {
  if (sensor.is_ready()) {

    Serial.print("mmHg: ");
    Serial.print(sensor.mmHg());

    Serial.print(" | PSI: ");
    Serial.println(sensor.psi());

  } else {
    Serial.println("Sensor not ready");
  }

  delay(1000);
}

The library used is the following: “hx710B_pressure_sensor-main”, which you can find online: GitHub - rppelayo/hx710B_pressure_sensor · GitHub (sorry i can't attach it in this message...)

You will also find attached the wiring diagram we used. If anyone is familiar with this issue or could help us with a possible solution, it would be greatly appreciated!

Thank you in advance!

Have you soldered the header pins onto the sensor board?

Yes, we did, because otherwise it was too difficult to get a good connection of the wires to the sensor.

Those sensor are sold as 0-40kPa,
What makes you think they can be used for negative atmospheric pressure.
Leo..

We haven’t tried using it with negative pressure yet, but for now, even at atmospheric pressure, the sensor doesn’t show any pressure.

is_ready() just checks to see if the DOUT pin is LOW.
So just for debugging purposes, disconnect the DOUT wire from the sensor and connect it to the Uno GND and see what happens (pin 2 to GND)

@vicdm

You might give my library a try.
It does not convert to pressure, but allows you to check if the raw measurements match.
(you might optional set offset and scale)

Ok, thank you! I will try it. Do I need to change anything in the code, or should I just run the same code and see what happens in the serial monitor?

No, it should at least not say "sensor not ready"

If it started printing crazy values, then there is either a bad connection, cold solder joint, broken wire, loose connection or the sensor board is actually bad.

Do you have a voltmeter or DMM so you can measure voltages?

Run the following sketch and chcek if the Serial Monitor shows any counts:

/* This program takes 10 samples from LC + HX711B at
   1-sec interval and then computes the average.
*/
#define DT 2
#define SCK 3

unsigned long x = 0, y = 0;
unsigned long dataArray[10];
int j = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(DT, INPUT); //data line  //Yellow cable in my Setup
  pinMode(SCK, OUTPUT);  //SCK line  //Orange cable in my Set up
}

void loop()
{

  for (int j = 0; j < 10; j++)
  {
    digitalWrite(SCK, LOW);//SCK is made LL
    while (digitalRead(DT) != 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-bit 
        bitWrite(x, 0, digitalRead(DT));
        x = x << 1;
      }
      clk();  //25th pulse
      Serial.println(x, DEC);
      y = x;
      x = 0;
      delay(1000);
    }
    dataArray[j] = y;
  }

  Serial.println("===averaging process=========");
  unsigned long C1 = 0;   //C1 = Count-1

  for (j = 0; j < 10; j++)
  {
    C1 += dataArray[j];
  }
  Serial.print("Average Count = ");
  C1 = C1 / 10;
  Serial.println(C1, DEC);
}

void clk()
{
  digitalWrite(SCK, HIGH);
  delayMicroseconds(50);
  digitalWrite(SCK, LOW);
}

The values shown are these—what do you think about them? Do you know why we obtain such values in this case?

This is what happened when we used your code. So I think the count is working.

Now, gently blow into the orifice of the pressure sensor and check whether the count increases. If this test passes, you can conclude that the pressure sensor is functioning properly. After that, you may use a library to operate the sensor.

However, if you intend to use my code, a two-point calibration is required to determine the gain and offset, which are subsequently applied to the raw readings to compute the actual unknown pressure.

Two-point Calibration Philosophy:
1. Apply known pressure P1 and record counts C1 ==> A(P1, C1).
2. Apply known pressure P2 and record counts C2 ==> B(P2, C2).
3. Apply unknown pressure P and record count C ==> Q(P, C).
4. Draw line passing through point A, B, Q.
5. Find the equation of the line of Step-4 ===> P = mC + k; where, m is the gain of the sensor and k is the offset of the sensor.

==> (P - P1)/(C - C1) = (P2 - P1)/(C2 - C1)
==> P - P1 = (C - C1) x (P2 - P1) /(C2 - C1)
==> P - P1 = C x (P2 - P1)/(C2 - C1) - C1x(P2 - P1)/(C2 - C1)
==> P = (P2 - P1)/(C2 - C1) x C + (P1 - C1x(P2 - P1)/(C2 - C1)) 
==> P = mC + k  Here: m and k are known; P is lnearly proportional to C

Blowing onto the orifice wouldn't do much to a 40kPa sensor.
Put a tube on it and blow on it with a bit of force.
Leo..

Thank you. I have no experience with this kind of pressure sensor.

They are not valid values the test was just to see if you had bad connections and or sensor.

See post #10

Recheck your soldering and connections.