Files
Arduino/WeatherPredictor/WeatherPredictor.ino
T
2026-07-17 19:43:03 +07:00

40 lines
992 B
Arduino

#include <Arduino.h>
#include <Wire.h>
#include "config.h"
#include "display_ui.h"
#include "sensors.h"
static void i2cScan() {
Serial.println(F("I2C scan:"));
byte found = 0;
for (byte addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.printf(" device at 0x%02X\n", addr);
found++;
}
}
Serial.printf(" %d device(s) found\n", found);
}
void setup() {
Serial.begin(115200);
delay(200);
Serial.println(F("\n=== Weather Predictor booting ==="));
Wire.begin(I2C_SDA, I2C_SCL); // MUST come before any I2C driver begin()
i2cScan();
displayBegin();
displaySplash("Weather", "Predictor v0.1");
if (!sensorsBegin()) Serial.println(F("BMP180 not found!"));
}
void loop() {
float abs_ = readAbsPressureHpa();
float msl = toSeaLevelHpa(abs_, DEFAULT_ALTITUDE_M);
Serial.printf("abs=%.1f hPa msl=%.1f hPa t=%.1f C\n",
abs_, msl, readTemperatureC());
delay(2000);
}