Hey everyone I got some Honeywell sensors one HSC differential and another SSC absolute type. I found some code here Commits · rodan/honeywell_hsc_ssc_i2c · GitHub
I was able to get it working but had to change a few things.
I changed min/max values and at the bottom I removed
//dtostrf(p, 2, 2, p_str);
// dtostrf(t, 2, 2, t_str);
And changed " p_str and t_str " to p and t
It is triggering a diagnostic fault 11 with the absolute sensor. (in the pdf it suggests either "Loss of sense element connection" or "Short circuit of sense element" ?? But seems to be outputting correct. or at least close to correct values.
But reading status 0 with the differential sensor meaning everything is working.
Here is the link to the i2c communications pdf for these sensors. http://sensing.honeywell.com/i2c%20comms%20digital%20output%20pressure%20sensors_tn_008201-3-en_final_30may12.pdf
I dont really know what im doing and would like to clean up the code if possible. Would appreciate any advice. Hope this is helpful to anyone else who needs it.
#include <Wire.h>
#include "hsc_ssc_i2c.h"
// see hsc_ssc_i2c.h for a description of these values
// these defaults are valid for the HSCMRNN030PA2A3 chip
#define SLAVE_ADDR 0x78
#define OUTPUT_MIN 1638 // 1638 counts (10% of 2^14 counts or 0x0666)
#define OUTPUT_MAX 14745 // 14745 counts (90% of 2^14 counts or 0x3999)
#define PRESSURE_MIN 0.0 // min is 0 for sensors that give absolute values
#define PRESSURE_MAX 1.6 // 1.6bar (I want results in bar for now)
uint32_t prev = 0;
const uint32_t interval = 5000;
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
unsigned long now = millis();
struct cs_raw ps;
char p_str[10], t_str[10];
uint8_t el;
float p, t;
if ((now - prev > interval) && (Serial.available() <= 0)) {
prev = now;
el = ps_get_raw(SLAVE_ADDR, &ps);
// for some reason my chip triggers a diagnostic fault
// on 50% of powerups without a notable impact
// to the output values.
if ( el == 4 ) {
Serial.println("err sensor missing");
} else {
if ( el == 3 ) {
Serial.print("err diagnostic fault "); //When the two status bits are “11”, one of the above mentioned diagnostic faults is indicated.
Serial.println(ps.status, BIN);
}
if ( el == 2 ) {
// if data has already been feched since the last
// measurement cycle
Serial.print("warn stale data ");
Serial.println(ps.status, BIN);
}
if ( el == 1 ) {
// chip in command mode
// *Command mode is used for programming the sensor. This mode should not be seen during normal operation.
Serial.print("warn command mode ");
Serial.println(ps.status, BIN);
}
Serial.print("status ");
Serial.println(ps.status, BIN);
Serial.print("bridge_data ");
Serial.println(ps.bridge_data, DEC);
Serial.print("temp_data ");
Serial.println(ps.temperature_data, DEC);
Serial.println("");
ps_convert(ps, &p, &t, OUTPUT_MIN, OUTPUT_MAX, PRESSURE_MIN,
PRESSURE_MAX);
// floats cannot be easily printed out
//dtostrf(p, 2, 2, p_str);
// dtostrf(t, 2, 2, t_str);
Serial.print("pressure (BAR) ");
Serial.println(p);
Serial.print("temperature (C) ");
Serial.println(t);
Serial.println("");
}
}
}