/*
LPS22HB - Read Pressure Temperature and Humidity
This example reads data from the on-board LPS22HB sensor of the Nano 33 BLE Sense,
converts the atmospheric pressure sensor values to pressure at sea level,
and prints them to the Serial Monitor every 5 second.
The circuit:
- Arduino Nano 33 BLE Sense
This example code is in the public domain.
*/
#include <Arduino_LPS22HB.h>
#include <Arduino_HTS221.h>
//local height above sealevel
float height = 408; // meine Höhe am Standort
void setup() {
Serial.begin(9600);
while (!Serial);
// Start pressure sensor
if (!BARO.begin()) {
Serial.println("Failed to initialize pressure sensor!");
while (1);
}
//intialize humidity temperatur sensor
if (!HTS.begin()) {
Serial.println("Failed to initialize humidity temperature sensor!");
while (1);
}
}
void loop() {
// read the sensor value from pressure sensor
float pressure = BARO.readPressure();
//print the pressure
Serial.print("Pressure is ");
Serial.print(pressure);
Serial.print(" kPa in ");
Serial.print(height);
Serial.println(" m");
// float altitude = 44330 * ( 1 - pow(pressure/101.325, 1/5.255) );
float temperature = HTS.readTemperature();
float humidity = HTS.readHumidity();
// print te temperature
Serial.print("Temperature is ");
Serial.print(temperature);
Serial.println(" °C");
// print Humidity
Serial.print("Humidity is ");
Serial.print(humidity);
Serial.println(" %");
//calculate Pressure at Sealevel
HTS.end();
// print an empty line
Serial.println();
// wait 5 second to print again
delay(5000);
}n
Das Programm stoppt bei der Ausführung schon im Setup Teil mit der Meldung:
"Failed to initialize humidity temperature sensor!"
Ich nehme an die Sensoren werden über eine Serielle Leitung abgefragt und das geht so nicht. Ich finde in der Doku für den Nano 33 BLE Rev2 aber kein Beispiel wie das für mehr als ein Sensor nacheinander geschehen kann
vy 73 de DF9TW, Thomas