AMS5812 0150-B calibration?

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.setTextSize(1); // display a line of text
display.setCursor(15, 20);
display.display(); // update display with all of the above graphics


void loop()
unsigned int data[4];
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] =;
data[1] =;
data[2] =;
data[3] =;

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.setCursor(15, 05);
display.print("Pressure: ");
display.setCursor(15, 15);
display.setCursor(15, 25);
display.setCursor(15, 35);
display.display(); // update display with all of the above graphics


// Output data to serial monitor
Serial.print(" “);
Serial.print(” “);
Serial.print(” “);
Serial.print(” ");
Serial.print(“Pressure : “);
Serial.println(” PSI”);


I will recommend using this lib


These AMS sensors are spectacular, but the user needs to look through the datasheet before selection.

It seems like the barometric version of this sensor is working as it would be expected to.
Take a look at page 6 of the datasheet:


Your Barometric sensor is reporting slightly higher that 1 Standard Atmosphere. I’m not sure about the negative sign.

I’m guessing what you want is a Bi-Directional Differential Sensor. That would allow you to use both sensor ports (1 inside the container and 1 outside).

Thanks for the feedback, rfontaine! Perhaps I ordered the wrong item, but since it had two pressure ports I had assumed it was a differential sensor. Not bi-directional necessarily, but still measuring a differential? Otherwise what is the second port for?

I did review the datasheet before ordering this one (I ordered the wrong sensor the first time :slight_smile: ) and I didn’t see a bi-directional differential sensor that measured barometric pressure, but maybe I didn’t look close enough. All I want is a sensor that again can measure a difference in pressure across two points within normal barometric pressure window! Any ideas?

Thank you, Bhaskar! I ran this script and got now the negative sign is fixed haha but it’s still reading a very low barometric pressure. Here’s the output:

Getting Readings from AMS5812_0150-B

Digital Pressure Reading: 10.96 PSI
Digital Pressure Reading: 755.96 mbar
Digital Pressure Reading: 1.10 kPa
Digital Pressure Reading: 8.22 mmHg
Temperature Reading in Celsius: 22.43 °C
Temperature Reading in Fahrenheit: 72.37 °F


According to NCD’s website, 758.4 mbar is the minimum reading. Any ideas why it’s reading below the minimum value?

The absolute & barometric sensors only use Port #1.
If you require Absolute values, I think you may need Two sensors.
If you only need to know the differential pressure between the 2 ports (gauge), I think you want a D-B sensor.
The AMS 5812-0150-D-B operating range is -1 Atm to +1 Atm.

I agree with you that your existing sensor reading is off.
You are inside the worst hurricane ever if you’re at 755 mbar.


I’m from India & currently studying in Second Year of Mechanical Engineering. My Fluid Mechanics mini project is to build a pressure & temperature sensor.

I want to measure the under water pressure with the help of this sensor to experimentally prove the ‘Hydrostatic Law’. Can it be just done by dipping an hose into the liquid? If yes, how do I connect an hose to the sensor? Will the sensor give me accurate reading just by dipping the hose into the water? And how do I create an experiment set up for that?
I want to estimate that the pressure increases as the depth increases.

Reply awaited.

Thank you.

Thanks for the additional info, Ryan. Do you know if calibration is done by the manufacturer or if this is something I can do on my end?

If I can’t do it from my end, I would hope NCD will accept a refund - or better, a swap out for a D-B sensor! Hopefully they are reading this post :wink:

whats the presssurecounts value ?
( You can print it from the code).

I get:




And it doesn’t seem to change when I tap on the pressure port(s) :frowning:

pressurecounts is defined in the cpp file, you will need to add a print statement over there.

Yes, if you purchase the appropriate AMS 5812 sensor ending in D-B, it will work for exactly what you want to do. I’ve used these sensors to accurately measure water depths just like you are planning.
Select the sensor with the correct range that you want to measure (2.31 feet of water depth = 1 psi).

Leave Port #1 open to the atmosphere. Connect your tubing to Port #2 and remove any air bubbles.

You will receive the differential pressure caused by the column (depth) of water, already corrected for atmospheric (weather) conditions by leaving Port #1 open to air and using a Bi-Directional Differential Sensor (xxxx -D-B)

@ahume, you have the correct sensor if you want absolute pressure.

What elevation are you (above sea level)?
If you live in the mountains for instance, 8000 ft elevation would be 755 mbar absolute pressure.

Unfortunately I’m only ~3m above sea level so doesn’t explain the low reading either…

@Bhaskar - I’m working on getting the pressureCounts value today. I’m still pretty new to Arduino coding but enjoy the challenege :slight_smile:

Me again Ryan. Your post here suggest that for my similar application I want a ‘bidirectional’ sensor, not an 'absolute" sensor. Since my tank’s depth is only about 5 feet, an AMS5812-0050-D-B should work, right? The one thing I cannot find anywhere is what goes underwater on the end of the tube. Some kind of bladder? Your advice, as always, is extremely valued.

Brian Shaw