Hello,
I'm trying to interface with an I2C pressure sensor (Amphenol NPI-19J-030A2). Using the "i2C_scanner" example from Wire.h, I verified that my sensor is connected to my Arduino (Uno) on register 0x28. Using the code below, I am able to get 6 pieces of data that seem to change as I change the pressure, but I don't understand how to interpret this data. The code comes from an IMU example I found and modified but I think some values probably don't make sense for my device like the "configure registers", "data output rate", etc.
Can someone help me interpret the i2c portion of the sensor's data sheet and modify the code to collect data from the sensor? How do I implement the information on the data sheet that describes the i2c comms? Would I need to create a custom library?
Thank you!!
Here's a sample of the below code's serial output:
16:18:42.198 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:42.992 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:43.788 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:44.630 -> total:688, d[0]:31, d[1]:146, d[2]:95, d[3]:99, d[4]:242, d[5]:75
16:18:45.421 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:46.216 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:47.012 -> total:688, d[0]:31, d[1]:146, d[2]:95, d[3]:99, d[4]:242, d[5]:75
16:18:47.855 -> total:832, d[0]:159, d[1]:146, d[2]:95, d[3]:115, d[4]:242, d[5]:75
16:18:48.652 -> total:800, d[0]:159, d[1]:146, d[2]:95, d[3]:83, d[4]:242, d[5]:75
#include <Wire.h>
#define Addr 0x28
void setup()
{
Wire.begin(); // Initialise I2C communication as MASTER
Serial.begin(9600); // Initialise Serial Communication, set baud rate = 9600
Wire.beginTransmission(Addr); // Start I2C Transmission
Wire.write(0x00); // Select configure register A
Wire.write(0x70); // Set normal measurement configuration, data output rate = 0.75Hz
Wire.endTransmission(); // Stop I2C Transmission
Wire.beginTransmission(Addr); // Start I2C Transmission
Wire.write(0x02); // Select Mode register
Wire.write(0x00); // Set continuous measurement
Wire.endTransmission(); // Stop I2C Transmission
delay(300);
}
void loop()
{
unsigned int data[6];
Wire.beginTransmission(Addr); // Start I2C Transmission
Wire.write(0x03); // Select data register
Wire.endTransmission();// Stop I2C Transmission
Wire.requestFrom(Addr, 6); // Request 6 bytes of data
if(Wire.available() == 6) // Read 6 bytes of data
{
data[0] = Wire.read();
data[1] = Wire.read();
data[2] = Wire.read();
data[3] = Wire.read();
data[4] = Wire.read();
data[5] = Wire.read();
}
delay(300);
// Output data to serial monitor
Serial.print("total:");
Serial.print(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]);
Serial.print(", d[0]:");
Serial.print(data[0]);
Serial.print(", d[1]:");
Serial.print(data[1]);
Serial.print(", d[2]:");
Serial.print(data[2]);
Serial.print(", d[3]:");
Serial.print(data[3]);
Serial.print(", d[4]:");
Serial.print(data[4]);
Serial.print(", d[5]:");
Serial.println(data[5]);
delay(500);
}