Here is the code to read a Sensortechnics HCA-Baro air pressure sensor.
Manual
const
HCATWIAddr : byte =$F8;
HCASens :float=87.38; //HCA800
//HCASens :float=52.428; //HCA600
HCAMin :float= 800; //HCA800
//HCAMin :float= 600; //HCA600
Function ReadHCA:float;
var Data :array[0..1] of byte;
raw: word; //Raw Value
res:float;
begin
res:=0;
if TWIstat(HCATWIAddr) then
bool:= TWIinp(HCATWIAddr, Data);
if bool then
HI(raw):=Data[0];
LO(raw):=Data[1];
raw:=raw and $7FFF; //Mask out Bit 15
res:= (float(raw)-1638.0)/HCASens +HCAMin;
endif;
endif;
return(res);
end;
Manual
Code
const
HCATWIAddr : byte =$F8;
HCASens :float=87.38; //HCA800
//HCASens :float=52.428; //HCA600
HCAMin :float= 800; //HCA800
//HCAMin :float= 600; //HCA600
Function ReadHCA:float;
var Data :array[0..1] of byte;
raw: word; //Raw Value
res:float;
begin
res:=0;
if TWIstat(HCATWIAddr) then
bool:= TWIinp(HCATWIAddr, Data);
if bool then
HI(raw):=Data[0];
LO(raw):=Data[1];
raw:=raw and $7FFF; //Mask out Bit 15
res:= (float(raw)-1638.0)/HCASens +HCAMin;
endif;
endif;
return(res);
end;