Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <LiquidCrystal.h>
- #include "i2c_BMP280.h"
- // Inicjalizacja obiektów
- LiquidCrystal lcd(2, 3, 4, 5, 11, 12); // RS, E, D4, D5, D6, D7
- BMP280 bmp280;
- void setup() {
- Wire.begin(); // Start interfejsu I2C
- lcd.begin(16, 2); // Inicjalizacja LCD 16x2
- lcd.print("Inicjalizacja");
- if (!bmp280.initialize()) {
- lcd.clear();
- lcd.print("BMP280 blad");
- while (1); // Zatrzymanie programu
- }
- delay(1000);
- lcd.clear();
- }
- void loop() {
- float temp = 0.0;
- float pressure = 0.0;
- bmp280.awaitMeasurement(); // Oczekiwanie na zakończenie pomiaru
- bmp280.getTemperature(temp); // Odczyt temperatury (°C)
- bmp280.getPressure(pressure); // Odczyt ciśnienia (Pa)
- pressure /= 100.0; // Przeliczenie Pa -> hPa
- lcd.setCursor(0, 0);
- lcd.print("Temp: ");
- lcd.print(temp, 2); // 2 miejsca po przecinku
- lcd.print(" C");
- lcd.setCursor(0, 1);
- lcd.print("Cisn: ");
- lcd.print(pressure, 2); // 2 miejsca po przecinku
- lcd.print(" hPa");
- delay(1000); // 1 sekunda
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement