How To Read the TPTd I2C Pressure Sensor With Arduino

How To Read the TPTd I2C Pressure Sensor With Arduino

This is a Guide on how to Read the TPTd I2C Pressure Sensor with an Arduino. The TPTd Pressure Sensor will be connected with a breadboard with jumper wires and bread board to the Arduino Uno . An I2C Pressure sensor Example sketch will be uploaded, this will output the pressure sensor information as well as the pressure.

The Arduino example sketch to read the TPTd Pressure is available for download

TPTd I2C Pressure sensor features

  • M12 or Flying Lead connections
  • Pressure Process connections G1/4 NP T1/4 NPT1/8 M10
  • 750mBarAto 1250mBarA barometric
  • 1 to 700 Bar Pressure Range
  • Fully customisable

Logic analyser has also been attached to show the I2C communications.

I2C is a popular protocol to communicate with electronic devices such as EEPPRRMS, Digital sensors and displays to name a few. Multiple devices can be connected on the same hardware lines which simplifies the interconnections. as shown below

I2C Parameters

  • I2C Address 0x26
  • 10 Bar 

View the TPTd I2C Pressure Range

Parts Required

  • Arduino uno
  • Jumper Wires
  • TPTd Pressure Sensor
  • Breadboard
  • Logic analyser ( optional)
  • NO PULL UP resistors required.

Wiring Connections

Connect the TPTd to the Arduino by following the table. The Pressure sensor is powered from the Arduino PCB

Arduino Uno TPTd I2C M12 TPTd Cable
3V3/5V Pin 1 +Ve Red
Gnd Pin 2 -Ve Blue
A4 SDA Pin 4 SDA Yellow
A5 SCL Pin 3 SCL Green
TPTd I2C Pressure sensor witing table

Arduino sketch

The Example Arduino sketch has been written to be easy to read and to expand upon

  • Read read the I2C Registers
  • Calculate the Real pressure
  • Output the Pressure value to the serial port

Once the connections have been made upload the I2C Pressure sensor Arduino sketch. And pressure will output to the serial port.

 The address #define will need to be updated with the I2C Address of the TPTd I2C Pressure sensor

Change the I2C address indicated in Green to the address of the TPTd pressure sensor

If the address of the TPTd has been forgotten or unknown the I2C address can be found using the I2C Address scanner. 

Arduino Sketch I2c Pressure sensor serial output

TPTd I2C Pressure Register overview

View the TPTd I2C Pressure Range

TPTd I2C Pressure Sensor has a 24 but ADC that is read via I2C other useful peripherals can also be read such as 

  • Serial Number 75411
  • Zero Calibrated Pressure Value e.g. 0 Bar
  • Fullscale Calibrated  Pressure Value e.g 10 Bar
  • Pressure Unit Bar mBar PSI 
  • Zero ADC Value e.g. 1682969
  • Full Scale ADC value e.g. 15096625
  • ADC Value e.g. 1513435

Calculate Pressure Equation from I2C Registers

Pressure = Pressure Range -Zero Pressure RangeZero ADC Value – Full scale ADC Value Full *(ADCValue-Zero ADC Value)+Zero Pressure Range

This is how the I2C Arduino sketch calculates the pressure value

Register Locations

These registers are required to calculate the pressure output.

Register Name Data Size High Addr Location Low Addr Location
Serial Number 24bit uint24_t 0x00 0x01
Zero Pressure Range Value 16bit uint16_t 0x2A
Full Scale Pressure Range Value 16bit uint16_t 0x2C
Pressure Unit 16bit uint16_t 0x29
Zero ADC Value 24bit uint24_t 0x24 0x25
Full Scale ADC Value 24bit uint24_t 0x26 0x27
ADC Value Single Read 24bit uint24_t 0xAA
ADC Value Quad Read 4 averaged samples 24bit uint24_t 0xAD
ADC Value Oct Read 8 averaged samples 24bit uint24_t 0xAE
I2C Pressure Sensor Register Locations

Arduino I2C Pressure Sensor Output

Example I2C Read 

The example I2C arduino code is available for download please contact us and we will gladly share it, it has been written for easy expansions and readability.

Every time a read is made the status register will be read first followed byt the data bytes

Using the Logic analyser the I2C reads are captured on the SDA and SCL pins. 

16 bit registers

These registers require 2 data reads to obtain all their data. The data registers contain 16bits

  • Zero Pressure Ranger Location 0x2A
  • Full Pressure Range Location 0x2C
  • Pressure Unit Location 0x29

Reading a 16 bit Register (Full Scale Pressure)

The I2C data captured here shows the Full Scale pressure value being read from the TPTd Pressure Sensor the value is 0x0A , which is 10 decimal.

As demonstrated in the signal capture to process is the following

  1. I2C Start 
  2. I2C Send Address with write bit set
  3. I2C Send Register to be read  , in this case 0x2C
  4. I2C Start or Restart
  5. I2C Send Address with Read bit set
  6. I2C Read Get Status
  7. I2C Read Get Data
  8. I2C Read Get Data
  9. I2C Stop

The 2 data bytes Data High and Data Low are to be combined into one 16bit data value as shown below

Uint16_t data= 0x00<<8

data = data+0x0A

Reading the 16 bit Register Data capture

24 bit Registers

The Data registers are 16 bits therefore 24 bits values have to be stored across two 16 bit locations as demonstrated in the register table.

However the ADC value is in one location and is access with one read requesting 3 bytes.

24 bit registers are

  • ADC Single 0xAA Single Read
  • ADC Quad 0xAA  Averaged 4 Values
  • ADC Oct 0xAE Averages 8 Values
  • Zero ADC Value 0x24 0x25
  • Full Scale ADC Value 0x24 low bits  0x25 high bits

Reading the ADC Data capture

Status Register

The Status Register value can be decoded with the following table

 

Leave a comment

Please note, comments need to be approved before they are published.

  • ITEM BAR TITLE

    Share shipping, delivery, policy information.

  • ITEM BAR TITLE

    Share shipping, delivery, policy information.

  • ITEM BAR TITLE

    Share shipping, delivery, policy information.

  • ITEM BAR TITLE

    Share shipping, delivery, policy information.