Hi guys
I'm trying to make the Sensirion SDP810 differential pressure sensor work with my Teensy 3.2. (datasheet: https://docs.rs-online.com/dd4e/0900766b81568896.pdf), but nothing works so far.
First, I tried to use the Arduino library Sensirion has provided on their GitHub (https://github.com/Sensirion/arduino-sdp) with the following code (taken from the library example):
Code:
#include <Wire.h>
#include <sdpsensor.h>
SDP8XXSensor sdp;
void setup() {
Wire.begin();
//Wire.setClock(100000);
Serial.begin(9600);
delay(1000); // let serial console settle
do {
int ret = sdp.init();
if (ret == 0) {
Serial.print("init(): success\n");
break;
} else {
Serial.print("init(): failed, ret = ");
Serial.println(ret);
delay(1000);
}
} while(true);
}
void loop() {
int ret = sdp.readSample();
if (ret == 0) {
Serial.print("Differential pressure: ");
Serial.print(sdp.getDifferentialPressure());
Serial.print("Pa | ");
Serial.print("Temp: ");
Serial.print(sdp.getTemperature());
Serial.print("C\n");
} else {
Serial.print("Error in readSample(), ret = ");
Serial.println(ret);
}
delay(500);
}
This code works just fine on an Arduino UNO R3, but results in an "init(): failed, ret = 1" in the Serial Monitor on the Teensy 3.2.
I simply don't understand why that is?
I also found on this forum, that other's had the same issue with this exact sensor: https://forum.pjrc.com/threads/47868...-Sensor-SDP810
Based on this post, I tried the following code, but still no luck:
Code:
#include "Wire.h"
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
uint16_t combined; //32 bit variable to store the msb and lsb
byte msb;
byte lsb;
Wire.beginTransmission(0x25);
Wire.write(0x361E);
Wire.endTransmission();
Wire.requestFrom(0x25, 2); // contents of your first two bytes
delay(8); //first measurement is available after 8ms, on page 7
msb = Wire.read(); //byte1 is msb
lsb = Wire.read(); //byte2 is lsb
combined = msb<<8; //assign msb to combined variable
combined |= lsb; //add the lsb to the combined variable
Serial.println(combined); //print the differential pressure
delay(500);
}
Here, the Serial Monitor just prints "65535" no matter the actual pressure.
I triple-checked the Wiring and tried three different Teensy boards, so I'm pretty sure that the issue lies in the code.
Help is much appreciated!
Best regards
Johan