I have Omron D6F-PH0505AD3 sensor and arduino uno. Im trying to read pressure differential but i dont know how. Sensor I2C bus address is 0x6C and only result i get is "4"
On page 9 there is an example of a session with the sensor.
In case access to internal registers are needed, the target register’s address needs to be set
to the Interface Configuration Register (address:00h and 01h).
think the core code should be something like this (I do not have such sensor disclaimer applies)
// write to the access address the address of the SENS control register 0xD040 see page 6
Wire.beginTransmission(addrs);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
Wire.write(0x40); // reg 1 - addres register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
// READ THE REGISTER
Wire.beginTransmission(addrs);
Wire.write(0x07); // set read register
int x = Wire.endTransmission();
Wire.requestFrom(addrs, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
int value = word( hibyte, lobyte);
Serial.println( value ); // this should be the value that is in register 0xD040
Not really complicated but you need multiple steps to get a value
for pressure I think (still all disclaimers apply)
// SET COMPENSATED REGISTER
Wire.beginTransmission(addrs);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
// READ THE REGISTER
Wire.beginTransmission(addrs);
Wire.write(0x07); // set read register
int x = Wire.endTransmission();
Thanks robtillaart. But only reading i get is 0. On page 15 there is 1. Initialization after power up [Must be done], is that possible reason?
This is my first project with i2c and only senson that can measure from -50 pascal to 50 pascal
I'm building a similar prototype with Arduino Duemilanove and Omron differential pressure sensor D6F-PH 5050AD3; I tried the code from robtillaart, but it wasn't working.
After searching a little bit, I found a differente application note for the sensor: Application note from Mouser
that had one different register address, I tried it and...it worked!
In addition to changing the address, I slightly modified the code to better follow what was indicated in the application note, and also to return a temperature with .1°C of resolution.
Furthermore, I added notes to adapt the differential pressure reading for all the 3 "sister" sensors:
D6F-PH0025AD1
D6F-PH0505AD3
D6F-PH5050AD3
Here's the code that worked for me:
int initialize(int i2c_addr)
{
//INITIALIZATION AFTER POWER UP
Wire.beginTransmission(i2c_addr);
Wire.write(0x0B);
Wire.write(0x00);
int x = Wire.endTransmission();
return x;
}
int pressure(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x51);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
Serial.print("raw pressure:\t ");
Serial.println(raw);
// D6F-PH5050AD3 ==> rangeMode=500 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0505AD3 ==> rangeMode=50 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0025AD1 ==> rangeMode=250 ==> int rd_pressure=(raw - 1024) * rangeMode / 60000L
int rangeMode = 500;
int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode;
return rd_pressure;
}
float temperature(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x61);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
Serial.print("raw temperature:\t ");
Serial.println(raw);
int temp = round((float)(raw - 10214) / 3.739); // this is the temperature multiplied by 10...
return (temp/10.0); // ...and the function returs the float temperature with 0.1°C resolution
}
I am a newbie with the arduino platform and I am need of some help figuring out what the overall code would look like I'm basically trying to use arduino uno rev3 with D6F-PH0505AD3.
Doesn't seem to be working for me, any help is appreciated. Thank you.
#include "Wire.h"
#define addrs 0x6C // I2C bus address
int P;
int I;
float T;
int initialize(int i2c_addr)
{
//INITIALIZATION AFTER POWER UP
Wire.beginTransmission(i2c_addr);
Wire.write(0x0B);
Wire.write(0x00);
int x = Wire.endTransmission();
return x;
}
int pressure(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x51);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
//Serial.print("raw pressure:\t ");
//Serial.println(raw);
// D6F-PH5050AD3 ==> rangeMode=500 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0505AD3 ==> rangeMode=50 ==> int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode
// D6F-PH0025AD1 ==> rangeMode=250 ==> int rd_pressure=(raw - 1024) * rangeMode / 60000L
int rangeMode = 50;
int rd_pressure = ((raw - 1024) * rangeMode * 2 / 60000L) - rangeMode;
return rd_pressure;
}
float temperature(int i2c_addr)
{
//MCU MODE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0); // reg 0 - address register high byte
// Wire.write(0x51); // reg 1 - address register low byte
Wire.write(0x40); // reg 1 - address register low byte
Wire.write(0x18); // reg 2 - serial control register - indicate # bytes among others (page 7 bottom)
Wire.write(0x06); // reg 3 - value to be written to SENS control register
int x = Wire.endTransmission();
delay(33);
//WRITE
Wire.beginTransmission(i2c_addr);
Wire.write(0x00);
Wire.write(0xD0);
Wire.write(0x61);
Wire.write(0x2C);
x = Wire.endTransmission();
//READ
Wire.beginTransmission(i2c_addr);
Wire.write(0x07);
x = Wire.endTransmission();
Wire.requestFrom(i2c_addr, 2);
byte hibyte = Wire.read();
byte lobyte = Wire.read();
long raw = word( hibyte, lobyte);
//Serial.print("raw temperature:\t ");
//Serial.println(raw);
int temp = round((float)(raw - 10214) / 3.739); // this is the temperature multiplied by 10...
return (temp/10.0); // ...and the function returs the float temperature with 0.1°C resolution
}
void setup()
{ // Open serial communications
Serial.begin(9600);
I=initialize (addrs); // start wire connection
}
void loop()
{
P=pressure(addrs);
Serial.print("pressure:\t ");
Serial.println(P);
T=temperature(addrs);
Serial.print("temperature:\t ");
Serial.println(T);
delay(30000); //delay for 30 seconds
}
Hello. I know is an old topic but I have the same setup Omron D6F PH series differential pressure sensor and arduino genuino uno wired as in your image but I can not figure out where to read the measured value after I uploaded successful the firmware in Arduino IDE. I have a Nokia 5110 LCD hooked to the same arduino but shows nothing now after uploading the code from this topic.
About myself I am new in programing I played before the Genuino Uno with a Mega 2560 and a 3 D printer
modifying the printing size etc after rebuild it to be bigger.
The scope of the project is to measure the human breath pressure in the nose after using sinus heating Mask. The sensor is mesuring from 0 - 250 Pa D6F-PH0025AD1.