Go Down

Topic: SensorTechnics i2c Pressure Sensor (Read 2 times) previous topic - next topic

SheepRustler

Hello All,

I'm trying to interface a SensorTechnics pressure sensor to a Mega. The device is a SSIB001GU9AH5 0-1bar stainless steel housed pressure sensor, seemingly ideal (if a little expensive @£80) for what I need.
It's i2c capable, but also has a analogue voltage out. I'd like to us the i2c function as (if I can get it working) because ultimately I'd like an array of the units.
Attached are the datasheets that I've managed to track down. In one of these there is the code snippet below, which I'm guessing is C ??, but as a Arduio beginner I'm finding it hard to follow/translate this into something I can use on the Arduino.

The datasheet also specifies that the device needs 1.5 K Ohm pullup resistors on from the 5v supply as well as 240 Ohm resistors on the SDA\SCL lines

My question is two fold:
1) Can anyone help me to understand this code and how to get it working?
2) Does the Arduino already have these pullup resistors on the SDA & SCL lines?

I wondered if this might be a device that could be added to the Arduino library....

Many thanks,

Code: [Select]

byte byte_msb, byte_lsb; // 8bit values
int16 pressure; // 16bit value
// Set I2C unit to I2C master mode, clock speed 100 kHz and 7 bit addressing
configureI2C (I2C_MASTER | CLK_SPEED_100KHZ | ADDRESSING_7BIT);
// Set the target address of the sensor (0x78 = 120dec)
I2C_set_target(0x78);
// Send start condition for reading from sensor (slave)
I2C_send_start_read();
// Read first (MSB) data byte and answer with ACK (continue communication)
I2C_read (&byte_msb, SEND_ACK);
// Read second (LSB) data byte and answer with NACK (end communication)
I2C_read (&byte_lsb, SEND_NACK);
// Send Stop condition
I2C_send_stop();
// Put both values together
pressure = ((int16)byte_msb << 8) | byte_lsb;



pylon

Quote
The datasheet also specifies that the device needs 1.5 K Ohm pullup resistors on from the 5v supply as well as 240 Ohm resistors on the SDA\SCL lines


Use 4k7 pull-ups (1k5 @5V is outside the bus specification) and I don't see a reason for the 240 ? resistors in the lines (maybe prevent short circuit in case of wrong wiring).

Quote
Does the Arduino already have these pullup resistors on the SDA & SCL lines?


It does but they are too weak for most cases.

Quote
Can anyone help me to understand this code and how to get it working?


Translated to Arduino-C:

Code: [Select]

byte byte_msb, byte_lsb; // 8bit values
int16_t pressure; // 16bit value
// Set I2C unit to I2C master mode, clock speed 100 kHz and 7 bit addressing
// ### configureI2C (I2C_MASTER | CLK_SPEED_100KHZ | ADDRESSING_7BIT);
Wire.begin();
// Set the target address of the sensor (0x78 = 120dec)
// ### I2C_set_target(0x78);
// Send start condition for reading from sensor (slave)
// ### I2C_send_start_read();
Wire.requestFrom(0x78, 2); // request two bytes from I2C slave address 0x78
// Read first (MSB) data byte and answer with ACK (continue communication)
// ### I2C_read (&byte_msb, SEND_ACK);
byte_msb = Wire.read();
// Read second (LSB) data byte and answer with NACK (end communication)
// ### I2C_read (&byte_lsb, SEND_NACK);
byte_lsb = Wire.read();
// Send Stop condition
// ### I2C_send_stop();
// Put both values together
pressure = ((int16_t)byte_msb << 8) | byte_lsb;

SheepRustler

Thanks very much for taking the time to reply Pylon,

The code makes sense now, but I cant get the device to be recognised on the i2C bus with the 4k7 pullup resistors installed.

I've tried the following i2c scanner with a HMC5883L connected onto the bus, which is detected, but not so the SSI device so I guess its a wiring\pull up resistor\address issue?

I might have to resort to the analogue pin after all.....  :(

Code: [Select]

#include <Wire.h>
void setup()
{
  Wire.begin();
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
void loop()
{
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 120; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
  delay(5000);           // wait 5 seconds for next scan
}

pylon

Code: [Select]
  for(address = 1; address < 120; address++ )


This code isn't scanning the sensors address which is 120 (0x78). Might that be a reason for it?

SheepRustler

Well spotted Pylon, but unfortunately increasing it to 150 as below has made no difference..... :(

Code: [Select]

for(address = 1; address < 150; address++ )

Go Up