4

I'm trying to build a pressure data logger using an Arduino and Mindman MP47P-03-F1 (https://www.mindman.com.tw/proimages/pdf/E_MP47_S.pdf) pressure sensor, the sensor is connected to an outer 12-24 VDC power source. I've connected the analog wire to the the Arduino's A0 and added another wire from the GND to the sensor. I get a stable voltage (~1V) reading but the pressure is wrong and it doesn't respond to pressure changes. Can someone tell me what I'm doing wrong? this is the sample code:

const int analogPin = A0; 
const float slope = -0.1;
const float intercept = 0.6;
const unsigned long startTime = millis();

void setup() { Serial.begin(9600); Serial.println("Time (s)\t\tPressure (MPa)"); }

void loop() { unsigned long elapsedTime = millis() - startTime; int sensorValue = analogRead(analogPin); float voltage = sensorValue * (5.0 / 1023.0);
float pressure = slope * (voltage - intercept);

Serial.println(sensorValue); Serial.print(elapsedTime / 1000.0); Serial.print("\t\t"); Serial.println(pressure);

delay(1000); }

edit: i've changed the code to as suggested by some on the arduino forum:

const int sensorPin = A0;
const int offset = 201; // zero pressure adjust
const int fullScale = 1023; // max pressure adjust
float sensorType = 1000.0; // kPa
float pressure; // final pressure
const unsigned long startTime = millis();

void setup() { Serial.begin(9600); }

void loop() { unsigned long elapsedTime = millis() - startTime; pressure = (analogRead(sensorPin) - offset) * sensorType / (fullScale - offset);

Serial.print(analogRead(sensorPin)); Serial.print("\t\t"); Serial.print(elapsedTime / 1000.0);
Serial.print("\t\t"); Serial.println(pressure, 4); delay(1000); }

the pressure is 0 but i keep getting jumps in the readings of the pressure when no pressure is applied. here is the picture of the wiring. enter image description here

1 Answers1

2

As jsotola mentions in the comments, you should definitely verify that the pressure sensor works with a multimeter first, preferably on a bench that has a variable power supply from which you can power your sensor. Make sure that you can measure the pressure you are putting into the sensor by some other means; a simple pressure gauge could work.

Then, you'll have to correct your equation - it is flipped, since the graphs show the pressure as an input and an output as a voltage, but when you're converting a voltage to a pressure, the process is flipped, so we calculate the slope as follows: take the pressure range (output) and divide it by the voltage range (input) -> 1.1 MPA / 4.4 V = 0.25 V_in. Now, we know that at 0.6V, the pressure output is -0.1 MPA, so we set up a linear equation of the form that you did -> y = mx + b and plug in the values: -0.1 MPA = 0.25 MPA/V * (0.6V) + b. If you solve for b, you'll get -0.25.

Therefore, pressure = 0.25X - 0.25 should be the equation that you check the pressure you're putting into the sensor against the voltage that you are measuring.

If you discover that with this equation you're measuring the right pressure, but once you re-implement your Arduino program you still have no luck, I'd check that the grounds are wired together correctly - it's crucial to have all of the involved grounds at the same 'level'. As a bonus, depending on the Arduino, you could utilize the chip's differential ADC channels, but as far I know, you'd have to write directly to registers to do that.

Nick S.
  • 167
  • 8