Hi everyone,
I’m new to this type of forum. I am currently working on a device using the MS5803-14BA break out board to measure outside pressure. I am using an ATMEGA328p chip as micro controller and AVR for programming. I have got my code working to the point where I am receiving the I2C read, which is giving me three number results. The problem I am experiencing, however, is how do I transform or use the numbers I am receiving into and actual measurement or a mathematical expression for results. I can’t find for the life of me an example to do so. I have looked at the data sheet and online for examples and can’t find anything. I will put a copy of my code below, if anyone has any pointers or can point me in the right direction it would be greatly appreciated. Thank you.
Moderator edit to add code tags
static inline void initMS5803(void) {
i2cStart(); //initialization of MS5803
i2cSend(MS5803_W);
i2cSend(0b00011110);
i2cStop();
}
uint64_t Pressure1, Pressure2, Pressure3;
long Pressure;
void readMS5803(void){
i2cStart();
i2cSend(MS5803_W); //start pressure conversion
i2cSend(0b01001000);
i2cStop();
_delay_ms(10);
i2cStart(); //Read Sequence
i2cSend(MS5803_W);
i2cSend(0x00);
i2cStart(); //I2C from read
i2cSend(MS5803_R);
Pressure1=i2cReadAck();
Pressure2=i2cReadAck();
Pressure3=i2cReadNoAck();
i2cStop();
printWord(Pressure1);
printString(" ");
printWord(Pressure2);
printString(" ");
printWord(Pressure3);
printString("\r\n");
//Pressure =
printf("\rAtm: "); //print results
printf("\nAlt: ");
_delay_ms(1000);
}