Particle AMS5812_0050-D-B Pressure & Temperature Sensor Tutorial
by Dcube Tech Ventures in Circuits > Electronics
42 Views, 0 Favorites, 0 Comments
Particle 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 the demonstration of using it with particle photon.
What You Need..!!
Connections:
Take an I2C shield for particle photon and gently push it over the pins of particle photon.
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.
Code:
The particle 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 have used two libraries for particle code, which are application.h and spark_wiring_i2c.h. Spark_wiring_i2c library is required to facilitate the I2C communication with the sensor.
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
#include
// AMS5812 I2C address is 0x78(120)
#define Addr 0x78
float pressure = 0.0, cTemp = 0.0, fTemp = 0.0;
unsigned long ptemp, temp;
void setup()
{
//Set variable
Particle.variable("i2cdevice","AMS5812");
Particle.variable("pressure",pressure);
Particle.variable("cTemp",cTemp);
// Initialise I2C communication
Wire.begin();
// Initialise SerialSerial.begin(9600);
delay(300);
}
void loop()
{
byte data[4];
// Request 4 bytes of data from slave device
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);
// Convert the data
ptemp = ((data[0] & 0xFF) * 256 + (data[1] & 0xFF));
temp = ((data[2] & 0xFF) * 256 + (data[3] & 0xFF));
pressure = ((ptemp - 3277.0) / ((26214.0) / 10.0)) - 5.0;
cTemp = ((temp - 3277.0) / ((26214.0) / 110.0)) - 25.0;
fTemp = (cTemp * 1.8 ) + 32;
// Output data to dashboard
Particle.publish("Temperature in Celsius :", String(cTemp));
delay(500);
Particle.publish("Temperature in Fahrenheit : ", String(fTemp));
delay(500);
Particle.publish("Pressure in PSI: ", String(pressure));delay(500);
}
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.