Problems calibrating Transducer

I'm trying to run this project from here:

The problem I'm having it that the gauge is showing -26.87 psi at 0psi
Everything works but the reading are all over the place.
However I'm not using the same transducer as in the project.

Here are the specs of the transducer i have.

Range: 0-100psig
Output: 0-10vdc
Input: 14-36vdc

I believe it's also Radiometric.

So by using a different transducer i know it needs to be calibrated.
I'm new to coding and i have no idea where to start or what line i need to edit.

Here is the code I'm using:
Sorry the code is too large to include it in Code tags.

Please see TXT attachment.

IOT Compressor.txt (18.3 KB)

Assuming that you are using an UNO and feeding your input sensor DC voltage signal at A0 channel of the ADC. Carry out these steps:

1. Feed you sensor signal into this resistor network: sensor voltage ---> (R1)1.5k + (R2)1.5k + (R3)2.2k ---->GND.

2. Connect signal from the junction point of R2-R3 to A0-pin.

3. Now, you have the following response points:

A(0 psig, 0V)
B(100 psig, 4.23V)    //10/(5.2k)*2.2k = 4.23V
C(psig, V)

from the above 3 points, we can find:

==> psig = 100*V/4.23

V is related with 10-bit ADC value in this way (assume VREF = 5V):

(1023/5)*V = analogRead(A0)
==> V = (5/1023)*analogRead(A0)

4. Now, this is your calibrated pressure:

float psig = (float)(100/4.23)*(5/1023.0)*analogRead(A0);
Serial.println(psig, 2); //should show correct pressure with 2-digit after decimal point

Thanks I''l give this a try.
However where do i insert these codes above?

And yes using A0

Please, post your codes/sketch what you have prepared and then I will show/guide you where to insert the given pieces of codes.

nuworld:
However I'm not using the same transducer as in the project.

Here are the specs of the transducer i have.

Range: 0-100psig
Output: 0-10vdc
Input: 14-36vdc

I believe it's also Radiometric.

If it has a voltage output, then it's not ratiometric.
That's good, because the NodeMCU has an absolute A/D, and can only properly measure voltage sensors.
The article is using a ratiometric sensor, and that's wrong.

GolamMostafa:
Feed you sensor signal into this resistor network: sensor voltage ---> (R1)1.5k + (R2)1.5k + (R3)2.2k ---->GND.

Are you forgetting that the NodeMCU already has a 100k:220k voltage divider connected to A0.
All you need is a 680k resistor between sensor output and A0.
The code can be as simple as:
float pressure = analogRead(A0) * 0.097656; // calibrate by changing the last digit(s)
(0.097656 being 1/10.24, including the A/D range and 100psi span)
Leo..

@OP

As you are using ESP8266, please follow guide lines pf Post#4. I was not prompted to enter into your link to see that you are actually using an ESP8266 based Project.

@GolamMostafa
It's hidden in the (wrongly posted) code in post#0.

@OP
Please read the "how to post" guide that you can find on top of every main page.
Leo..

sorry guys i will read (the thread.

I'm using a ESP8266(LiLon NodeMCU V3)
And a 24v pws for the sensor.

As for the code it was too large to include code tags.
there is a 9000 character limit for each post.
This is why the included code is in the attachment in OP.

also what line do i put these new code in.

Sorry I'm very new to this.

Can't be bothered to read all of that.
You should always try sensors with the least amount of code before adding them to a complicated setup.

Advice still stands.
680k resistor between 0-10volt sensor output and A0, shared grounds, and only this line to convert A/D to pressure.

float pressure = analogRead(A0) * 0.097656; // calibrate by changing the last digit(s)

Nothing else, except for maybe a 100n ceramic cap between A0 and ground if used in an electrically noisy environment or with pressure fluctuations.
Leo..

Umm, if you can read all the code then I have no idea where to add your
Code.

Please keep in mind that some projects are more complex than others.
Hence the large code.

If you can’t be bothered to read?
Then I understand.

Thanks anyway.

Try this minimal sketch to test the the sensor on the serial monitor.
Leo..

float pressure;

void setup() {
  Serial.begin(9600);
}

void loop() {
  pressure = analogRead(A0) * 0.097656; // calibrate by changing the last digit(s)
  Serial.println(pressure, 1); // one decimal place is all you're getting
  delay(1000);
}

Wawa:
Try this minimal sketch to test the the sensor on the serial monitor.
Leo..

float pressure;

void setup() {
 Serial.begin(9600);
}

void loop() {
 pressure = analogRead(A0) * 0.097656; // calibrate by changing the last digit(s)
 Serial.println(pressure, 1); // one decimal place is all you're getting
 delay(1000);
}

I ran the Sketch.

@ 0 Psi the sensor read @0.6 psi

@ 50 psi the sensor read @ 49.5

@ 100 psi the sensor read @ 100.0

Rather good for the crappy A/D of an ESP8266.
Leo..

What do I do now.
Where do I put the code at in my sketch?

Prune out the analogRead part of the code, and insert the new one.
I sure hope you wrote the code yourself, or do understand it.
If you did copy/paste, then take 10 steps back, and start learning.
Leo..