Using ResponsiveAnalogRead

I am using the ResponsiveAnalogRead library to read voltage output from a 5V pressure transducer. It is working well for me, however, one limitation is that the values are pegged to a default voltage of 5V. I need to benchmark it to supply voltage.
Can someone please advise how do I do that?

I am sharing a shortened version of the code for simplicity.

const int ANALOG_PIN = A7;
ResponsiveAnalogRead analog(ANALOG_PIN, true);

void loop() {
  // put your main code here, to run repeatedly:
  analog.update();
  ReadPressure();

  SetDisplayTemperature(sensor_voltage);
  if (sensor_voltage >= (base_voltage + 3)) {
    ChangeRelayState(0, 0);
  } else {
    ChangeRelayState(2, 1);
  }
  delay(500);
}

void ReadPressure() {
  sensor_voltage = analog.getValue();
}

IS the supply voltage a fixed value ?

We do multiple installations of the same. The supply voltage varies from particular SMPS, however ranging from 4.5V to 5.2V.

As far as I can see ResponsiveAnalog will return a number between 0 and 1023 (ADC resolution).

Supposing a fixed voltage at the input, the reading will change with the actual supply voltage of the microcontroller.

If you want to get a voltage, it is your responsibility to convert it, using the actual supply voltage.

You need to look into the datasheet of your sensor whether the output varies with the supply voltage (likely not).

The datasheet is of no use. Attached herewith.
NB157-EN.pdf (185.7 KB)

As observed, even a minor adjustment in SMPS output leads to variation in the pressure readings. Would the analogReference() function help in my case? Not sure how to proceed further.

Yes it is.
Vout = Vcc x (0.5 x P + 0.1) +/- Error
So for a given pressure the output voltage will vary with the supply voltage

If the supply voltage for the sensor is the same as the ADC Vref, then you wont have a problem.

Did you try this with analogRead()? The smoothing in the ResponsiveAnalog might complicate things.

Seems you would be better off with the built in reference voltages (3V or 1.1V). Of course you would need a voltage divider (2 resistors).

In this case the output of the sensor varies with the supply voltage, and the ADC also refers to the supply voltage, making the reading independent of the supply voltage. Using any constant reference voltage would make things unnecessary difficult.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.