jeremycole / AllSensors_DLHR

Arduino library for the AllSensors DLHR Series Low Voltage Digital Pressure Sensors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allsensor_DLC

quangvu912 opened this issue · comments

Hi,
My name is Vu. i just bought allsensor_DLC-L20G-U2, DLC-L01G-U2 from digikey, i cannot find any library for this, however DLHR have the same structure with DLC. Can i use this library for my sensor, and how can i config or get the data from that
This is data sheet of DLC series https://www.allsensors.com/datasheets/DS-0365_Rev_A.PDF

Hi Vu,

You're right that it looks like the DLC sensor should be largely compatible. I did not study absolutely every detail of the data sheet, but it looks like the basics (including the I2C address) are the same, the differences I noted:

  • The temperature transfer function (page 5 of the data sheet) differs very slightly, using 150 instead of 125 as a factor. This could be pretty easily fixed to be configurable per sensor, but at least temporarily if you're using only DLC sensors, it could just be edited in that function. (If you're not interested in the temperature output from the sensor, I think you could also just ignore this.)
  • There are -A "absolute" variants which the currently DLHR library doesn't handle at all, but you're not using those, so it shouldn't matter.

Assuming you don't need the temperature, you could add this in your local file (somewhere after the #include):

class AllSensors_DLC_L01G : public AllSensors_DLHR {
public:
  AllSensors_DLHR_L01G(TwoWire *bus) : AllSensors_DLHR(bus, AllSensors_DLHR::SensorType::GAGE, AllSensors_DLHR::SensorResolution::RESOLUTION_16_BITS, 1.0) {}
};

class AllSensors_DLC_L20G : public AllSensors_DLHR {
public:
  AllSensors_DLC_L20G(TwoWire *bus) : AllSensors_DLHR(bus, AllSensors_DLHR::SensorType::GAGE, AllSensors_DLHR::SensorResolution::RESOLUTION_16_BITS, 20.0) {}
};

And then you should be able to use AllSensors_DLC_L01G and AllSensors_DLC_L20Gvery simply like in the ReadSensor example instead of AllSensors_DLHR_L10G_8.

However I will look at fixing this up properly and pushing a new version that is compatible with DLHR and DLC sensors directly.

Thank you so much, i am a beginner, previous days i learned some PID example and oled, servo and ESC BLDC, my application is ventilator.
These are the total pressure sensors i just bought, they will come in next week. how can i get all of the information from these sensors because i read somewhere that your code may got problem if these sensor have the same address.
1 more thing, can the I2C bus of sensor connect directly to I2C of arduino (no need level switch). if that do i need pull_up resistor and which value

DLC-L20G-U2
DLC-L05G-U2
DLC-L10G-U2
DLC-L01G-U2

Thank you so much for quick response.

if i want to save the pressure value to variable storing maximum resolution of that sensor. which type of variable i should define (float, double or long)?

These are the total pressure sensors i just bought, they will come in next week. how can i get all of the information from these sensors because i read somewhere that your code may got problem if these sensor have the same address.

Yes, the sensors all have the same I²C address, and it is not changeable or selectable on these devices (some I²C devices have address pins or similar, but these do not, and the devices also do not have an "enable" pin). That means that in order to use more than one of these sensors on a single I²C bus, you will need some sort of multiplexing solution. In a previous design I used the Texas Instruments TCA9548A (which I also wrote an Arduino library for).

1 more thing, can the I2C bus of sensor connect directly to I2C of arduino (no need level switch). if that do i need pull_up resistor and which value

The standard Arduino is a 5V device, although some are 3.3V, so it depends on which Arduino you use. These sensors are 1.8V-3.6V (typically 3.3V) and they are absolutely not 5V tolerant, so to use a 5V microcontroller, you will need some sort of voltage level translation to use them. Even connecting them momentarily accidentally at 5V will permanently damage them. There are many voltage level translation solutions out there, but since you already need a multiplexer, you could potentially use the same device to do both multiplexing and voltage level translation. For example, the TCA9548A above supports interfacing between differing voltage levels on the bus and device side.

Since you need to do multiplexing and potentially voltage level translation anyway, typically you will want to use a 3.3V supply to pull up each I²C device with a pull-up resistor independently.

if i want to save the pressure value to variable storing maximum resolution of that sensor. which type of variable i should define (float, double or long)?

The sensors are ~15 bit resolution internally, so float type is generally going to be perfectly fine to store their full resolution.

Hi Jeremycole,
i received the sensor today, i made something
hardware
arduino sensor
SDA---SCL---resistor 5.1k---3.3v (arduino)
SCL---SCL---resistor 5.1k---3.3v(arduino)
3.3V---3.3V
GND--GND
and this is software and result.
what is the problem? sometime it get right value, but some they give me -6227 and -40
pic1
Is that problem of the hardware connection because i did not use the level switch voltage

It's hard to say specifically, but you might want to try printing gagePressure.status with each round and see what the status of the sensor is. Do I understand that you are connecting it to a 5V Arduino? The values you see there I think just imply that it read all zeroes from the sensor, either because the sensor was not in a good state or because something is wrong with the bus. The status byte's bits are documented in the datasheet:

DS-0365_Rev_A_PDF

yes it is connecting to 5V arduino. The status value always = 64 mean 0100 000 bit 6 = 1, power on