I am trying to read a Honeywell SA transducer but the pressure from my gauge is way off from the reading. I'm not sure how to really translate the data from the data sheet to my code.
here's my wacky code. Thanks
int pwrled = 12;
int whiteled = 11;
void setup(){
pinMode(pwrled, OUTPUT);
pinMode(whiteled, OUTPUT);
Serial.begin(9600);
}
void measurePressure(){
const float offset = 0.0;
float pressure = 0;
int rawReading = analogRead(A1);
float voltage = rawReading * (5.0 / 1023.0);
pressure= (voltage - offset) * 100/4.0;
Serial.println("-----------------------------------------------------");
Serial.print("Transducer Pressure: ");
Serial.print(pressure);
Serial.print(" PSI ");
Serial.print("Voltage: ");
Serial.println(voltage);
Serial.println("-----------------------------------------------------");
digitalWrite(pwrled, HIGH);
digitalWrite(whiteled, LOW);// Currently haveing it turn on a led
delay(500);
digitalWrite(pwrled, LOW);
digitalWrite(whiteled, HIGH);
delay(500); }
void loop() {
measurePressure();
}
The data sheet says to measure the voltage. 1V = zero pressure, 5V = full scale.
However, output up to 6V is possible. You MUST protect the analog input from voltages > 5 V. A 10K resistor in series with the gauge and the analog input will do that.
The following is correct in the basic approach, but why is offset set to zero, and what do you think the term 100/4.0 supposed to do?