#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp;
unsigned long previousMillis = 0; // Stores last time the action was triggered
const long interval = 1000; // Interval at which to blink (1000 milliseconds)
void setup() {
Serial.begin(115200);
Serial.println("BMP180 test!");
Wire.begin();
if (!bmp.begin()) {
Serial.println("BMP180 not found!");
while (1) { delay(1000); }
}
Serial.println("BMP180 found!");
}
void loop() {
// 1. Get the current time
unsigned long currentMillis = millis();
// 2. Check if the specified interval has passed
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
float temperature = bmp.readTemperature();
int32_t pressure = bmp.readPressure();
Serial.printf("Time: %.1i ms", currentMillis);
Serial.printf(" Temperature: %.1f C", temperature);
Serial.printf(" Pressure: %d Pa\n", pressure);
}
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4
Loading
bmp180
bmp180