I’m running the AMS5812-0150-B barometric pressure sensor with an Arduino and I keep getting a -15.01 PSI. I pulled a sketch form GitHub with the below calculations. I’m confused as to two the pressure is reporting negative? And second, it doesn’t seem very responsive when I pop my finger on and off the pressure port. It barely changes from -14.95 to -15.05. Any ideas what I’m doing wrong?
My goal is to be able to measure pressure inside and outside a open volume such as a coke bottle that has wind blowing over the top of it (e.g. observing helmholtz resonance).
Here’s the full script (which prints to a small OLED). I’m still new to Arduino scripts, so feel free to correct any sill mistakes!
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define Addr 0x78 // AMS5812 Diff Pressure Sensor I2C address is 0x78(120)
#define OLED_ADDR 0x3C // OLED display I2C address (0x3C)
Adafruit_SSD1306 display(-1);
void setup() {
Wire.begin(); // Initialise I2C communication as MASTER
Serial.begin(9600); // Initialise serial communication, set baud rate = 9600
delay(600); // delay after initializing text
// initialize and clear display
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
display.setTextSize(1); // display a line of text
display.setTextColor(WHITE);
display.setCursor(15, 20);
display.print(“Initializing…”);
display.display(); // update display with all of the above graphics
}
void loop()
{
unsigned int data[4];
display.clearDisplay();
delay(600); //delay to start below
Wire.requestFrom(Addr, 4); // Request 4 bytes of data
// 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();
}
float pressure = ((data[0] & 0xFF) * 256 + (data[1] & 0xFF)); // Convert the data
float temp = ((data[2] & 0xFF) * 256 + (data[3] & 0xFF));
pressure = ((pressure - 3277.0) / ((26214.0) / 30.0)) - 15.0;
float cTemp = ((temp - 3277.0) / ((26214.0) / 110.0)) - 25.0;
float fTemp = (cTemp * 1.8 ) + 32;
float pressurembar = pressure * 68.9476;
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(15, 05);
display.print("Pressure: ");
display.setCursor(15, 15);
display.print(pressurembar);
display.setCursor(15, 25);
display.println(“mbar”);
display.setCursor(15, 35);
display.print(pressure);
display.display(); // update display with all of the above graphics
delay(500);
display.clearDisplay();
// Output data to serial monitor
Serial.print(data[0]);
Serial.print(" “);
Serial.print(data[1]);
Serial.print(” “);
Serial.print(data[2]);
Serial.print(” “);
Serial.print(data[3]);
Serial.print(” ");
Serial.print(“Pressure : “);
Serial.print(pressure);
Serial.println(” PSI”);
}