LPS331AP-Pressure

Currently I am working on getting the LPS331AP-Pressure to read out correct values.

The product documentation for it can be found here: http://www.pololu.com/file/0J622/LPS331AP.pdf

and it is sold here: http://www.pololu.com/product/2126/resources

My current code looks like:
hardware.i2c89.configure(CLOCK_SPEED_400_KHZ); function readPressureInchesGH() { local a = (0x5d << 1); local press = hardware.i2c89.read(a, "\\x28", 3); local pressure = (press[0] << 16) + (press[1] << 8) + (press[2]); //2's compliment if the number is negative if (0x800000 && pressure) pressure = -(0x1000000 - pressure); pressure = pressure/4096; return pressure; } function readPAT() { //need to turn device on hardware.i2c89.write(0x5d << 1,"\\x20\\xe0"); //wait .5 seconds imp.sleep(0.5); //do work of getting pressure local pressureA = readPressureInchesGH(); //do work of getting altitude server.log("pressure: " + pressureA + " inHG"); } readPAT();

The hardware currently has the imp pin 8 going to SCL of LPS, imp pin 9 going to SDA of LPS, imp 3v3 pin to vin pin of LPS, and imp pin GND to GND pin of LPS.

My read out value is: pressure: 1140 inHg
The value should be closer to 30.43 inHg today

Any ideas why it is getting such a bad read?

Holy cow, that really looks complicated. There are several R/W registers where you are supposed to configure some flash ROM registers?

Have you been able to find any Arduino examples using that chip? If you could see an Arduino example, that might shed some light on the reading and writing of the module.

Sparkfun has a couple of breakout boards w/ arduino code examples:
https://www.sparkfun.com/products/11824

Yes there is some really nice code for Arduino of course at this site: https://github.com/pololu/lps331-arduino but I don’t quite get how to make it work. I was originally reading them all out individually but it was reading strings instead of numbers.

I finally got it and I have posted my pictures and code at my blog.
/Word Press Blog for pressure sensor-lps331ap