Introduction: Arduino AMS5812_0050-D-B Pressure & Temperature Sensor Tutorial
AMS5812 Amplified Pressure Sensor with Analog and Digital Outputs is a high precision sensor with an analog voltage output and digital I2C interface. It combines a piezoresistive sensing element with a signal conditioning element for its operation. Here is its demonstration with arduino nano.
Step 1: What You Need..!!
Step 2: Connections:
Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.
Then connect the one end of I2C cable to AMS5812_0050-D-B sensor and the other end to the I2C shield.
Connections are shown in the picture above.
Step 3: Code :
The Arduino code for AMS5812_0050-D-B can be downloaded from our GitHub repository-Dcube Store.
Here is the link for the same :
https://github.com/DcubeTechVentures/AMS5812-0050-D-B
We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board.
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.
// AMS5812
// This code is designed to work with the AMS5812_I2CS_0050-D-B I2C Mini Module available in Dcube Store.
#include
// AMS5812 I2C address is 0x78(120)
#define Addr 0x78
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);
delay(300);
}
void loop()
{
unsigned int data[4];
delay(500);
// Request 4 bytes 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();
}
// Convert the data
float pressure = ((data[0] & 0xFF) * 256 + (data[1] & 0xFF));
float temp = ((data[2] & 0xFF) * 256 + (data[3] & 0xFF));
pressure = ((pressure - 3277.0) / ((26214.0) / 10.0)) - 5.0;
float cTemp = ((temp - 3277.0) / ((26214.0) / 110.0)) - 25.0;
float fTemp = (cTemp * 1.8 ) + 32;
// Output data to serial monitor
Serial.print("Pressure : ");
Serial.print(pressure);
Serial.println(" PSI");
Serial.print("Temperature in Celsius : ");
Serial.print(cTemp);
Serial.println(" C");
Serial.print("Temperature in Fahrenheit : ");
Serial.print(fTemp);
Serial.println(" F");
delay(500);
}
Step 4: Applications:
AMS5812 is an amplified pressure sensor and it can be employed in systems where static and dynamic pressure measurement and barometric pressure measurement is to be carried out. It plays a pivotal role in Vacuum monitoring,Gas flow monitoring, Fluid level measurement as well as Medical instrumentation.