Reading Pressure Sensor

Ok so I have my arduino reading a pressure sensor, however I'm not sure if I have it connected correctly. As I understand it I should be getting a voltage reading, but the values I'm getting seem to high.

My setup includes a stepper motor. I have a voltage supply (+) going into the A0 pin and then the (-) going into the common ground pin. I have a 250 ohm resister between them.

The pressure sensor I have is LP1003.

The code I am using is below; I have the motor going to that is spins a threaded bar to push a syringe closed to inflate a material. So the pressure needed for inflation is what I want to measure.

I assumed that with my set up that the output would be voltage which I could convert however the values seem to high to be correct.

Any help would be great, coding is new to me.

Thanks

int delaylength = 30;    //30 milliseconds // for motor

int analogPin = A0;     // potentiometer wiper (middle terminal) connected to analog pin 3 //for sensor

                       // outside leads to ground and +5V //for sensor

int val = 0;           // variable to store the value read//for sensor


void setup() {
  
  //establish motor direction toggle pins
  pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
  pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???
  
  //establish motor brake pins
  pinMode(9, OUTPUT); //brake (disable) CH A
  pinMode(8, OUTPUT); //brake (disable) CH B
}

void loop(){
 
  digitalWrite(9, LOW);  //ENABLE CH A
  digitalWrite(8, HIGH); //DISABLE CH B

  digitalWrite(12, HIGH);   //Sets direction of CH A
  analogWrite(3, 255);   //Moves CH A
  
  delay(delaylength);
  
  digitalWrite(9, HIGH);  //DISABLE CH A
  digitalWrite(8, LOW); //ENABLE CH B

  digitalWrite(13, LOW);   //Sets direction of CH B
  analogWrite(11, 255);   //Moves CH B
  
  delay(delaylength);
  
  digitalWrite(9, LOW);  //ENABLE CH A
  digitalWrite(8, HIGH); //DISABLE CH B

  digitalWrite(12, LOW);   //Sets direction of CH A
  analogWrite(3, 255);   //Moves CH A
  
  delay(delaylength);
    
  digitalWrite(9, HIGH);  //DISABLE CH A
  digitalWrite(8, LOW); //ENABLE CH B

  digitalWrite(13, HIGH);   //Sets direction of CH B
  analogWrite(11, 255);   //Moves CH B
  
  delay(delaylength);
  


  Serial.begin(9600);          //  setup serial - sets the data rate in bits per second for seriel data transmission



  val = analogRead(analogPin);    // read the input pin



  Serial.println(val);             // outputting the value - supposed to be in volts

while (val > 50){exit(0);}


}

The output from that sensor is 4 to 20 milliAmps and the minimum supply voltage is 13 volts, you can't put 13 volts on the Arduino's input pins. Do you know how to make a voltage divider?
Also, are you aware the pipe threads are "G" threads (parallel pipe threads) that don't seal on the threads like taper threads do?

esi-tec.com.cn/DISPLAY/lp1000.pdf

outsider:
The output from that sensor is 4 to 20 milliAmps and the minimum supply voltage is 13 volts, you can't put 13 volts on the Arduino's input pins. Do you know how to make a voltage divider?

esi-tec.com.cn/DISPLAY/lp1000.pdf

Hi Outsider,

Thank you for your reply, I'm not sure what you mean by voltage divider?

I'm completely new to this, I don't know what you mean by pipe threads and taper threads?

Well, first of all you need a DC supply between 14 and 30 volts, then you can calculate the proper voltage divider.
Also, are you aware the pipe threads are "G" threads (parallel pipe threads) that don't seal on the threads like taper threads do? Do you have a proper port adapter?

Yes I think I have 24V supply, what is the calculation to get the voltage divider?

You will need 3 resistors, 250 , 510 and 10000 Ohms, also, how do you plan to connect the sensor pressure port to your apparatus?

The attached picture shows the sensor set up I have so far, how did you calculate those values for the other two resistors and where do they connect in?

Thank you :slight_smile:

sensor setup.JPG

The 560 goes between sensor and output and one end of 10k and 250, other end of 10k to A0, other end of 250 to ground like you have it, you also need a wire from supply - to sensor, according to data sheet, pin 1 is +, 2 is output and 3 is ground, see attached image.

Untitled.png

Thanks so much for your help! Could you explain a bit more what the resistors are doing, if you have time. Will the set up you suggested give my readings in voltage? How do you calculate the resistor values (or do you have a link for the theory behind it)?

Thanks

The problem with the 4 - 20 mA sensor is if the electronics fail it might put the full power supply voltage on the output, thats the purpose of the voltage divider, with 15 volts on the top of the divider (R1,560) the voltage at the junction of (R2, 250) will be R2 / (R1 + R2) X 15 = 4.93 volts, the purpose of the 10k in series with A0 is to limit current in case the connection to R2 or the connection of R2 to ground failed, the sensor would try to drive at least 4 mA into the open circuit, putting out full supply voltage.
The 250 Ohm resistor is a burden resistor to generate voltage from current, 4 mA will be 1 volt and 20 mA will be 5, so the ADC count will be around 205 for zero pressure and near 1023 for 100 kPa.
if the sensor is not able to drive the full 20 mA you can lower the 560 a little but I wouldn't go below 470, you can adjust for small offsets in software.

So is the absence of the extra resistors one of the reasons why the readings I'm getting are so high?
With this new set up, will my readings be in volts?

Yes, and I mistakenly calculated for 15 volts instead of 24, make R1 1000 Ohms instead of 560.

Thanks so much for your help Outsider :slight_smile: