Pressure Sensor for Pressure cuff

Need help in utilizing my pressure sensor ( MPS20N0040D)

The sensor always output 8388608 and does not recognize the pressure when the pressure cuff increases in pressure.

#include <SPI.h>
#include <Q2HX711.h>
#include <Average.h>

// Define the pin numbers for control
const int ENA = 5;           // Enable pin connected to ENA on L298N
const int IN1 = 2;           // Control pin 1 connected to IN1 on L298N
const int IN2 = 3;           // Control pin 2 connected to IN2 on L298N
const byte MPS_OUT_pin = 8;  // OUT data pin
const byte MPS_SCK_pin = 9;  // clock data pin
int avg_size = 10;           // #pts to average over

Q2HX711 MPS20N0040D(MPS_OUT_pin, MPS_SCK_pin); // start comm with the HX710B
Average<long> ave(avg_size);

// Conversion factor from sensor output to mmHg (replace 1 with your actual conversion factor)
const float CONVERSION_FACTOR = 1.0; 

void setup() {
  Serial.begin(9600); // start the serial port
  // Initialize the control pins as outputs
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
}

void loop() {
  // Turn on the air pump
  digitalWrite(ENA, HIGH);   // Enable the motor driver
  digitalWrite(IN1, HIGH);   // Set IN1 HIGH
  digitalWrite(IN2, LOW);    // Set IN2 LOW
  ave.push(MPS20N0040D.read());
  
  // Convert the pressure reading to mmHg and print
  float pressure_mmHg = ave.mean() * CONVERSION_FACTOR;
  Serial.println(pressure_mmHg);
}

Try dropping the ave stuff and see what raw data you're getting.

I have removed the average stuff in the code, still the readings in the serial monitor is around 8388608 when it should be growing since I also have attached a pressure reader in the pipe

Please post the new code.

#include <SPI.h>
#include <Q2HX711.h>

// Define the pin numbers for control
const int ENA = 5;           // Enable pin connected to ENA on L298N
const int IN1 = 2;           // Control pin 1 connected to IN1 on L298N
const int IN2 = 3;           // Control pin 2 connected to IN2 on L298N
const byte MPS_OUT_pin = 8;  // OUT data pin
const byte MPS_SCK_pin = 9;  // clock data pin

Q2HX711 MPS20N0040D(MPS_OUT_pin, MPS_SCK_pin); // start comm with the HX710B

// Conversion factor from sensor output to mmHg (replace 1 with your actual conversion factor)
const float CONVERSION_FACTOR = 1.0; 

void setup() {
  Serial.begin(9600); // start the serial port
  // Initialize the control pins as outputs
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
}

void loop() {
  // Turn on the air pump
  digitalWrite(ENA, HIGH);   // Enable the motor driver
  digitalWrite(IN1, HIGH);   // Set IN1 HIGH
  digitalWrite(IN2, LOW);    // Set IN2 LOW
  
  // Read the pressure sensor
  long pressure_raw = MPS20N0040D.read();

  // Convert the pressure reading to mmHg and print
  float pressure_mmHg = pressure_raw * CONVERSION_FACTOR;
  Serial.println(pressure_mmHg);

  // Optional delay to slow down the readings (adjust as needed)
  delay(1000); // 1 second delay
}


Here is the new code sir

Could it be a wiring issue? How did you put it together?

You should have received a float.

is 0x800000 if that gives any useful clues.

The module I see is a HX710, not a HX711.
Use a HX710 library for starters.
Leo..

Hello, thank you for the help everyone, I was able to find the issue. Apparently, the sensor is really sensitive there should be a certain curve in the tube attached then it will detect the pressure. I calibrated the raw data by making an equation by matching the raw data with its corresponding pressure gauge.