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?