You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void loop() {
Wire.beginTransmission(XDB308_ADDR); // Starte I2C-Kommunikation
Wire.write(0x00); // Schreibe die zu lesende Registeradresse
if (Wire.endTransmission() == 0) { // Überprüfe, ob die Übertragung erfolgreich war
Wire.requestFrom(XDB308_ADDR, 2); // Fordere 2 Bytes Daten vom XDB308 an
if (Wire.available()) {
byte msb = Wire.read(); // Lese das höherwertige Byte
byte lsb = Wire.read(); // Lese das niederwertige Byte
int sensorValue = (msb << 8) | lsb; // Kombiniere die Bytes, um den Sensorwert zu erhalten
float voltage = sensorValue * (0.4 / 65535.0); // Berechne die Spannung
float pressure_mpa = voltage * MAX_PRESSURE / 0.4; // Berechne den Druck in MPa
float pressure_bar = pressure_mpa * 10; // Umrechnung von MPa in bar
Serial.print("Druckwert: ");
Serial.print(pressure_bar);
Serial.println(" bar");
}
}
delay(1000); // Warte eine Sekunde, bevor erneut gelesen wird
}
`
When I look at it in the serial monitor, I only see 0.20 MPa or 2.02 bar
But when I blow into the sensor with my mouth, the value doesn't change. what am I doing wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I need help Integration an i2c pressure sensor XDB308 into esphome
`#include <Wire.h>
#define XDB308_ADDR 0x6D
#define MAX_PRESSURE 0.4
void setup() {
Wire.begin(); // Initialisiere I2C-Bus
Serial.begin(9600); // Initialisiere serielle Kommunikation
}
void loop() {
Wire.beginTransmission(XDB308_ADDR); // Starte I2C-Kommunikation
Wire.write(0x00); // Schreibe die zu lesende Registeradresse
if (Wire.endTransmission() == 0) { // Überprüfe, ob die Übertragung erfolgreich war
Wire.requestFrom(XDB308_ADDR, 2); // Fordere 2 Bytes Daten vom XDB308 an
}
delay(1000); // Warte eine Sekunde, bevor erneut gelesen wird
}
`
When I look at it in the serial monitor, I only see 0.20 MPa or 2.02 bar
But when I blow into the sensor with my mouth, the value doesn't change. what am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions