Request for Assistance with Sphygmomanometer Readings Using HX710B Sensor

Dear friends,
I am developing a sphygmomanometer using the HX710B sensor and need your help with the data readings. My issue is that the sensor only measures up to 60 mmHg; when the pressure exceeds this value, I no longer get readings in my program. I would appreciate any guidance or suggestions. I have attached images for further clarity.

Program:

#include "HX711.h"

// Pines de conexión
const int LOADCELL_DOUT_PIN = 3; // Pin de datos
const int LOADCELL_SCK_PIN = 4;   // Pin de reloj

// Instancia del objeto HX711
HX711 scale;

// Factores que vamos a ajustar
float calibrationFactor = 104858.84; // Ajusta este valor según las pruebas
long offset = 30.00; // Se calibrará dinámicamente

// Número de lecturas para calcular el offset promedio
const int numLecturasOffset = 10;

void setup() {
  Serial.begin(115200);
  
  // Iniciar el HX711
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  
  // Establecer la ganancia del HX711
  scale.set_gain(128); // Cambiar a 64 o 128 según la celda de carga
  
  // Esperar unos milisegundos para estabilizar el sensor
  delay(500);
  
  // Calcular el offset basado en el valor promedio en reposo (sin presión)
  offset = obtenerOffsetPromediado();
  Serial.print("Offset ajustado: ");
  Serial.println(offset);

  // Mostrar instrucciones de calibración
  Serial.println("Calibración del offset completa. Si es necesario recalibrar el offset, presiona 'c'.");
}

void loop() {
  if (Serial.available()) {
    char comando = Serial.read();
    if (comando == 'c') {
      // Recalibrar el offset si se presiona 'c'
      offset = obtenerOffsetPromediado();
      Serial.print("Nuevo offset ajustado: ");
      Serial.println(offset);
    }
  }

  if (scale.is_ready()) {
    // Leer el valor crudo del sensor HX710B
    long lecturaBruta = scale.read();
    
    // Mostrar la lectura cruda y el offset
    Serial.print("Lectura cruda: ");
    Serial.println(lecturaBruta);
    Serial.print("Offset: ");
    Serial.println(offset);
    
    // Restar el offset y aplicar el factor de calibración
    float pressure = (lecturaBruta - offset) / calibrationFactor; // Calcula la presión en mmHg
    
    // Mostrar la presión en mmHg en el Serial Monitor
    Serial.print("Presión: ");
    Serial.print(pressure);
    Serial.println(" mmHg");
  } else {
    Serial.println("Sensor no está listo.");
  }

  delay(1000); // Esperar 1 segundo entre lecturas
}

// Función para obtener un offset promediado en reposo
long obtenerOffsetPromediado() {
  long sum = 0;
  for (int i = 0; i < numLecturasOffset; i++) {
    if (scale.is_ready()) {
      sum += scale.read();
      delay(100); // Pequeño retardo entre lecturas
    }
  }
  return sum / numLecturasOffset; // Retornar el promedio de las lecturas
}







Your topic has been moved. Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

1 Like

why decimals on long?

Remove all your calibration/offset etc from your code and leave only scale.read and print that.
Try if you get output beyond 60mmHg.

2 Likes

What do you mean you no longer get readings?
Are they zero, at the maximum?
If the max is 60 anything above that is invalid, so why do you care?
You are using a library for the HX711 not the HX710B

Before posting your code and schematic, please review the forum guidelines and use code tags to ensure clarity. Additionally, include links to the technical information for your hardware and provide a preliminary schematic that shows all power, ground, and power sources.

For more guidance, please refer to this link:

Important Notes:

  • Breadboard diagrams (often referred to as "frizzes") are not considered proper schematics in this context.
  • Wiring diagrams are helpful for assembly but are not effective for debugging.
  • Screenshots are discouraged because they are often hard to read. Please provide text-based code and clear, high-quality images of schematics.

Providing the correct information will help others understand your setup and offer better assistance.


You might find this tutorial useful, as it points to a library specifically for that sensor.
https://www.teachmemicro.com/arduino-pressure-sensor-tutorial/

Please do not post illegible pictures of text and code. Use cut/paste and code tags instead.

1 Like