Sensirion SDP810 Differential Pressure Sensor Code for Arduino

Lately I have been working a lot on a control system to emulate stack effect for use in the experimental setup I'm constructing. For the control system I'm using some small but extremely accurate and fast responding digital pressure differential sensors manufactured by Sensirion. The sensors are called SDP-810-125Pa, and while I've found two Arduino libraries intended for communication with these sensors, neither worked for what I'm doing, as I need to run the sensors in "continuous mode". I've therefore resorted to just communicating directly with the sensors over I2C using the build-in Arduino Wire.h library. This has turned out to not be too difficult (I managed it after all), and the Arduino code can still be kept pretty compact. I'm sharing the basic code below for anybody else using these sensors with Arduino MCU's. Also I've been in contact with a software developer at Sensirion who has told me that he is working on expanding their arduino library to also include the continuous read modes.

Their library can be found on Github here: https://github.com/Sensirion/arduino-sdp

 Until they get the library updated, the code below can be used to run the sensors in "continues mode":



#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
Wire.beginTransmission(0x25); //Start communication over i2c on channel 25 (page 6 in cut sheet)
Wire.write(0x36); Wire.write(0x03); //Start sensor in mode "Averate till read, Mass flow", use 3615 for DP (see page 7 in cutsheet)
Wire.endTransmission();
delay(8); //First measurement is available after 8ms, page 7 in cut sheet
}
void loop()
{
//Read pressure from SDP810
int16_t Pres_Raw; //16 bit intiger to store the msb and lsb
double Pres; //Double precision float to store actual pressure reading
byte msb;
byte lsb;
Wire.requestFrom(0x25, 2); //Contents of first two bytes
msb = Wire.read(); //Byte1 is msb
lsb = Wire.read(); //Byte2 is lsb
Pres_Raw = msb<<8; //Assign msb to combined variable
Pres_Raw |= lsb; //Add the lsb to the combined variable
Pres = Pres_Raw/float(240); //Divide the raw reading by the scaling factor (page 10 in cut sheet)
Serial.write(Pres); //Print pressure reading in terminal (Pa)
delay(5)

}

// Cut sheet available at: www.mouser.dk/datasheet/2/682/Sensirion_Differential_Pressure_Sensors_SDP8xx_Dig-1314455.pdf

Comments