add bmp
This commit is contained in:
parent
5346e3f5a6
commit
7cca316b53
40
include/bmp.h
Normal file
40
include/bmp.h
Normal file
@ -0,0 +1,40 @@
|
||||
#include <Adafruit_BMP280.h>
|
||||
|
||||
namespace Bmp {
|
||||
|
||||
Adafruit_BMP280 bmp; // I2C Interface
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println(F("BMP280 test"));
|
||||
|
||||
if (!bmp.begin(0x76)) {
|
||||
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.print(F("Temperature = "));
|
||||
Serial.print(bmp.readTemperature());
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print(F("Pressure = "));
|
||||
Serial.print(bmp.readPressure() / 100); //displaying the Pressure in hPa, you can change the unit
|
||||
Serial.println(" hPa");
|
||||
|
||||
Serial.print(F("Approx altitude = "));
|
||||
Serial.print(bmp.readAltitude(1019.66)); //The "1019.66" is the pressure(hPa) at sea level in day in your region
|
||||
Serial.println(" m"); //If you don't know it, modify it until you get your current altitude
|
||||
|
||||
Serial.println();
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
@ -80,6 +80,11 @@ namespace Display {
|
||||
colonOn = !colonOn;
|
||||
}
|
||||
|
||||
void displayFloat(float value) {
|
||||
clockDisplay.print(value);
|
||||
clockDisplay.writeDisplay();
|
||||
}
|
||||
|
||||
void displayValue(int value) {
|
||||
clockDisplay.print(value, HEX);
|
||||
clockDisplay.writeDisplay();
|
||||
|
||||
@ -21,6 +21,8 @@ lib_deps =
|
||||
ottowinter/AsyncMqttClient-esphome@^0.8.5
|
||||
crankyoldgit/IRremoteESP8266@^2.7.18
|
||||
arkhipenko/TaskScheduler@^3.4.0
|
||||
adafruit/Adafruit Unified Sensor @ ^1.1.4
|
||||
adafruit/Adafruit BMP280 Library@^2.5.0
|
||||
build_flags = -D IR=1
|
||||
|
||||
[env:laptop_home]
|
||||
|
||||
@ -17,8 +17,9 @@ Task tWifiConnected(onWifiConnected, &ts);
|
||||
#include "mqtt.h"
|
||||
#include "ota.h"
|
||||
#include "ir.h"
|
||||
#include "bmp.h"
|
||||
|
||||
#define STAY_CONNECTED_AFTER_BOOT 5*60
|
||||
#define STAY_CONNECTED_AFTER_BOOT 30*60
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
@ -28,6 +29,9 @@ void setup() {
|
||||
Ntp::setup();
|
||||
Ir::setup();
|
||||
Mqtt::setup();
|
||||
Bmp::setup();
|
||||
Display::displayFloat(Bmp::bmp.readTemperature());
|
||||
delay(3000);
|
||||
|
||||
hourChanged.setWaiting();
|
||||
wifiConnected.setWaiting();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user