Raspberry Pi CPS120 Pressure Sensor Python Tutorial

by Dcube Tech Ventures in Circuits > Electronics

23 Views, 0 Favorites, 0 Comments

Raspberry Pi CPS120 Pressure Sensor Python Tutorial

Raspberry Pi CPS120 Pressure Sensor Python Tutorial

CPS120 is a high quality and low cost capacitive absolute pressure sensor with fully compensated output. It consumes very less power and comprises of an ultra small Micro-Electro-Mechanical Sensor(MEMS) for pressure measurement. A sigma-delta based ADC is also embodied in it to accomplish the requirement of compensated output. Here is the demonstration with a java code using Raspberry Pi.

What You Need..!!

CPS120_I2CS_A_1.png
pi.jpg

1. Raspberry Pi

2. CPS120

3. I²C Cable

4. I²C Shield for Raspberry Pi

5. Ethernet Cable

Connections:

CPS120_I2CS_A_1.png
pi.jpg
sensor.jpg
complete_connection.jpg

Take a I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.

Then connect the one end of I2C cable to CPS120 sensor and the other end to the I2C shield.

Also connect the Ethernet cable to the pi or you can use a WiFi module.

Connections are shown in the picture above.

Code:

complete_connection.jpg

The python code for CPS120 can be downloaded from our github repository-Dcube store.

Here is the link for the same :

https://github.com/DcubeTechVentures/CPS120/blob/master/Python/CPS120.py

We have used SMBus library for python code, the steps to install SMBus on raspberry pi is described here:

https://pypi.python.org/pypi/smbus-cffi/0.5.1

You can also copy the code from here, it is given as follows:

# Distributed with a free-will license.

# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

# CPS120

# This code is designed to work with the CPS120_I2CS I2C Mini Module

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# CPS120 address, 0x28(40)

# 0x80(128) Select Start mode

bus.write_byte(0x28, 0x80)

time.sleep(0.1)

# CPS120 address, 0x28(40)

# Read data back from 0x00(0), 2 bytes, Pressure MSB first

data = bus.read_i2c_block_data(0x28, 0x00, 2)

# Convert the data to kPa

pressure = (((data[0] & 0x3F) * 256 + data[1]) / 16384.0) * 90 + 30

# Output data to screen

print "Pressure is : %.2f kPa" %pressure

Applications:

CPS120 has a variety of applications. It can be employed in portable and stationary barometers, altimeters etc. Pressure is an important parameter to determine the weather conditions and considering that this sensor can be installed at weather stations too. It can be incorporated in air contol systems as well as vacuum systems.