It has 3 wires.
Black is -
Red is +5
Green is Sensor output. I have this one hooked up to Analog 0 on the Arduino Uno i'm using.
Anyway, i get the same reading from the Green sense wire no matter what pressure it sees.
It is always 4.95V.
I have tried it a 40 PSI, 30 PSI, 25 PSI and also disconnected from the pressure tank.
The sensor has the following documentation:
Output: 0.5V~4.5V linear voltage output. 0 psi outputs 0.5V, 15psi outputs 2.5V, 30 psi outputs 4.5V.
So first of all 4.95 is more than the 4.5 that they mention.
This makes me wonder if I have it hooked up wrong?
I have the red +5 going to the +5 pin on the uno, the black - hooked up to the gnd on the Uno, and the green output on the Analog 0 pin on the uno.
This is the code im using:
const int analogPin = A0;
float inputP1;
float voltageP1;
float psiP1;
void setup() {
Serial.begin(9600); // open the serial port at 9600 bps:
}
void loop()
{
inputP1 = analogRead(A0);
voltageP1 = ((float)inputP1* (5 / 1023.0));
psiP1 = ((float)inputP1/1023*100);
Serial.print("VOLTAGE = ");
Serial.print(voltageP1);
Serial.println();
Serial.print("PSI = ");
Serial.print(psiP1);
Serial.println();
Serial.println();
Serial.println();
delay (500);
}
You can try the code below. You may have to adjust the mapping numbers (0-100), But this may help you get closer to what you are looking for...
Let me know if this helps...
int PS = A0; // Pressure Sensor
int PSR = 0; // Pressure Sensor Reading
void setup() {
Serial.begin(9600);
pinMode(PS, INPUT);
}
void loop() {
PSR = analogRead(PS);
delay(250);
PSR = map(PSR, 0, 1023, 0, 100); //Changes voltage into PSI.. Analog--->Digital
Serial.print("Pressure: ");
Serial.println(PSR);
Serial.println(" ");
delay(250);
}
Read the reviews. Seems like about a 50/50 failure rate. I have read on a lot of automotive sights that these cheap Chinese sensors are a gamble.
Also the specifications are wrong. At 0 psi it should read .5V and at 100 psi 4.5V.
detown:
Also the specifications are wrong. At 0 psi it should read .5V and at 100 psi 4.5V.
Actually 10% of VCC @ 0 psi and 90% of VCC @ 100 psi.
Sensors like this are ratiometric, and 5volt is never 5.000volt.
Therefore better to code in A/D values, not in 'volts' (you're not making a voltmeter).
Test sketch attached.
Leo..
const byte pressurePin = A0;
float sensorType = 100.0;
const int offset = 102; // zero pressure adjust
const int fullScale = 922; // max pressure adjust
float pressure; // final pressure
void setup() {
Serial.begin(9600);
}
void loop() {
pressure = (analogRead(pressurePin) - offset) * sensorType / (fullScale - offset);
Serial.print("Pressure: ");
Serial.print(pressure, 1); // one decimal place is all you're getting with a 10-bit A/D
Serial.println(" psi");
delay(500);
}