Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <Adafruit_Sensor.h>
- #include <Adafruit_BMP280.h>
- #include <DHT.h>
- #define DHTPIN 4
- #define DHTTYPE DHT11
- DHT dht(DHTPIN, DHTTYPE);
- Adafruit_BMP280 bmp;
- void setup() {
- Serial.begin(9600);
- dht.begin();
- if (!bmp.begin()) {
- Serial.println("Nie można znaleźć czujnika BMP280!");
- while (1);
- }
- }
- void loop() {
- float temperaturaDHT = dht.readTemperature();
- float wilgotnosc = dht.readHumidity();
- if (isnan(temperaturaDHT) || isnan(wilgotnosc)) {
- Serial.println("Błąd odczytu z DHT11");
- } else {
- Serial.print("DHT11 -> Temp: ");
- Serial.print(temperaturaDHT);
- Serial.print(" °C, Wilgotność: ");
- Serial.print(wilgotnosc);
- Serial.println(" %");
- }
- float temperaturaBMP = bmp.readTemperature();
- float cisnienie = bmp.readPressure() / 100.0F; // hPa
- Serial.print("BMP280 -> Temp: ");
- Serial.print(temperaturaBMP);
- Serial.print(" °C, Ciśnienie: ");
- Serial.print(cisnienie);
- Serial.println(" hPa");
- Serial.println("----------------------------");
- delay(2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement