20static const uint8_t dev_addr = 0x20;
22static const int sda_pin = 0;
24static const int scl_pin = 1;
26const std::string
ssid =
"HARE_Lab";
46 Log.traceln(
"onReceive(%d)", len);
56 Log.traceln(
"onRequest");
66 Log.begin(LOG_LEVEL_TRACE, &Serial);
67 Log.noticeln(
"ESP32 Starting...");
70 Log.noticeln(
"Connecting to WiFi: %s",
ssid.c_str());
74 const int max_wifi_retries = 20;
76 while (WiFi.status() != WL_CONNECTED && wifi_retries < max_wifi_retries) {
82 if (WiFi.status() != WL_CONNECTED) {
83 Log.errorln(
"WiFi connection failed!");
87 Log.noticeln(
"WiFi connected");
88 Log.noticeln(
"IP address: %s", WiFi.localIP().toString().c_str());
91 Log.noticeln(
"Configuring NTP time...");
92 configTzTime(
"UTC",
"pool.ntp.org",
"time.nist.gov",
"time.google.com");
98 time_t now = time(
nullptr);
99 if (now > 1000000000) {
100 Log.noticeln(
"Time synchronized: %s", ctime(&now));
103 Log.errorln(
"Time not synchronized, using system time");
111 Log.noticeln(
"Web server started");
113 Log.noticeln(
"ents-node esp32 firmware, compiled at %s %s", __DATE__,
115 Log.noticeln(
"Git SHA: %s", GIT_REV);
117 Log.noticeln(
"Starting i2c interface...");
125 bool i2c_status = Wire.begin(dev_addr, sda_pin, scl_pin, 100000);
128 Log.noticeln(
"Success!");
130 Log.noticeln(
"Failed!");
Interface for the module handler.
void OnReceive(size_t num_bytes)
Arduino I2C onRecieve.
void RegisterModule(Module *module)
Register a module with a message type.
void OnRequest(void)
Arduino I2C onRequest.
Irrigation module for the esp32.
void CheckAutoIrrigation()
bool time_sync_successful
void onReceive(int len)
Callback for onReceive.
void onRequest()
Callback for onRequest.
const std::string password
Module for controling irrigation valve.
Module for accessing the microSD card.
Interface for controlling the esp32.
void SetupServer()
Setup endpoints for the webserver.
void HandleClient()
Handle requests from the webserver.
Module for WiFi communication.