safwan092

Project_10660_Code

Jan 5th, 2023
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <Adafruit_Sensor.h>
  3. #include <Adafruit_BME280.h>
  4. #include <LiquidCrystal_I2C.h>
  5.  
  6. LiquidCrystal_I2C lcd(0x27,16,2);
  7.  
  8. #define SEALEVELPRESSURE_HPA (1013.25)
  9.  
  10. Adafruit_BME280 bme;
  11.  
  12. void setup() {
  13. Serial.begin(9600);
  14. lcd.init();
  15. lcd.init();
  16. lcd.backlight();
  17.  
  18. if (!bme.begin(0x76)) {
  19. Serial.println("Could not find a valid BME280 sensor, check wiring!");
  20. while (1);
  21. }
  22. }
  23.  
  24. void loop() {
  25. Serial.print("Temp:");
  26. Serial.print(bme.readTemperature());
  27. Serial.println("*C");
  28.  
  29. Serial.print("Hum:");
  30. Serial.print(bme.readHumidity());
  31. Serial.println("%");
  32.  
  33. Serial.print("Pr:");
  34. Serial.print(bme.readPressure() / 100.0F);
  35. Serial.println("hPa");
  36.  
  37. Serial.print("Alt:");
  38. Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  39. Serial.println("m");
  40.  
  41. lcd.setCursor(0, 0);
  42. lcd.print("Temp:");
  43. lcd.print(bme.readTemperature());
  44. lcd.print("*C -");
  45.  
  46. //lcd.setCursor(0, 1);
  47. lcd.print(" Hum:");
  48. lcd.print(bme.readHumidity());
  49. lcd.print("%");
  50.  
  51. lcd.setCursor(0, 1);
  52. lcd.print("Pr:");
  53. lcd.print(bme.readPressure() / 100.0F);
  54. lcd.print("hPa -");
  55.  
  56. lcd.print(" Alt:");
  57. lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  58. lcd.print("m");
  59.  
  60. Serial.println();
  61. delay(1000);
  62. lcd.clear();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment