I got a MPX4115 pressure sensor and I tried to get
it working with the Arduino. But as I try to calculate
the pressure it does gave me strange results.

I just plugged the Vout to +5V GND to Ground and Vs to
the AnalogPin 0

This is pretty much exactly the code I have for the 6115 sensor, and it seems to work fine.

What do your results look like, and what did you expect?

Realize that you have to apply a function to convert from voltage to pressure (and there's another function to convert from that integer to a floating point voltage).

If you have a multimeter, can you measure the voltage on the analog pin (Vout). A reading of 1023 implies 5 volts and if that's what you are getting then the sensor may not be wired correctly or the sensor is faulty

What do you mean by this
"(and there's another function to convert from that integer to a floating point voltage)."

The ADC returns an integer from 0 to 1023, representing values from 0 to 5V (assuming you haven't added an external analog reference), so each integer from analogRead() represents ~4.88mV. To get Vin, you need the following conversion:

float Vin;
Vin = (5.0/1024.0) * analogRead(0);

Also, be careful of rounding when evaluating integers - it can lead to unexpected results.

I realise that this is an old post now, but, just got one of these to make my own weather station.

In regards to your readings being out by a factor of 10, the datasheet states that the formula is for calculating kPa, not hPa, so that's why it's out by a factor of ten.

The formula can be simplified a little for the Arduino too.
As the 'Vout/Vs' part is just a ratio, you don't need to calculate the actual voltage. This saves a few steps in the calculation and will reduce the error too.

Also, as you might not be supplying exactly 5v to the sensor, working the whole thing out as a voltage probably won't be totally accurate, where as 'analogRead/1024' will always give you the right ratio.

So, to work out the pressure in hPa, or millibars as we call them in the UK, and get the most accurate reading use:

P= ((analogRead(0)/1024)+ 0.095)/0.0009

Regards,
The Cageybee

(Updated the formula. Took away a zero from the final division when I should have added one)

Noticed from your blog your working out as a voltage. Doing it like that is likely to lead to error. The more calculations you do, the more error will creep in.

Also, as the voltage being presented to the Vs pin is likely to fluctuate to some degree, even more so if being supplied by a battery, working it out as a voltage will increase the error.

If you work it out as 'analogRead(0)/1024', it doesn't matter what the voltage at Vs is, your analogRead value will always be at the correct proportion. Do you see what I mean?

I noticed you're using the suggested caps. I was a little worried about not using them as I thought I'd be getting reading going all over the place. As it turns out, it's rock solid without them. They're nice sensors I've got to say, but then they should be for the price.