Pressure Sensor giving bad values

I have the AMS5812 - 0001 - D differential pressure sensor and I am trying to operate it with an Arduino Mega 2560 currently. I used the sample code provided on the website but for some reason I am getting very weird values. The pressure will sit at around 0.03 PSI and does not change if I tap on one of the sensor tubes. The temperature is reading 98.75C every time I turn it on with no variance at all. I have two of these sensors and it is happening on both of them so I would assume the problem is on the software side but I can’t figure out how. Any help would be appreciated. This is the code I used:

#include <Wire.h>

// AMS5812 I2C address is 0x78(120)
#define Addr 0x78

void setup()
// Initialise I2C communication as MASTER
// Initialise serial communication, set baud rate = 9600

void loop()
unsigned int data[4];

// 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] =;
data[1] =;
data[2] =;
data[3] =;

// 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) / 0.15));
float cTemp = ((temp - 3277.0) / ((26214.0) / 110.0)) - 25.0;
float fTemp = (cTemp * 1.8 ) + 32;

// Output data to serial monitor
// Serial.print("data1 : ");
// Serial.print((data[0] & 0xFF) * 256 + (data[1] & 0xFF));
// Serial.println((data[2] & 0xFF) * 256 + (data[3] & 0xFF));
// Serial.println(data[2]);
// Serial.println(data[3]);
Serial.print(“Pressure : “);
Serial.println(” PSI”);
Serial.print(“Temperature in Celsius : “);
Serial.println(” C”);
Serial.print(“Temperature in Fahrenheit : “);
Serial.println(” F”);

To ensure there is nothing wrong with the sample code you could attempt using this alternative library:

does the sensor show up when you run i2c scan ?

Hello, I work with Isabella and have taken over the troubleshooting.

@TravisE_NCD_Technica I’m having troubles getting your suggested GitHub library to work with Arduino IDE. I’ve installed the bolderflight/units library but am getting some weird namespace issues. I’m going to keep troubleshooting that, but I have more information.

@Anil_Bhaskar I ran the i2c scan found here: Arduino | How to Scan and Detect I2C Addresses | Adafruit Learning System

And it does show up:

I2C device found at address 0x77  !
I2C device found at address 0x78  !

(the x77 is a DPS310 sensor also on the i2c bus)

I’m running this on a SAMD21 (p1am-100) which is equivalent to the arduino MKR Zero

We have both the AMS5812-0003-D and the AMS5812-0001-D sensor variants. We’ve been using 3-D for awhile without issue, but have been trying to validate 1-D for more sensitive applications.

When I plug in the 3-D variant and restart my microcontroller I get the follow output:

Pressure : -0.15 PSI
Temperature in Celsius : 23.26 C
Temperature in Fahrenheit : 73.86 F
Hex : 
Pressure : -0.15 PSI
Temperature in Celsius : 23.16 C
Temperature in Fahrenheit : 73.68 F
Hex : 

When I plug in the 1-D variant and restart my microcontroller I get the following output:

Pressure : -0.13 PSI
Temperature in Celsius : 98.75 C
Temperature in Fahrenheit : 209.74 F
Hex : 
Pressure : -0.11 PSI
Temperature in Celsius : 98.75 C
Temperature in Fahrenheit : 209.74 F
Hex : 
Pressure : -0.09 PSI
Temperature in Celsius : 98.75 C
Temperature in Fahrenheit : 209.74 F
Hex : 

A few things to note about the above output:

  • 3-D is reporting the correct ambient temp and pressure, as expected. We haven’t had an issue with this sensor (we have about a dozen of them in various setups and they all work as expected)
  • 1-D fluctuates on pressure a little, but temp always remains the same
  • I modified the code to read more registers, to see if I was missing something, but the chip just loops and repeats the prior register values
  • 7FFF should be the temp measurement, but it always reads the same, and it is not 98.75*c ambient here :hot_face:

i don’t have one of these sensors with me.
I will recommend reaching out to the sensor element manufacturer