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.
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!
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)
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)
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);
}
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