Go Down

Topic: question on MPL3115A2 altitude sensor offset register (Read 666 times) previous topic - next topic

aixelsyd

I'm using a MPL3115A2 sensor from sparkfun.
-product page :https://www.sparkfun.com/products/11084?
-Data Sheet http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Pressure/MPL3115A2.pdf

Unfortunately i'm new to programming and am having a bit of trouble  :(

I have the sensor set in altimeter mode and seems to be working properly so far.  I'm having trouble with the pressure offset feature.  From the data sheet I understand that sending the current ground level in Pa (divided by 2) to the 0x14 and 0x15 addresses would set the ground level for a relative altitude measurement.  My project also incorporates multiple bmp085 sensor, so no problem.  When on the ground I read the bmp085 sensor and get ground level pressure in Pa, then send that value to the MPL3115A2. Unfortunately I'm unsure how to send my Pa 'int' value in hex to the sensor.
i.e.
Code: [Select]

groundPressure = value_from_bmp085
groundPressure *= .5;

value_to_send_x14 = Magic_pixie_dust(groundPressure);
value_to_Send_x15 = More_magic_pixie_dust(groundPressure);

// BAR_IN_MSB (0x14):
  IIC_Write(0x14, ???? );

  // BAR_IN_LSB (0x15):
  IIC_Write(0x15, ???? );


Any help would be greatly appreciated.

afremont

You probably want to do something like this where INTVALUE is the 16 bit integer to be written:

// BAR_IN_MSB (0x14):
  IIC_Write(0x14, INTVALUE >> 8 );       // Write the upper 8 bits of INTVALUE

  // BAR_IN_LSB (0x15):
  IIC_Write(0x15, INTVALUE & 0xFF );   // Write the lower 8 bits of INTVALUE
Experience, it's what you get when you were expecting something else.

aixelsyd

Ah yes, reading through the bitwise operators on the arduino reference page and your suggestion makes sense.  Thank you very much for the help and I apologize for such a newbie question.

Go Up