I'm a master's stutent and I'm trying to connect a OPTRAND D822J6-SP pressure sensor with sensitivity of 39.15mV/Bar to an Arduino UNO to read the output.
Could you, please, help me write the code for this experiment?
Thank you :)
I'm a master's stutent and I'm trying to connect a OPTRAND D822J6-SP pressure sensor with sensitivity of 39.15mV/Bar to an Arduino UNO to read the output.
Could you, please, help me write the code for this experiment?
Thank you :)
Perhaps, what problem have you encountered? Are you working with a data sheet giving all the information about your sensor? Can you provide a link so the rest of us can see it?
Usually example code provides a good start.
Have You figured out the wiring, the schematics?
The pressure stays always as zero.
The instructions for the sensor are here:
http://www.optrand.com/autopsi_manual100413.pdf
Perhaps if you showed your code, someone might be able to see if you have made a mistake.
I am applying 12 volts to the red wire, and connecting the white wire (signal) to A0 of the arduino and of course connecting the black wire to ground of the arduino and of the power source.
I am using this code provided by chatgpt as I don't have much experience programmung arduinos yet:
const int sensorPin = A0;
const float Vref = 5.0;
const int ADC_resolution = 1023;
const float sensitivity = 0.03915;
float Vmin = 0.5;
// ============================
void setup() {
Serial.begin(9600);
}
void loop() {
// Ler valor ADC
int adcValue = analogRead(sensorPin);
// Converter para tensão
float voltage = (adcValue * Vref) / ADC_resolution;
// Calculate pressure (bar)
float pressure = (voltage - Vmin) / sensitivity;
if (pressure < 0) {
pressure = 0;
}
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V | Pressure: ");
Serial.print(pressure);
Serial.println(" bar");
delay(500);
}
Sorry! My system will not allow that download due to security risk.
Have you printed the value in adcValue to see what is being read from the sensor?
What is the voltage range of the signal wire you are connecting to the Arduino A0? If the voltage is over the voltage powering your Arduino, you have likely killed your Arduino.
The signal output is from 0.5 volts to 4.5 volts. The Arduino works fine because I have tried it with other sensors.
Haven't tried it yet. I will do it next time I'm at the laboratory and I'll answer you back.
Thank you for the idea.
Not your problem, but the actual resolution is 1024. There are 1024 possible values which can range from 0 to 1023. A common error.
Hey.
This is the output I get on the serial minitor:
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
Voltage: 4.94 V | Pressure: 113.32 bar
...
The the output stays always the same.
And as you see the voltage shows 4.94 V which is more than the 4.5 V limit sepecified for the signal.
What is the signal voltage shown on your oscilloscope/volt meter?
It's the same.
Always 4.94 volts.
A schematic of your actual project could show the problem.
Nice picture, but you missed showing the picture of your schematic drawing!
By the way, zero is the correct value for that sensor at 1 bar pressure since it is designed to read very high pressures. What is the green line from the sensor?
Have you changed the vref in your code to that actual reference voltage of 4.94?