Coding for multiple i2c pressure sensor

I'm using ABP2 honeywell pressure sensor ABP2DRRN002ND2B3XX with arduino uno.
I want to use five sensors of the same type simultaneously.
However, the datasheet which include with sensor shows only how to work one sensor.
Could anyone tell me how to work multiple sensors simultaneously with i2c communication?

The following code is included with datasheet.

#include<Arduino.h>
#include<Wire.h>
uint8_t id = 0x28; // i2c address
uint8_t data[7]; // holds output data
uint8_t cmd[3] = {0xAA, 0x00, 0x00}; // command to be sent
double press_counts = 0; // digital pressure reading [counts]
double temp_counts = 0; // digital temperature reading [counts]
double pressure = 0; // pressure reading [bar, psi, kPa, etc.]
double temperature = 0; // temperature reading in deg C
double outputmax = 15099494; // output at maximum pressure [counts]
double outputmin = 1677722; // output at minimum pressure [counts]
double pmax = 1; // maximum value of pressure range [bar, psi, kPa, etc.]
double pmin = 0; // minimum value of pressure range [bar, psi, kPa, etc.]
double percentage = 0; // holds percentage of full scale data
char printBuffer[200], cBuff[20], percBuff[20], pBuff[20], tBuff[20];
void setup() {
 Serial.begin(9600);
 while (!Serial) {
 delay(10);
 }
 Wire.begin();
 sprintf(printBuffer, "\nStatus Register, 24 - bit Sensor data, Digital Pressure Counts,\
 Percentage of full scale pressure, Pressure Output, Temperature\n");
 Serial.println(printBuffer);
}
void loop() {
 Wire.beginTransmission(id);
 int stat = Wire.write (cmd, 3); // write command to the sensor
 stat |= Wire.endTransmission();
 delay(10);
 Wire.requestFrom(id, 7); // read back Sensor data 7 bytes
 int i = 0;
 for (i = 0; i < 7; i++) {
 data [i] = Wire.read();
 }
 press_counts = data[3] + data[2] * 256 + data[1] * 65536; // calculate digital pressure counts
 temp_counts = data[6] + data[5] * 256 + data[4] * 65536; // calculate digital temperature counts
 temperature = (temp_counts * 200 / 16777215) - 50; // calculate temperature in deg c
 percentage = (press_counts / 16777215) * 100; // calculate pressure as percentage of full scale
 //calculation of pressure value according to equation 2 of datasheet
 pressure = ((press_counts - outputmin) * (pmax - pmin)) / (outputmax - outputmin) + pmin;
 dtostrf(press_counts, 4, 1, cBuff);
 dtostrf(percentage, 4, 3, percBuff);
 dtostrf(pressure, 4, 3, pBuff);
 dtostrf(temperature, 4, 3, tBuff);
 /*
 The below code prints the raw data as well as the processed data
 Data format : Status Register, 24-bit Sensor Data, Digital Counts, percentage of full scale 
pressure,
 pressure output, temperature
 */
 sprintf(printBuffer, " % x\t % 2x % 2x % 2x\t % s\t % s\t % s\t % s \n", data[0], data[1], data[2],
 data[3],
 cBuff, percBuff, pBuff, tBuff);
 Serial.print(printBuffer);
 delay(10);
}

Have you heard of an I2C multiplexer/expander?

Why are you using the double data type?

looks like there's a sensor select pin

sensor

ABP2DRRN002ND2B3XX is I2C :wink:

If you dont want to use and I2C multiplexer, assuming you have NOT ordered the bits yet, you could order parts with different I2C addr as described in the data sheet.

also it's 3.3V! take care when using it with the UNO as you may well need a voltage level converter between your sensor and the UNO for the I2C communication (UNO operates at 5V)

hope that helps....

Yes!
I have exactly that. But I don't know how to make coding to combine this pressure sensors and TCA9548A.

This coding is refer from datasheet, so I don't know details.

I suppose ABP2DRRN002ND2B3XX is not SPI ...?
It's i2c.

I see.
Unfortunately, I have already ordered them.
So I must manage to use them. Is there any method to rewrite i2c address?

3 posts were split to a new topic: Compilation error: 'dtostrf' was not declared in this scope

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.