1

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

3
  • 2
    the program should be responding to pressure changes ... disconnect the arduino and check the sensor output with a voltmeter
    – jsotola
    Jul 11 at 14:58
  • @NickS. - That's a nice comment your wrote! The "Also, your equation is wrong..." part is brilliant, and would be part of a great answer. Perhaps you are not aware that answers in the comments on Arduino SE are frowned upon.
    – VE7JRO
    Jul 12 at 0:45
  • @NickS. - Why not put your "I just gave pointers" part of your comment into an answer? I am certain that the long term members of this stack will agree that answers and partial answers are not welcome in the question's comment section :) NG
    – VE7JRO
    Jul 12 at 2:28

1 Answer 1

1

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.

4
  • from where i need to measure the sensor voltage? it has a LCD screen where i can see the pressure changes but the Arduino doesn't see these changes, from 0MPa to 0.008MPa for example Jul 12 at 7:57
  • also, from time to time i get voltage spikes that change the pressure reading Jul 12 at 12:59
  • You'd measure the voltage from the white wire to the blue wire (from analog out to DC-). Do you actually have a bigger pressure source than that minuscule (probably ambient) value? It's so small, it's less than 1% of the full scale, which is below reasonable SNR based on the +/- 2.5% FS value - it might as well be noise. Do you have a spare bicycle hand pump that you can attach the correct fitting to and try it out? Maybe with a pass-thru gauge? Either way, 1V sounds reasonable for ~0 MPA, so if you aren't applying any pressure that's bigger than ambient that looks ok. What kind of spikes?
    – Nick S.
    Jul 12 at 14:17
  • How large are the spikes? Do you have a cap on the input to the PS (I only see a hose)? Did you try measuring the output without the Arduino in place, preferably with a scope? Do you have a second PS you can test (for the future - you should get two next time, so you don't have to try and figure out if you're troubleshooting your connection or the sensor itself)? Did you decouple the power supply from the PS? Why do you need an extra probe to connect the analog output wire to the Arduino itself? Again, ideally you'd have a known non-zero pressure source which you can apply to the PS.
    – Nick S.
    Jul 13 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.