Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
1 / 16
XGZP6897D PRESSURE SENSOR
FEATURES
■Wide Ranges: -100kPa…-0.5～0～0.5…200kPa(show in Pressure Range Example)
■2.7V～5.5V Power Supply
■Differential Pressure Type
■For Non-corrosive Gas or Air
■Calibrated Digital Signal(I2C Interface)(Refer to XGZP6897A for Analog signal)
■Temp. Compensated: 0℃～+60℃(32℉～+140℉)
■Temperature Measurable
■Affordable Cost, Easy-to-use
APPLICATIONS
■Medical&Healthcare
■Industrial&Automation
■Domestic Appliance
■Consumer Electronic
■Air Flow or Wind Pressure Measurement
INTRODUCTION
XGZP6897D is a perfect silicon pressure sensor offering a ratiometric digital data(I2C interface) for reading
differential pressure over the specified full scale pressure span.
The XGZP6897D incorporates a silicon piezoresistive pressure sensor chip and an interior signal-
conditional Application Specific Integrated Circuit(ASIC) in a SOP8 package with two air vents, which can be
mounted directly on a standard PCB.
The XGZP6897D is fully calibrated and temperature compensated for specified span, so XGZP6897D
pressure sensor satisfy the perfect accuracy, which is designed for a wide range of application in medical
care&health, home appliances, consumer electronic, industry, air flow measurement, loT and other pneumatic
devices/meters etc by utilizing a microcontroller or microprocessor with I2C interface.
XGZP6897D pressure sensor is for high volume application at an affordable cost and perfect performance.
Customized calibration parameter (e.g.pressure range etc.) are available.
√RoHS

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
2 / 16
PERFORMANCE SPECIFICATION
Unless otherwise specified, measurements were taken by 3.3Vdc with temperature of 25±1℃and humidity from 25%～85﹪RH.
1 The range cover all pressure ranges as shown as “PRESSURE RANGE EXAMPLE” list.
2 Overload voltage(6.5Vdc above) or current(5mA above) may burn the IC and cause the sensor failure thoroughly.
3 The highest data bit as the signed number.
4 The indicated value is widespread value, contact CFSensor for more information on specific pressure range.
BLOCK DIAGRAM
CHARACTERISTIC
MIN.
TYP.
MAX
UNIT
Available Pressure Range①
-100…-0.5～0～0.5…200
kPa
Power Supply②
2.7
3.3
5.5
Vdc
Current Consumption
Operating Current
-
1.8
-
mA
Standby Current
-
100
-
nA
Output Resolution③
Pressure
21
Bit
Temperature
16
Bit
Total Accuracy
10kPa＜Pressure ≤200kPa
-
-
±2
%FSS
Pressure ≤10kPa or＞200kPa
-
-
±2.5
%FSS
Temperature Accuracy
-1
1
℃
Offset Drift after Soldering
-
-
±1
%FSS
Long Term Stability(1000 hr, 25°C)
-
-
±0.5
%FSS
Over Pressure④
Pressure ≤5kPa
-
5X
-
FSS
5kPa＜Pressure ≤200kPa
-
2.5X
-
FSS
Burst Pressure④
Pressure ≤5kPa
-
10X
-
FSS
5kPa＜Pressure ≤200kPa
-
3X
-
FSS
Pressure on P2 Port(Common mode pressure)
-
-
250
kPa
Compensation Temperature
0
-
60
℃
Operating Temperature
-30
-
105
℃
Storage Temperature
-40
-
125
℃
ESD Protection(Human Body Mode)
-
±2000
-
V
Response Time(Normal mode)
-
5
-
mS

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
3 / 16
DDIMENSION(Unit:mm Unspecified Tolerances:±0.1mm)
Note: Port 1(P1) as High pressure cavity, and Port 2(P2) as Low pressure cavity.
PIN DEFINITION
FOOTPRINT(Unit:mm)
NOTE: FOOTPRINT LAYOUT FOR REFERENCE ONLY, CONTACT CFSENSOR FOR ABOVE FILE IF REQUIRED.
PIN2
PIN6
PIN7
PIN8
PIN1/3/4/5
VDD
SDA
SCL
GND
N/C
SCL
The clock signal
NC
Do not connect to external circuitry or ground
GND
Ground
VDD
Voltage supply
SDA
Data signal(Send& Receive)
Recommended Application Circuit

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
4 / 16
ORDER GUIDE (100kPa=0.1MPa=1bar≈14.5PSI)
XGZP6897
D
C
001
KP
DPN
Pressure Type(DG:Gauge(Positive)
DN:Negative
DPN: N+P)
Pressure Unit(KP：kPa
HP:hPa)
Pressure Range(000-999）
I2C Address(C: 0x58）
Output Signal(A: Analog
D:I2C)
Series
PRESSURE RANGE EXAMPLE
Notes: 1. Unit conversion: 1000hPa==100kPa=0.1MPa=1000mbar=1bar≈750mmHg≈14.5PSI≈10mH2O;
2. Available for more custom pressure range e.g. -7～7kPa, , 0-250Pa etc,.
Pressure Range（kPa）
Pressure Range（by other units）
Part Number
-0.25 ～0.25
250～250Pa
XGZP6897DC2.5HPDPN
-0.5 ～0.5
-5～5mbar / 500～500Pa
XGZP6897DC005HPDPN
-1 ～1
-10～10mbar / -100～100mmH2O
XGZP6897DC001KPDPN
-2.5 ～2.5
-25～25mbar / -250～250mmH2O
XGZP6897DC025HPDPN
-5 ～5
-50～50mbar / -500～500mmH2O
XGZP6897DC005KPDPN
-10 ～10
-100～100mbar / -75～75mmHg
XGZP6897DC010KPDPN
-50 ～50
-500～500mbar / -375～375mmHg
XGZP6897DC050KPDPN
-100 ～0
-1～0bar / -14.5～0PSI
XGZP6897DC100KPDN
0 ～1
0～10mbar / 0～100mmH2O
XGZP6897DC010HPDG
0 ～2.5
0～25mbar / 0～250mmH2O
XGZP6897DC025HPDG
0 ～5
0～50mbar / 0～500mmH2O
XGZP6897DC005KPDG
0 ～10
0～100mbar / 0～75mmHg
XGZP6897DC010KPDG
0 ～20
0～200mbar / 0～150mmHg
XGZP6897DC020KPDG
0 ～40
0～400mbar / 0～300mmHg
XGZP6897DC040KPDG
0 ～50
0～500mbar / 0～375mmHg
XGZP6897DC050KPDG
0 ～100
0～1bar /0～14.5PSI
XGZP6897DC100KPDG
★Above P/N is example only, consult CFSensor whether required pressure range is under normal production before place order.
Note: Custom requirement or parameter, please consult CFSensor and comment custom code herewith Part number.

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
5 / 16
I2C INTERFACE
The I2C bus uses SCL and SDA as signal lines, both of which are connected to VDD through pull-up resistors (typ.value: 2.2K)
and remain high level when not communicating. I2C device factory setting slave address: 0X58
From master to slave
S
Start
A
Acknowledge
From slave to master
P
Stop
N
Not Acknowledge
Write Operation
S
SlaveAddr
[6..0]
0
A
RegisterAddr
[7:0]
A
Command
Data[7:0]
A
P
Read Operation
S
SlaveAddr
[6..0]
0
A
RegisterAddr
[7:0]
A
S
SlaveAddr
[6..0]
1
A
RegisterData
[7:0]
A
P
I2C TIME DIAGRAM
The I2C interface protocol has special bus signal conditions. Start (S), stop (P) and binary data conditions are shown below.
At start condition, SCL is high and SDA has a falling edge. Then the slave address is sent. After the 7 address bits, the
direction control bit R/W selects the read or write operation. When a slave device recognizes that it is being addressed, it
should acknowledge by pulling SDA low in the ninth SCL (ACK) cycle.
At stop condition, SCL is also high, but SDA has a rising edge. Data must be held stable at SDA when SCL is high. Data can
change value at SDA only when SCL is low.
I2C PROTOCAL

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
6 / 16
GENERAL REGISTER DESC.
Add.
Desc.
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Default
0x00
ID
R
ID<7:0>
0x58
0x01
Chip_Control
R/W
reserved<7:6>
data_Ready
reserved
data_out
measurement_ctrl
Active<1:0>
0x05
0x02
CFG_OSR
R/W
OSR_T<7:5>
OSR_P<4:2>
MODE[1:0]
OTP
0x03
CFG_MEAS
R/W
reserved<7:6>
T_SB[5:3]
PT_R[2:0]
OTP
0x04
P_data
R
Data out<23:16>
0x00
0x05
P_data
R
Data out<15:8>
0x00
0x06
P_data
R
Data out<7:0>
0x00
0x07
T_data
R
Temp out<15:8>
0x00
0x08
T_data
R
Temp out<7:0>
0x00
0x20-21
Cal_coff
R/W
Temperature Coefficients<7:0>
0x00
Reg0x00: I2C device address, the default address is 0x58H.
Reg0x01: Chip activation control register
Reg0x02: CFG_OSR(Oversampling control register)
Reg0x03: CFG_MEAS (Measurement command register)
Reg0x04-Reg0x06: Pressure data register
Reg0x07-Reg0x08: Temperature data register
Bit #
Name
Description
0x02.[1:0]
MODE[1:0]
01b: Normal mode
0x02.[4:2]
OSR_P[2:0]
Oversampling rate of pressure measurement
000b: over sampling x 256
001b: over sampling x 512
010b: over sampling x 1024
011b: over sampling x 2048
100b: over sampling x 4096
101b: over sampling x 8192
110b: over sampling x 16384
111b: over sampling x 32768
0x02.[7:5]
OSR_T[2:0]
Oversampling rate of temperature measurement
000b: over sampling x 256
001b: over sampling x 512
010b: over sampling x 1024
011b: over sampling x 2048
100b: over sampling x 4096
101b: over sampling x 8192
110b: over sampling x 16384
111b: over sampling x 32768
0x03.[2:0]
PT_R[2:0]
000b: 64/1
001b: 32/1
010b: 16/1
011b: 8/1
100b: 4/1
101b: 1/1
Others: 128/1
0x03.[5:3]
T_SB[2:0]
000b: 0ms
001b: 62.5ms
010b: 125ms
011b: 250ms
100b: 500ms
101b: 750ms
110b: 1000ms
111b: 2000ms
0x03.[7:6]
reserved
reserve
0x03.[7:6]

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
7 / 16
PRESSURE CALCULATION
Read the pressure data from 0x04 to 0x06 register, the calculation formula for the actual pressure is as below:
Sum = (0x04 value * 2^16 + 0x05 value * 2^8 + 0x06 value),
If sum < 8388608, P=sum / 2^21*(PMAX - PMIN)
(Unit: Pa)
If sum ≥8388608，P=(sum-2^24)/2^21*(PMAX - PMIN)
(Unit: Pa)
PMAX and PMIN Definition
Range
PMIN
PMAX
Example(Unit: Pa)
Positive
0
Upper Range
0~10kPa: PMIN=0, PMAX:10000
Negative
Lower Range
0
-20~0kPa: PMIN= -20000, PMAX:0
N to P
Lower Range
Upper Range
-1~1kPa: PMIN=-1000，PMAX:1000
TEMPERATURE CALCULATION
Read the pressure data from 0x07 and 0x08 register, the calculation formula for the actual temperature is as below:
Final_T = (Inter_T - Byte1) / 2 ^ Shift_N + 25
The specific calculation steps are as follows:
1, Inter_T = RAW_T - 65536 (RAW_T > 32768); otherwise, Inter_T = RAW_T, where
RAW_T = 0x07 value * 2^8 + 0x08 value
2, Byte1 is calculated from the 0x20 register value, where
Bits [6:0] are used as the exponent of 2,
Bit [7] is the sign bit, when bit [7] = 1, Byte1 is a negative value, when bit [7] = 0, Byte1 is a positive value.
Assumed the value of 0x20 register is 0x8D (i.e. 10001101), according to the above description, the exponent is 13,
the sign bit is negative, so the value of Byte1 is -(2^13), i.e. -8192.
3, Shift_N = Byte2/10, where Byte2 is the 0x21 register value. Assumed the value of 0x21 register is 0x46,
then Shift_N=70/10=7.
PACKING INFORMATION
Tube Packing
Packing
Plastic Tube
Inner Box
Note
Quantity
45PCS per tube
1800pcs(40pcs tube)
Anti-static bag
Note:The sensor should be stored in an ESD protective container before using them.

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
8 / 16
OVERALL NOTES
Unless otherwise specified, following notes are general attention or presentation for all products from CFSensor.
Mounting
The following steps is for transmitting the air pressure to sensor after sensor soldering on PCB.
▼For some sensors that come with inlet tube, select the flexible pipe to suit the pressure inlet that is firm enough to
prevent the pressure leaks.
▼Atmosphere hole (for Gauge type sensors) and Inlet pipe/hole can’t be blocked with gel or glue etc,..
▼Avoiding excessive external force operation
Soldering
Due to its small size, the thermal capacity of the pressure sensor is low. Therefore, take steps to minimize the effects of
external heat. Damage and changes to characteristics may occur due to heat deformation. Use a non-corrosive resin type of
flux. Since the pressure sensor is exposed to the atmosphere, do not allow flux to enter inside.
▼Manual soldering
☉Raise the temperature of the soldering tip to 190°C max. and solder within 5 seconds.
☉The sensor output may vary if the load is applied on the terminal during soldering.
☉Keep the soldering tip clean.
▼Reflow soldering (SMD Terminal)
☉Considering the thermal effect on offset drift for the low pressure range, the Low Temperature Soldering
curve are recommended as below.
☉Self alignment may not always work as expected, therefore, please carefully the position of the terminals and pattern.
☉The temperature of the profile is assumed to be a value measured with the printed wiring board of the terminal
neighborhood.
☉Please evaluate solderbility under the actual mounting conditions since welding and deformation of the pressure inlet port
may occur due to heat stress depending on equipments or conditions.
▼Rework soldering
☉Complete rework at a time.
☉Use a flattened soldering tip when performing rework on the solder bridge. Do not add the flux.
☉Keep the soldering tip below the temperature described in the specifications.
▼Avoid drop and rough handling as excessive force may deform the terminal and damage soldering characteristics.
▼Keep the circuit board warpage within 0.05 mm of the full width of the sensor.
▼After soldering, do not apply stress on the soldered part when cutting or bending the circuit board.
▼Prevent human hands or metal pieces from contacting with the sensor terminal. Such contact may cause anomalous

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
9 / 16
outlets as the terminal is exposed to the atmosphere.
▼
After soldering, prevent chemical agents from adhering to the sensor when applying coating to avoid insulation
deterioration of the circuit board.
Connecting
▼
Correctly wire as in the connection diagram. Reverse connection may damage the product and degrade the
performance.
▼Do not use idle terminals(N/C) to prevent damages to the sensor.
Cleaning
▼Since the pressure sensor is exposed to the atmosphere, do not allow cleaning fluid to enter inside from atmosphere
hole (for Gauge type sensors) and inlet pipe.
▼Avoid ultrasonic cleaning since this may cause breaks or disconnections in the wiring.
Environment
▼Please avoid using or storing the pressure sensor in a place exposed to corrosive gases (such as the gases given off by
organic solvents, sulfurous acid gas, hydrogen sulfides, etc.) which will adversely affect the performance of the pressure
sensor chip.
▼Since this pressure sensor itself does not have a water-proof construction(even available media can be liquid), please do
not use the sensor in a location where it may be sprayed with water, etc.
▼Avoid using the pressure sensors in an environment where condensation may form. Furthermore, its output may fluctuate
if any moisture adhering to it freezes.
▼The pressure sensor is constructed in such a way that its output will fluctuate when it is exposed to light. Especially when
pressure is to be applied by means of a transparent tube, take steps to prevent the pressure sensor chip from being exposed
to light.
▼Avoid using pressure sensor where it will be susceptible to ultrasonic or other high-frequency vibration.
▼Keeping the sensors sealed in static shielding bags with an oxygen-free condition and use the sensor as soon as possible
once unfold the package, because the sensors' PINs may be oxidated a bit under atmosphere environment(slight oxidation
wouldn't affect soldering and performance)
More Precautions
▼That using the wrong pressure range or mounting method may result in accidents.
▼The only direct pressure medium you can use is non-corrosive gas or air as illuminated above(Note: some sensors are
compatible with liquid media). The use of other media, in particular, corrosive gases and liquid (organic solvent based,
sulfurous acid based, and hydrogen sulfide based, etc.) or contains foreign substances will cause malfunction and damage.
Please do not use them and check with CFSensor.
▼The pressure sensor is positioned inside the pressure inlet. Never poke wires or other foreign matter through the pressure
inlet since they may damage the sensor or block the inlet. Avoid use when the atmospheric pressure inlet(only for Gauge
type pressure sensor) is blocked.
▼Use an operating pressure which is within the rated pressure range. Using a pressure beyond this range may cause
damage.
▼Since static charge can damage the pressure sensor, bear in mind the following handling precautions.
☉When storing the pressure sensor, use a conductive material to short the pins or wrap the entire sensor in aluminum foil.
Common plastic containers should not be used to store or transport the sensor since they readily become charged.
☉When using the pressure sensor, all the charged articles on the bench surface and the work personnel should be
grounded so that any ambient static will be safely discharged.

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
10 / 16
▼Based on the pressure involved, give due consideration to the securing of the pressure sensor.
【SAFETY NOTES 】
Using these sensors products may malfunction due to external interference and surges, therefore, please confirm the
performance and quality in actual use. Just in case, please make a safety design on the device (fuse, circuit breaker, such as
the installation of protection circuits, multiple devices, etc.), so it would not harm life, body, property, etc even a malfunction
occurs. To prevent injuries and accidents, please be sure to observe the following items:
●The driving current and voltage should be used below the rated value.
●Please follow the terminal connection diagram for wiring. Especially for the reverse connection of the power supply, it will
cause an accident due to circuit damage such as heat, smoke, fire, etc.
●In order to ensure safety, especially for important uses, please be sure to consider double safety circuit configuration.
●Do not apply pressure above the maximum applied pressure. In addition, please be careful not to mix foreign matter into
the pressure medium. Otherwise, the sensor will be discarded, or the media will blew out and cause an accident.
●Be careful when fixing the product and connecting the pressure inlet. Otherwise, accidents may occur due to sensor
scattering and the blowing out of the media.
●If the sensor come with sharp PIN, please be careful not to hurt your body when using it.
【WARRANTY 】
The information in this sheet has been carefully reviewed and is believed to be accurate; however, no responsibility is
assumed for inaccuracies. Furthermore, this information does not convey to the purchaser of such devices any license under
the patent rights to the manufacturer. CFSensor reserves the right to make changes without further notice to any product
herein. CFSensor makes no warranty, representation or guarantee regarding the suitability of its product for any particular
purpose, nor does CFSensor assume any liability arising out of the application or use of any product or circuit and specifically
disclaims any and all liability, including without limitation consequential or incidental damages. Typical parameters can and
do vary in different applications. All operating parameters must be validated for each customer application by customer’s
technical experts. CFSensor does not convey any license under its patent rights nor the rights of others.
【CONTACT 】
CFSensor
22F/14Bldg High-Tech Park High-Tech Area Wuhu P.R.C.241000
Tel/Fax:+86 18226771331
Email:INFO@CFSensor.com
North America ⅡEurope ⅡSoutheast Asia ⅡMiddle East ⅡLatin America

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
11 / 16
IIC Example Code
(C51 Language)
#include <reg52.h>
#include <math.h>
#define DELAY_TIME 600
//Time-Delay Parameter
时延参数，可根据需要做适当调整
#define TRUE 1
#define FALSE 0
#define uchar unsigned char
#define uint unsigned int
float SPAN = 40;
//SPAN is the span of the sensor 传感器的量程0~40KPa
sbit SCL = P1 ^ 7;
//IIC clock line
定义IIC 总线时钟线
sbit SDA = P1 ^ 6;
//IIC clock line
定义IIC 总线时钟线
//Time-Delay Function
时延函数
void DELAY(uint t)
{
while (t != 0)
t--;
}
void I2C_Start(void)
//IIC Start signal
发送IIC 总线起始信号
{
SDA = 1;
//SDA output high
SDA 输出高电平
DELAY(DELAY_TIME);
SCL = 1;
//SCL output high
SCL 输出高电平
DELAY(DELAY_TIME);
SDA = 0;
//SDA output low
SDA 输出低电平
DELAY(DELAY_TIME);
SCL = 0;
//SCL output low
SCL 输出低电平
DELAY(DELAY_TIME);
}
void I2C_Stop(void)
//IIC Stop signal
发送IIC 总线停止信号
{
SDA = 0;
DELAY(DELAY_TIME);
SCL = 1;
DELAY(DELAY_TIME);
SDA = 1;

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
12 / 16
DELAY(DELAY_TIME);
SCL = 0;
DELAY(DELAY_TIME);
}
void SEND_0(void)
//IIC send data "0"
向IIC 总线发送"0"
{
SDA = 0;
DELAY(DELAY_TIME);
SCL = 1;
DELAY(DELAY_TIME);
SCL = 0;
DELAY(DELAY_TIME);
}
void SEND_1(void)
//IIC send data "1"
向IIC 总线发送"1"
{
SDA = 1;
DELAY(DELAY_TIME);
SCL = 1;
DELAY(DELAY_TIME);
SCL = 0;
DELAY(DELAY_TIME);
}
bit Check_Acknowledge(void)
//Read ACK signal
读取ACK 信号
{
char F0 = 0;
SDA = 1;
DELAY(DELAY_TIME);
SCL = 1;
DELAY(DELAY_TIME / 2);
F0 = SDA;
DELAY(DELAY_TIME / 2);
SCL = 0;
DELAY(DELAY_TIME);
if (F0)
return FALSE;
return TRUE;
}
void WriteI2CByte(uchar b) reentrant
//Write One Byte of Data
发送一个字节

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
13 / 16
{
char i;
for (i = 0; i < 8; i++)
if ((b << i) & 0x80)
//Send high bits first
先发送高位
SEND_1();
else
SEND_0();
}
uchar ReadI2CByte(void) reentrant
//Receive one byte
读取一个字节
{
char b = 0, i, F0 = 0;
for (i = 0; i < 8; i++)
{
SDA = 1;
DELAY(DELAY_TIME);
SCL = 1;
DELAY(DELAY_TIME);
F0 = SDA;
DELAY(DELAY_TIME);
SCL = 0;
if (F0)
{
b = b << 1;
//Receive high bits first
先读取高位
b = b | 0x01;
}
else
b = b << 1;
}
return b;
}
//Write a register’s address and a command byte to the sensor
//向传感器写寄存器地址和一个命令字节
//"addr": register's address, "thedata": the command byte
void Write_One_Byte(uchar addr, uchar thedata)
{
bit acktemp = 1;
I2C_Start();
//IIC START Signal
发送IIC 启动信号
WriteI2CByte(0x58 << 1 + 0);
//The SLAVER address is 0x58
//传感器的IIC 总线地址为0x58
// The lowest bit of address is 0 means writing
地址值最低位为0 表示写

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
14 / 16
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
WriteI2CByte(addr);
//Send the register’s address
发送寄存器的地址值
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
WriteI2CByte(thedata);
//Write command to the sensor
向传感器写命令字节
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
I2C_Stop();
//IIC STOP Signal
发送IIC 停止信号
}
//Read one byte of data from the sensor
从传感器读取一个字节
uchar Read_One_Byte(uchar addr)
{
bit acktemp = 1;
uchar mydata;
I2C_Start();
//IIC START Signal
发送IIC 启动信号
WriteI2CByte(0x58 << 1 + 0);
//The SLAVER address is 0x58
//传感器的IIC 总线地址为0x58
// The lowest bit of address is 0 means writing
地址值最低位为0 表示写
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
WriteI2CByte(addr);
//Send the register’s address
发送寄存器的地址值
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
I2C_Start();
//IIC START Signal
发送IIC 启动信号
WriteI2CByte(0x58 << 1 + 1);
//The SLAVER address is 0x58
//传感器的IIC 总线地址为0x58
// The lowest bit of address is 1 means Reading
地址值最低位为1 表示读
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
mydata = ReadI2CByte();
//Read the above register’s data
读取上述寄存器的数据值
acktemp = Check_Acknowledge();
//check the SLAVER’s ACK
检查传感器的ACK
I2C_Stop();
//IIC STOP Signal
发送IIC 停止信号
return mydata;
}
//Ms Time-Delay Function
Ms 延时函数
void Delay_xms(uint x)
{
uint i, j;
for (i = 0; i < x; i++)
for (j = 0; j < 112; j++)
;
}
void main(void)
//The main function
主函数
{

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
15 / 16
uchar pressure_H, pressure_M, pressure_L,temperature_H,temperature_L;
//Temporary variables used to save bytes of pressure and temperature from the sensor
//临时变量，用于存放从传感器中读出的压力值和温度值的字节数据
long int pressure_ad,temperature_ad;
//Temporary variables used to save AD values of pressure and temperature from the sensor
//临时变量，用于存放从传感器中读出的压力和温度的AD 值
float pressure,temperature,Shift_N;
//pressure: actual pressure
变量pressure 用于存放实际压力值
//temperature: actual temperature
变量temperature 用于存放实际温度值
uchar byte1,byte2;
int EOFF;
Delay_xms(1000);
while (1)
{
Write_One_Byte(0x01, 0x01);
//Send 0x01 to the register whose address is 0x01 to start a data collection
//向传感器0x01 寄存器发送0x01 以启动采集数据
Delay_xms(20);
pressure_H = Read_One_Byte(0x04);
//Read bytes of pressure from the sensor
pressure_M = Read_One_Byte(0x05);
//从传感器中读出压力值的字节数据
pressure_L = Read_One_Byte(0x06);
pressure_ad = pressure_H * 65536 + pressure_M * 256 + pressure_L;
//compute the AD pressure of the sensor
计算传感器AD 转换后的压力值
temperature_H = Read_One_Byte(0x07);
//Read bytes of temperature from the sensor
temperature_L = Read_One_Byte(0x08);
//从传感器中读出温度值的字节数据
temperature_ad = temperature_H * 256 + temperature_L;
//compute the AD temperature of the sensor
计算传感器AD 转换后的温度值
//compute the actual pressure of the sensor
计算传感器实际的压力值
//pressure’s unit is Pa
变量pressure 的单位为Pa
if (pressure_ad >= 8388608)
pressure = (float) (pressure_ad - 16777216) / 2^21 *(PMAX-PMIN) ;
else
pressure = (float) pressure_ad / 2^21 * (PMAX-PMIN) ;
//compute the actual temperature of the sensor
计算传感器实际的温度值
//temperature’s unit is Centigrade
变量temperature 的单位为℃
if(temperature_ad > 32768)
temperature_ad -= 65536;
byte1 = Read_One_Byte(0x20);
//Read temperature parameter from the sensor

Calibrated Pressure Sensor Series
V3.1/20250812
XGZP6897D_DataSheet_EN_V3.1
www.CFSensor.com
16 / 16
byte2 = Read_One_Byte(0x21);
//Read temperature parameter from the sensor
if (byte1 == 0x0C)
//According byte1 to evaluate the variable EOFF
EOFF = 4096;
else if (byte1 == 0x8C)
//根据byte1 的值，求变量EOFF 的值
EOFF = -4096;
else if(byte1 == 0x0D)
EOFF = 8192;
else if(byte1 == 0x8D)
EOFF = -8192;
else if(byte1 == 0x0E)
EOFF = 16384;
else if(byte1 == 0x8E)
EOFF = -16384;
Shift_N = byte2 / 10;
//compute the variable Shift_N 计算变量Shift_N 的值
temperature = (temperature_ad - EOFF) / 2 ^ Shift_N + 25;
//the actual temperature of the sensor
传感器的实际温度值
printf("Actual pressure is %f Pa\r\n",pressure);
printf("Actual temperature is %f Centigrade\r\n\r\n",temperature);
Delay_xms(1000);
}
}
