Created
April 24, 2024 10:45
-
-
Save maxpromer/a8448e843a924ad8fcb0ed2a0f69a302 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Dev by Artron Shop Co.,Ltd. */ | |
#include <Wire.h> | |
#include <Adafruit_BMP280.h> | |
#include <AHT20.h> | |
Adafruit_BMP280 bmp; | |
AHT20 aht20; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(F("AHT20+BMP280 test")); | |
Wire.begin(); | |
if (aht20.begin() == false) { | |
Serial.println("AHT20 not detected. Please check wiring. Freezing."); | |
while (1); | |
} | |
Serial.println(F("AHT20 OK")); | |
if (!bmp.begin()) { | |
Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); | |
while (1); | |
} | |
/* Default settings from datasheet. */ | |
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ | |
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ | |
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ | |
Adafruit_BMP280::FILTER_X16, /* Filtering. */ | |
Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ | |
} | |
void loop() { | |
Serial.printf("Temperature: %.02f *C\n", aht20.getTemperature()); | |
Serial.printf("Humidity: %.02f %RH\n", aht20.getHumidity()); | |
Serial.printf("Pressure: %.02f hPa\n", bmp.readPressure()); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment