Dcube Tech Ventures
Published

Pressure Measurement Using CPS120 and Arduino Nano

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

IntermediateProtip4 hours7,069
Pressure Measurement Using CPS120 and Arduino Nano

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
CPS120
×1
I²C Cable
×1
ControlEverything.com I2C Shield for Arduino Nano
×1

Story

Read more

Schematics

CPS120 Schematic

Code

Code snippet #1

Arduino
#include
// CPS120 I2C address is 0x28(40)
#define Addr 0x28
void setup() 
{    
// Initialise I2C communication    
Wire.begin();    
// Initialise Serial Communication, set baud rate = 9600    
Serial.begin(9600);
}
void loop()
{        
unsigned int data[4];        
// Start I2C Transmission    
Wire.beginTransmission(Addr);        
// Request 4 byte of data    
Wire.requestFrom(Addr, 4);
// Read 4 bytes of data    
// pressure msb, pressure lsb, temp msb, temp lsb    
if(Wire.available() == 4)    
{      
data[0] = Wire.read();      
data[1] = Wire.read();      
data[2] = Wire.read();      
data[3] = Wire.read();      
delay(300);            
// Stop I2C Transmission      
Wire.endTransmission();          
// Convert the data to 14 bits      
float pressure = ((((data[0] & 0x3F) * 265 + data[1]) / 16384.0 ) * 90.0 ) + 30.0 ;      
float cTemp = ((((data[2] * 256) + (data[3] & 0xFC)) / 4.0 ) * (165.0 / 16384.0)) - 40.0;      
float fTemp = cTemp * 1.8 + 32;             
// Output data to serial monitor      
Serial.print("Pressure is :   ");      
Serial.print(pressure);      
Serial.println(" kPa");      
Serial.print("Temperature in Celsius : ");      
Serial.print(cTemp);      
Serial.println(" C");      
Serial.print("Temperature in Fahrenheit : ");      
Serial.print(fTemp);      
Serial.println(" F");      
delay(500);     
}  
}

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
Contact

Comments

Please log in or sign up to comment.