SPI connection - Pressure Sensor Readout

Hi guys,

got a problem with reading out data from my new pressure sensor. I bought the LDE 1 by First Sensors. It is controlled by SPI. As Iam really overchallenged I need your help!?!

Here comes the Datasheet:

Until now my Sketch looks very simple, like:

#include <SPI.h>

int ss=10;
int value;

void setup() {
Serial.begin(9600);
pinMode (ss,OUTPUT);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
}

void loop(){
  digitalWrite(ss, LOW);
  SPI.transfer(0);     // ???
  SPI.transfer(value);
  digitalWrite(ss,HIGH);
Serial.println(value);
}

Of course the sketch doesn´t work ... I found on page 8 of the datasheet something about three bytes that have to be send ?!
Now the question ... How can I tell my Arduino to send this bytes? Do I send as hexadecimal or binary ? ... And what is the appropriate command to send ?

Thank you for your help in advance!
regards
kohlmeise

moderator: added code tags ==> # button above smiley's

this is how it should work, it compiles but as I have no such sensor I cannot test it.

#include <SPI.h>

#define POLLCURRENT 0x2D
#define STOREDATAREGISTER 0x14
#define READDATAREGISTER 0x98

int ss=10;
int value;

void setup() 
{
  Serial.begin(9600);
  Serial.println("start");
  pinMode (ss, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
}

void loop()
{
  value = readPressureSensor();
  Serial.println(value);
  delay(1000);
}

int readPressureSensor()
{
  int result = 0;
  digitalWrite(ss, LOW);
  SPI.transfer(POLLCURRENT); 
  SPI.transfer(STOREDATAREGISTER ); 
  SPI.transfer(READDATAREGISTER );
  result += SPI.transfer(0x00) * 256;
  result += SPI.transfer(0x00) ;
  digitalWrite(ss, HIGH);
  return result;
}

Hi thank you so much ! I will try to understand the sketch and test it very soon !

kind regards

Here the final version of the sketch. The Sensor needed some additional commands.
The data transfer works in 3. steps. Between every step the cs have to be turned high and low.
Thank you again for your help
kind regards kohlmeise

 #include <SPI.h>

#define POLLCURRENT 0x2D
#define STOREDATAREGISTER 0x14
#define READDATAREGISTER 0x98

int cs=10;
int value;

void setup() 
{
  Serial.begin(9600);
  Serial.println("start");
  pinMode (cs, OUTPUT);
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
}

int readPressureSensor()
{
  digitalWrite(cs, LOW);
  SPI.transfer(POLLCURRENT); 
  digitalWrite(cs, HIGH);
  digitalWrite(cs, LOW);
  SPI.transfer(STOREDATAREGISTER); 
  digitalWrite(cs, HIGH);
  digitalWrite(cs, LOW);
  SPI.transfer(READDATAREGISTER);
  digitalWrite(cs, HIGH);
  digitalWrite(cs, LOW);
  byte h = SPI.transfer(0x00);
  byte l = SPI.transfer(0x00);
  digitalWrite(cs, HIGH);
  int result=word(h,l);
  return result;
}

void loop()
{

  value = readPressureSensor();
  Serial.println(value);
  Serial.println(analogRead(A0));
  
  delay(100);
}

moderator: added code tags ==> # button above smiley's