Dcube Tech Ventures
Published

Pressure Measurement using CPS120 and Raspberry Pi

CPS120 is a high-quality and low-cost capacitive absolute pressure sensor with fully compensated output.

IntermediateProtip4 hours805
Pressure Measurement using CPS120 and Raspberry Pi

Things used in this project

Hardware components

Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
CPS120
×1
I²C Cable
×1
ControlEverything.com I2C Shield for Raspberry Pi 3 & Pi2
×1

Story

Read more

Schematics

CPS120 schematic

Code

Code snippet #1

Java
import com.pi4j.io.i2c.I2CBus;
import com.pi4j.io.i2c.I2CDevice;
import com.pi4j.io.i2c.I2CFactory;
import java.io.IOException;
public class CPS120
{	
public static void main(String args[]) throws Exception	
{		
// Create I2CBus		
I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);		
// Get I2C device, CPS120 I2C address is 0x28(40)		
I2CDevice device = bus.getDevice(0x28);				
// Send start command		
device.write(0x28, (byte)0x80);		
Thread.sleep(800);				
// Read 2 bytes of data, msb first		
byte[] data = new byte[2];		
device.read(data, 0, 2);				
// Convert data to kPa		
double pressure = (((data[0] & 0x3F) * 256 + data[1]) * (90 / 16384.00)) + 30;				
// Output data to screen		
System.out.printf("Pressure is : %.2f kPa %n",pressure);	
}
}

Github file

Credits

Dcube Tech Ventures
34 projects • 16 followers
Dcube Tech Ventures Pvt Limited is collaboration of Hardware, Embedded and Software endeavour's to create the Internet of things. www.dcubestore.com

Comments