Reading Honeywell HSC Sensors over SPI

Hi,

I want to read two Honeywell HSC Sensors over SPI. One is a 1.6Bar absolute Sensor (HSCMRNN1.6BASA3) and the other a 60mBar differential Sensor (HSCDRRN060MDSA3).

SS Connected to Digital Out 3 (Absolute 1.6Bar Sensor) and Digital Out 2 (relative 60mBar).
Here is my code:

#include <SPI.h>
uint8_t chipSelectPin1 = 3;
uint8_t chipSelectPin2 = 2;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  pinMode(chipSelectPin1, OUTPUT);
  digitalWrite(chipSelectPin1, HIGH);

  pinMode(chipSelectPin2, OUTPUT);
  digitalWrite(chipSelectPin2, HIGH);
}
void loop()
{
  delay(1000);
  float val1 =  (1600 * ((float)readSensor(chipSelectPin1) - 1638) / 13107);
  Serial.print("PRESS1 = "); Serial.println(val1);

  float val2 =  (40 * ((float)readSensor(chipSelectPin2) - 1638) / 4369) + 60;
  Serial.print("PRESS2 = "); Serial.println(val2);
}

int16_t readSensor (uint8_t selectPin) {

  SPI.beginTransaction(SPISettings(700000, MSBFIRST, SPI_MODE1)); // Set to 700kHz, MSB and MODE1
  digitalWrite(selectPin, LOW);       //pull Chipselect Pin to Low

  int inByte_1 = SPI.transfer(0x00);  // Read first Byte of Pressure
  int inByte_2 = SPI.transfer(0x00);  // Read second Byte of Pressure
  int inByte_3 = SPI.transfer(0x00);  // Read first Byte of Temperature
  int inByte_4 = SPI.transfer(0x00);  // Read second Byte of Temperature

  digitalWrite(selectPin, HIGH);      //pull Chipselect Pin to High
  SPI.endTransaction();               //end SPI Transaction
  Serial.print("Chipselect = "); Serial.print(selectPin, DEC); Serial.print(" ");
  Serial.print("Byte_1 = "); Serial.print(inByte_1, DEC); Serial.print(" ");
  Serial.print("Byte_2 = "); Serial.print(inByte_2, DEC); Serial.print(" ");
  Serial.print("Byte_3 = "); Serial.print(inByte_3, DEC); Serial.print(" ");
  Serial.print("Byte_4 = "); Serial.print(inByte_4, DEC); Serial.print(" ");

  int16_t pressure_dig = inByte_1 << 8 | inByte_2; 

  inByte_3 = inByte_3 << 3; //Shift first Temperature byte 3 left 
  float realTemp = ((float)inByte_3 * 200 / 2047) - 50; //Convert Digital value to °C
  Serial.print("Temp[C]= "); Serial.print(realTemp); Serial.print(" ");

  return pressure_dig; //return digital Pressure Value
}

Somehow, I dont get the correct values:

Chipselect = 2 Byte_1 = 255 Byte_2 = 255 Byte_3 = 255 Byte_4 = 255 Temp[C]= 149.32 PRESS2 = 44.99
Chipselect = 3 Byte_1 = 31 Byte_2 = 255 Byte_3 = 88 Byte_4 = 111 Temp[C]= 18.78 PRESS1 = 799.94
Chipselect = 2 Byte_1 = 255 Byte_2 = 255 Byte_3 = 255 Byte_4 = 255 Temp[C]= 149.32 PRESS2 = 44.99
Chipselect = 3 Byte_1 = 31 Byte_2 = 253 Byte_3 = 88 Byte_4 = 111 Temp[C]= 18.78 PRESS1 = 799.69

A weather station in this area with approx 45.6m height difference gives me a value of 1022mBar.... not 799 as indicated by the absolute pressure Sensor.

The second Sensor should give me 0 since nothing is connected to the ports.

The temperature is read in the same way on both sensor but I receive two different values (although 18.78 should be correct).

Any ideas?

Thanks :slight_smile:

Here is the Datasheet

And here is a application Datasheet

Hi,

thanks for your program.i was able to use that and work with HSCDANN150PASA5 (HONEYWELL SENSOR).

I did some modification to your program which has been attached here and it gives me proper change in pressure readings.and the logged data change in pressure for 2 sensors has been attached for people reference in future.

-raghu

edited_working_prog1_for_2_sensors.ino (2.38 KB)

CoolTerm Capture 2016-07-18 10-44-36.txt (65.9 KB)