clear all
mypi = raspi
mypi.AvailableI2CBuses;
mypi.I2CBusSpeed;
scanI2CBus(mypi,'i2c-1');
BMP180 = i2cdev(mypi,'i2c-1','0x77');
AC1m=int16(readRegister(BMP180, hex2dec('AA'),'int8'));
AC1l=int16(readRegister(BMP180, hex2dec('AB'),'int8'));
AC1 = int32(typecast((bitshift(AC1m,8)+ AC1l),'int16'));
AC2m=int16(readRegister(BMP180, hex2dec('AC'),'int8'));
AC2l=int16(readRegister(BMP180, hex2dec('AD'),'int8'));
AC2 = int32(typecast((bitshift(AC2m,8)+ AC2l),'int16'));
AC3m=int16(readRegister(BMP180, hex2dec('AE'),'int8'));
AC3l=int16(readRegister(BMP180, hex2dec('AF'),'int8'));
AC3 = int32((bitshift(AC3m,8)+ AC3l));
AC4m=int16(readRegister(BMP180, hex2dec('B0'),'int8'));
AC4l=int16(readRegister(BMP180, hex2dec('B1'),'int8'));
AC4 = int32(typecast((bitshift(AC4m,8)+ AC4l),'uint16'));
AC5m=int16(readRegister(BMP180, hex2dec('B2'),'int8'));
AC5l=int16(readRegister(BMP180, hex2dec('B3'),'int8'));
AC5 = int32(typecast((bitshift(AC5m,8)+ AC5l),'uint16'));
AC6m=int16(readRegister(BMP180, hex2dec('B4'),'int8'));
AC6l=int16(readRegister(BMP180, hex2dec('B5'),'int8'));
AC6 = int32(typecast(bitshift(AC6m,8)+ AC6l,'uint16'));
B1m=int16(readRegister(BMP180, hex2dec('B6'),'int8'));
B1l=int16(readRegister(BMP180, hex2dec('B7'),'int8'));
B1 = int32((bitshift(B1m,8)+ B1l));
B2m=int16(readRegister(BMP180, hex2dec('B8'),'int8'));
B2l=int16(readRegister(BMP180, hex2dec('B9'),'int8'));
B2 = int32((bitshift(B2m,8)+ B2l));
MBm=int16(readRegister(BMP180, hex2dec('Ba'),'int8'));
MBl=int16(readRegister(BMP180, hex2dec('BB'),'int8'));
MB = int32((bitshift(MBm,8)+ MBl));
MCm=int16(readRegister(BMP180, hex2dec('BC'),'int8'));
MCl=int16(readRegister(BMP180, hex2dec('BD'),'int8'));
MC = int32((bitshift(MCm,8)+ MCl));
MDm=int16(readRegister(BMP180, hex2dec('BE'),'int8'));
MDl=int16(readRegister(BMP180, hex2dec('BF'),'int8'));
MD = int32((bitshift(MDm,8)+ MDl));
if readRegister(BMP180, hex2dec('D0'),'int8') ~=hex2dec('55')
error('Sonething wrong with temperature sensor')
end
writeRegister(BMP180, hex2dec('F4'), hex2dec('2E'),'int8')
pause(4.5E-3)
pause(5*60)
MSBt=int16(readRegister(BMP180, hex2dec('F6'),'int8'));
LSBt=int16(readRegister(BMP180, hex2dec('F7'),'int8'));
UT=int32((bitshift(MSBt, 8)) + (LSBt));
X1=int32((UT-int32(AC6))*int32(AC5)/(2^15));
X2=int32(int32(MC)*2^11/((X1+int32(MD))));
B5=double(X1+X2);
T=(B5+8)/(2^4)*0.1
Best Answer