DVLR Pressure sensor I2C communication

Hello,

I am using a DVLR L60D Pressure sensor with Arduino .

https://www.allsensors.com/press-releases/DS-0300_Rev_A13.pdf

Is there any library to use this sensor. Could anyone provide me the link to the library/code regarding this.

Thank you

The manufacturer's page : http://www.allsensors.com/products/dlvr-l60d

If you find something online, please give a link where you found it. I think you found it here : https://www.reddit.com/r/arduino/comments/3efxpc/arduino_interface_with_i2c_pressure_sensor/ That code uses the Wire library in the wrong way. There should be no Wire.endTransmission() after Wire.requestFrom().

The Arduino requests two bytes from the sensor with Wire.requestFrom() and reads the bytes with Wire.read() The formala with the numbers should be according to what is in the datasheet, but I have not read the datasheet.

If you buy a random sensor, you have to write code for it. If you buy something from Adafruit.com, they give a library with it.

Did you tell how you have connected it ? A 3.3V sensor may not be connected to 5V. The I2C pins SDA and SCL might not be connected to a 5V I2C bus.

Hello, I will make sure I will add the links henceforth.

The sensor I have is a 3.3 V and the Arduino I am using is promini which is also 3.3V .

Adafruit did not have the sensor for my requirements. I need to measure negative pressure not more than 5 psi. So I had to buy this from digikey.

http://www.digikey.com/product-search/en?mpart=DLVR-L60D-E1NS-C-NI3F&vendor=442

When I try to compile the code, it shows these error messages.

candidate 1: uint8_t TwoWire::requestFrom(int, int)

uint8_t requestFrom(int, int);

candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

uint8_t requestFrom(uint8_t, uint8_t); :(

Some problem with attaching the pictures of connections! Will try again and upload.

I think these three should be 'int':

byte byterequest=2;
byte a;
byte b;

And I also don't like the rest of the code.

I tried doing that before.

It showed errors like :

" id returned 1 exit status. exit status 1 "

Is there any other way to do this?/ read from the sensor ?

Perhaps this (not tested):

float meas_diff_pressure_Pa()
{
  float Pressure_Pa;

  int n = Wire.requestFrom(I2C_WIRE_ADDR, 2);   // request two bytes

  if( n == 2)      // did we receive two bytes ?
  {
     int a = Wire.read();    // receive first byte (from a buffer in the Wire library)
     int b = Wire.read();   // read second byte (from a buffer in the Wire library)

     a &= 0x3F;    // remove two highest bits.

     unsigned int P_bin = word( a, b);     // high, low

     float Pressure_INH20 = (( (float) P_bin - 8192.0) / 16384.0) * 2.0;
     Pressure_Pa = 249.1740 * Pressure_INH20;
  }
  else
  {
    Serial.println("Error, didn't get all bytes from sensor");
    Pressure_Pa = 0.0          // set to error value. This is bad, an error should be returned.
  }

  return Pressure_Pa;
}

Hello,

I try to compile this code and I get these errors.

#include <Wire.h>
byte I2C_WIRE_ADDR=0x28;
void setup() 
{
  Wire.begin();
  Serial.begin(115200);

float meas_diff_pressure_Pa();

float Pressure_Pa;
}

  int n = Wire.requestFrom(I2C_WIRE_ADDR, 2);   // request two bytes
  void loop(){
  if( n == 2)      // did we receive two bytes ?
  {
     int a = Wire.read();    // receive first byte (from a buffer in the Wire library)
     int b = Wire.read();   // read second byte (from a buffer in the Wire library)

     a &= 0x3F;    // remove two highest bits.

     unsigned int P_bin = word( a, b);     // high, low

     float Pressure_INH20 = (( (float) P_bin - 8192.0) / 16384.0) * 2.0;
     Pressure_Pa = 249.1740 * Pressure_INH20;
  }
  else
  {
    Serial.println("Error, didn't get all bytes from sensor");
    Pressure_Pa = 0.0 ;         // set to error value. This is bad, an error should be returned.
  }

Errors:

Wire/Wire.h:59:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
     uint8_t requestFrom(int, int);
             ^
Wire.h:57:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)
     uint8_t requestFrom(uint8_t, uint8_t);
             ^
sketch_feb06a.ino: In function 'void loop()':
sketch_feb06a:25: error: 'Pressure_Pa' was not declared in this scope
sketch_feb06a:30: error: 'Pressure_Pa' was not declared in this scope
sketch_feb06a:33: error: 'Pressure_Pa' was not declared in this scope
sketch_feb06a:33: error: return-statement with a value, in function returning 'void' [-fpermissive]
'Pressure_Pa' was not declared in this scope

To allow integers and bytes as parameters, the Wire.requestFrom() is defined more than once (candidate 1 and candidate 2). But since one parameter is a byte and the other parameter is an integer, the compiler doesn't know which function to select. They both are okay, so the compiler can pick one, but the compiler wants you to select one of the functions.

You could make the address an integer:

// byte I2C_WIRE_ADDR=0x28;
const int I2C_WIRE_ADDR = 0x28;

After that, select the Auto Format tool in the menu: Tools / Auto Format Ctrl+T

Then check your code for misplaced brackets '{' and '}' and check where the loop() starts and put the code inside the loop().

Hello,

The code got compiled. Thank you

However , when I try to run the I2C scanner , the serial monitor shows I2C scanning…

but does not come up with any address. :confused: :o

I have attached the picture of the connections. Please correct me where I am going wrong.

IMG_3652.JPG

When the i2c_scanner halts, perhaps SDA or SCL is shortcut to ground or they are shortcut to each other, or the pullup resistors are missing. Try removing the SDA or SCL wire, and the i2c_scanner should run, saying that nothing is found. Then try with the pullup resistors but without sensors. Then add the sensor. If the sensor stops the i2c_scanner, check the power of the sensor (the 5V and the GND).

I think you have the non-barbed lid, package SIP, so that is E1NS. In your photo is pin 1 on the left. The pins are (left to right) GND, VS, SDA, SCL. It is hard to see in the photo what the 5V and GND is, and which wire for SDA or for SCL is.

I'm sorry, but I can not see a problem in the photo. Check the wiring again, and use a multimeter to check if the voltage is near 5V (4.5V is probably also okay). Those resistor leads are close to each other, I hope they don't make contact.

Hello,

I followed exactly what you said and it worked!!!

Thanks a lot.

Nice :) You not half-way yet, I hope you can make the sketch work and get useful data.

Hello,

When I run the code, the serial monitor does not show any values.

Can you tell me what the problem might be?

Thank you

The baudrate must be the same. This sets the baudrate to 115200 : Serial.begin ( 115200 ) ; Then also the baudrate in the serial monitor must be set to 115200. Or you can set both to 9600. I still use the default of 9600 for my sketches.

Hello,

Both the baud rates are the same. I set them to 115200.

Print a message as soon as it starts:

void setup()
{
  Serial.begin(115200);
  Serial.println("Started");
  ...

That will work for an Arduino Uno and Pro Mini. If you can't see the text, something is wrong. Perhaps you have to turn off the computer, and turn it on after a minute.

It prints "Started".

But does not show any values. :(

I will try with an other pressure source and check. :confused:

Hello,

I checked with a different source and it still does not work.

Any idea what might be wrong?

No, sorry, I don't know that sensor. If you say on this forum "it does not work", often someone replies that it does not provide any information. I think I did not see a complete sketch in this topic.

The "Pressure_INH20" and "Pressure_Pa" are not printed. Use Serial.println() or Serial.print() for those. In the setup function is this: "float meas_diff_pressure_Pa () ;", but you can remove it, it does not do something.