#define THINGER_SERIAL_DEBUG
#include <ThingerESP32.h>
//#include <WiFi.h>
//#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306Wire.h"
#include <DHT.h> //en Wokwi recomienda usar la de ESP: #include "DHTesp.h"
#include <BH1750.h>
#define DHTPIN 17 // Digital pin connected to the DHT sensor -> HE USADO EL PIN 13
#define DHTTYPE DHT22 //en lugar de: #define DHTTYPE DHT11
#define pin_rele 25
#define PERIOD_OLED 4000
#define PERIOD_mail 3600000
#define USERNAME "xxxx"
#define DEVICE_ID "xxxx"
#define DEVICE_CREDENTIAL "xxxxx"
#define SSID "Wokwi-GUEST"
#define SSID_PASSWORD ""
ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
// create an OLED display object connected to I2C
//SSD1306Wire display(0x3c, SDA, SCL);
SSD1306Wire display(0x3c, 4, 15); // o SSD1306Wire display(0x3c,4, 15, GEOMETRY_128_64);
DHT dht(DHTPIN, DHTTYPE);
BH1750 lightMeter; //I2C0 al mismo bus que la OLED
void setup() {
pinMode(pin_rele, OUTPUT);
digitalWrite(pin_rele, LOW);
Serial.begin(9600);
Wire.begin(4, 15); //no haría falta porque ya lo inicializa para el display
lightMeter.begin(); //voy a dejar el modo por defecto
dht.begin();
thing.add_wifi(SSID, SSID_PASSWORD);
Serial.println("Probando sensores");
// initialize OLED display with I2C address 0x3C
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
// no voy a poner el código
}
void loop() {
// no voy a poner el código
}