sgunther
Posts: 3
Joined: Mon Feb 11, 2013 8:11 pm

I2C to Honeywell Pressure Sensor

Mon Feb 11, 2013 8:30 pm

I am trying to interface the Raspberry Pi to a Honeywell I2C pressure sensor. The sensor requires either a two, three or four byte readout of consecutive bytes without a new start cycle. Figure 2 on Page 2 of the communications specification shows it as;
Master - [Start][Slave Address][Read]
Slave - [ACK]
Slave - [DATA]
Master - [ACK]
Slave - [DATA]
Master - [ACK]
Slave - [DATA]
Master - [ACK]
Slave - [DATA]
Master - [NACK]
Master - [STOP]

This protocol does not require slave register addressing but does require multi-byte reads. The i2cget tool provided in the i2c-tools package appears to only offer the ability to do a single byte read.

Is there a way to do a non-addressed multi-byte read using a simple command line tool? If not are there other simple tools that can be called via Python to pull the data or do I need to use something like ioctl invoked in a C program?

Any help is much appreciated.

-Steve

Honeywell Part Number: SSCDANN020NG2A3
Honeywell Data Sheet: Click Link Here
Honeywell I2C Communications Specification Click Link Here

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C to Honeywell Pressure Sensor

Tue Feb 12, 2013 3:20 pm

This sort of thing has come up before do a search for python-smbus or quickwire or other libraries in the forums.

It has been covered several times before maybe not with your exact device but how to do muti-byte and word has been covered before.

Often even doing a byte of addressing is ignored by the device and will work anyway.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: I2C to Honeywell Pressure Sensor

Tue Feb 12, 2013 3:24 pm

Actually very similar thread http://raspberrypi.org/phpBB3/viewtopic ... re#p258536

Found by entering "Honeywell pressure" in search box above
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

sgunther
Posts: 3
Joined: Mon Feb 11, 2013 8:11 pm

Re: I2C to Honeywell Pressure Sensor

Tue Feb 12, 2013 3:30 pm

I spent time last night piecing together various things I found in the forums and got it working! The only issue I am still having has to do with the sensor status indicating "Stale Data" when it shouldn't from a timing perspective. For the time being I am adding a loop to the read requiring fresh data or a pre-defined timeout before I return the value from the program. I'll try to post some code later tonight in case anyone is interested.

Species5618
Posts: 3
Joined: Tue Jul 30, 2013 8:23 pm

Re: I2C to Honeywell Pressure Sensor

Thu Jun 19, 2014 12:01 pm

sgunther, would you like to share you Honeywell i2c solution,

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: I2C to Honeywell Pressure Sensor

Fri Oct 30, 2015 4:49 pm

I use ABPLANT005PG2A3

this code works for me:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <fcntl.h>

#define MAX_PRESSURE 5.0
#define MIN_PRESSURE 0.0

#define SENSOR_ADDR 0x28

int main()
{
  int fd;
  char buf[10];

  if ((fd = open("/dev/i2c-1", O_RDWR)) < 0) {
    printf("Failed to open the bus.");
    exit(1);
  }

  if (ioctl(fd, I2C_SLAVE, SENSOR_ADDR) < 0) {
    printf("Failed to acquire bus access and/or talk to slave.\n");
    exit(1);
  }

  for (;;) {
    if (read(fd, buf, 4) != 4) {
      printf("Failed to read from the i2c bus.\n");
    } else {
      printf("pressure: %f\t",
             (buf[0] * 0x100 + buf[1] - 1638) *
             (MAX_PRESSURE - MIN_PRESSURE) / (14745 - 1638) +
             MIN_PRESSURE);
      printf("temperature: %f\n",
             (buf[2] * 0x100 + buf[3]) * 200.0 / 2047 / 32 - 50);
    }
    usleep(500 * 1000);
  }
}

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 6 guests