Im trying to get readings from my pressure sensor as in image: sensor.jpg).
I am getting very normal readings from the meter (image: reading.jpg) but then i connect black to A0 to the arduino with the basic sketch;
int analogPin = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// read the raw data coming in on analog pin 0:
int lightLevel = analogRead(analogPin);
// Convert the raw data value (0 - 1023) to voltage (0.0V - 5.0V):
float voltage = lightLevel * (5.0 / 1024.0);
// write the voltage value to the serial monitor:
Serial.println(voltage);
}
The voltages bounce around from 0-5v.
Ive also included the circuit diagram for the pressure sensor (image: circuit.jpg).
That diagram looks like the sensor outputs digital ( ON / OFF) signals, not analog (0 to 5V), can you post a datasheet link or brand name / part number?
No i dont have a common ground actually. The sensor is running at 12v but the output is ranging from 5v-0v.
Hi Karma, I feel you might be right! I cant really find the exact datasheet but it based on the Panasonic DP-100 sensor. I have attached the manual. I think it actually be the Standard model rather than the Multifunction version.
On the last page it is blanked out for Analog output for this model so i think you are right! Its super weird as the voltage does change as the pressure changes! If that is the case that is simply On/Off then how to i at least be able to read that signal?
Thank you so much. Yes it is the NPN version. Do i still need resistors for this one as well?
I will try it on the black.
Would this code be sufficient you think?
void setup() {
//start serial connection
Serial.begin(9600);
//configure pin 2 as an input
pinMode(2, INPUT_PULLUP);
}
void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(2);
//print out the value of the pushbutton
Serial.println(sensorVal);