This sketch shows how to read pressure and temperature from the MPL115A1 Pressure Sensor (SPI version) and as a bonus throws in a simple altimeter. I got the breakout board with this device on it yesterday and found the provided sample code a little complex for my simple mind. This sketch should be very cut-pasteable for those who just want to get data from the thing.
I have your code running (thanks!), but i’m not seeing any activity from the sensor. I get the same result (7.25 psi) if I have the sensor connected or or not. I probably somehow burned up the sensor (i have a warehouse full of electronic things I have bricked), but if you have seen this before, i’d appreciate any advice.
I can really only offer generic advice. The value that you’re showing (7.25 psi) is what you get when the software reads zeros off the device. The range is 50-115 kPa which is 7.25-16.68 psi. So either the part is dead or not connected correctly. Here are some suggestions:
Check the PCB. I had to actually re-solder one of the surface mount components on mine, the two caps on the board had been accidentally connected together on one end during the surface mount process. So make sure the layout and soldering job matches the schematic for the board. The schematic is on the sparkfun product page.
Check your wiring job. Make sure you’re using 5V for VCC on a 5V Arduino or 3.3V for VCC on a 3.3V Arduino. Make sure your connections are good. I ended up soldering on headers and plugging the thing into a breadboard because my IC test clips were flakey. Make sure you’ve connected the right pins, it’s way too easy to get them mixed up.
I have used this code to interface the MPL1151A1 sensor to Arduino. I’m finding that the pressure readings are accurate, but the temperature consistently reads approximately 6 degrees Celcius too low. I’ve gone through the code carefully comparing it to the datasheet: I can find no fault. I also tried allowing the chip more time to perform the conversion but nothing makes any difference. Oddly the datasheet doesn’t specify the temperature accuracy, but six degrees seems a long way out.
It seems odd that the chip can do the hard job of reading pressure yet yield poor results on temperature. My query is more from curiosity than anything else: I’d be much more concerned if the pressure readings were wrong and decent temperature sensors are cheap enough. But has anyone else encountered this problem?
As for the effects of light, my reading of the datasheet and my understanding of semiconductor technology is that the effects are not permanent - it can simply affect the reading.
Concerning the real temperature computation, the datasheet is misleading. It incorrectly states that sensor ADC count at 25C is 472. In my case the count at 24C is 510 and the sensor sensitivity is about 5.5 counts/C vs. 5.35 from the datasheet. This way for the ADC count K one gets K = 510 - 5.5*(T - 24), and computing temperature from this equation becomes accurate. For your sensor the constants 510 and 5.5 might be different. A calibration in two temperature points is needed to resolve the issue.
The example code referenced for download in the first post no longer seems to be available for download. By any chance does some one have this that they could repost? Thanks.
chumann:
The example code referenced for download in the first post no longer seems to be available for download. By any chance does some one have this that they could repost? Thanks.
I second that. I wouldnt mind the temperature part.
Thanks for the barometric code that is there.
Mine seems to be saying 52.03 all the time. Any ideas what valid ranges should be ? I am in Melbourne.
I suppose that MSHoerberJr was trying to be helpful, but (s)he hasn’t read the data sheet. The functionality of the MPL115A1 requires it to measure the package temperature, and that measurement is available to the user. See http://www.freescale.com/files/sensors/ … L115A1.pdf