|
@@ -46,6 +46,35 @@ void ARDUINO_ISR_ATTR onTimer(void) {
|
|
|
|
|
|
|
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
|
|
|
|
|
|
|
|
|
+void DHT_test() {
|
|
|
|
|
+ float h = dht.readHumidity();
|
|
|
|
|
+ float t = dht.readTemperature();
|
|
|
|
|
+ if (isnan(h) || isnan(t)) {
|
|
|
|
|
+ Serial.println("Failed to read from DHT sensor!");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Serial.print("Humidity: ");
|
|
|
|
|
+ Serial.print(h);
|
|
|
|
|
+ Serial.print(" %\t");
|
|
|
|
|
+ Serial.print("Temperature: ");
|
|
|
|
|
+ Serial.print(t);
|
|
|
|
|
+ Serial.println(" *C");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void OLED_test() { //pantallazo a blanco y luego iniciando
|
|
|
|
|
+ display.clearDisplay();
|
|
|
|
|
+ display.fillScreen(SSD1306_WHITE); // Pantalla blanca
|
|
|
|
|
+ display.display();
|
|
|
|
|
+ display.clearDisplay();
|
|
|
|
|
+ display.setTextSize(2); // Tamaño texto
|
|
|
|
|
+ display.setTextColor(SSD1306_WHITE);
|
|
|
|
|
+ display.setCursor(0, 0); // Posición
|
|
|
|
|
+ display.println("¡Hola ESP32!");
|
|
|
|
|
+ display.println("OLED OK!");
|
|
|
|
|
+ display.display(); // Muestra
|
|
|
|
|
+ delay(1000);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void setup() {
|
|
void setup() {
|
|
|
Serial.begin(115200);
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
@@ -88,22 +117,14 @@ void setup() {
|
|
|
Serial.println("SD Card Mounted");
|
|
Serial.println("SD Card Mounted");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ OLED_test();
|
|
|
|
|
+
|
|
|
|
|
+ // DHT check
|
|
|
|
|
+ DHT_test();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
//revisar toda esta parte, generada por copilot##########################################################
|
|
//revisar toda esta parte, generada por copilot##########################################################
|
|
|
void loop() {
|
|
void loop() {
|
|
|
- // DHT check
|
|
|
|
|
- float h = dht.readHumidity();
|
|
|
|
|
- float t = dht.readTemperature();
|
|
|
|
|
- if (isnan(h) || isnan(t)) {
|
|
|
|
|
- Serial.println("Failed to read from DHT sensor!");
|
|
|
|
|
- } else {
|
|
|
|
|
- Serial.print("Humidity: ");
|
|
|
|
|
- Serial.print(h);
|
|
|
|
|
- Serial.print(" %\t");
|
|
|
|
|
- Serial.print("Temperature: ");
|
|
|
|
|
- Serial.print(t);
|
|
|
|
|
- Serial.println(" *C");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// GPS check
|
|
// GPS check
|
|
|
if (gpsFlag) {
|
|
if (gpsFlag) {
|
|
@@ -152,16 +173,4 @@ void loop() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Update OLED
|
|
|
|
|
- display.clearDisplay();
|
|
|
|
|
- display.setCursor(0, 0);
|
|
|
|
|
- display.setTextSize(1); // Smaller text for more info
|
|
|
|
|
- display.printf("Temp: %.1f C\nHum: %.1f %%\n", t, h);
|
|
|
|
|
- if (gps.location.isValid()) {
|
|
|
|
|
- display.printf("Lat: %.4f\nLon: %.4f", gps.location.lat(), gps.location.lng());
|
|
|
|
|
- } else {
|
|
|
|
|
- display.println("GPS: No fix");
|
|
|
|
|
- }
|
|
|
|
|
- display.display();
|
|
|
|
|
- delay(1000);
|
|
|
|
|
}
|
|
}
|