I have a TruStability Pressure sensor (SSCDANT150PGAA5) and I want read the value in my arduino. I can't get it to work and I have no idea what may be going wrong or how to fix it.
Below are the wiring and the code. Does anyone see anything wrong with my approach? What next steps should I take?
WIRING:
NAME Arduino SENSOR PIN
GND 1
+5V 2
SCLK 13 3
MISO 12 4
SS 10 5
CODE:
#include <SPI.h>
// pins used for the connection with the sensor
// the other you need are controlled by the SPI library):
const int dataReadyPin = 12;
const int chipSelectPin = 10;
void setup() {
Serial.begin(19200);
// start the SPI library:
SPI.begin();
SPI.setClockDivider(128);
// initalize the data ready and chip select pins:
pinMode(dataReadyPin, INPUT);
pinMode(chipSelectPin, OUTPUT);
digitalWrite(chipSelectPin,HIGH);
delay(100);
Serial.println("----------------------------");
Serial.println(" TEST PRESSURE SENSOR v4
");
Serial.println("----------------------------");
}
void loop()
{
digitalWrite(chipSelectPin, LOW);
delay(10);
int inByte_1 = SPI.transfer(0x00);
int inByte_2 = SPI.transfer(0x00);
int inByte_3 = SPI.transfer(0x00);
int inByte_4 = SPI.transfer(0x00);
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(" ");
float psi = inByte_1<<8|inByte_2;
psi = (psi*5)/16384;
Serial.print("PRES = ");Serial.print(psi);Serial.print("\n");
inByte_3 = inByte_3<<3;
//float realTemp = ((float)inByte_3*200/2047)-50;
//Serial.print("Temp
= ");Serial.print(realTemp);Serial.print("\n");
digitalWrite(chipSelectPin,HIGH);
delay(1000);
}