Skip to content

Instantly share code, notes, and snippets.

@maxpromer
Created April 24, 2024 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxpromer/a8448e843a924ad8fcb0ed2a0f69a302 to your computer and use it in GitHub Desktop.
Save maxpromer/a8448e843a924ad8fcb0ed2a0f69a302 to your computer and use it in GitHub Desktop.
/* 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