08-07-2024, 04:50 PM
In the end you can solve it using the following code, I share it in case someone needs it.
Now my problem is trying to enable the Watchdog, it is not respecting the function esp_task_wdt_reset() since I am constantly resetting the card, if anyone has any example of Watchdog on the esp32 S3 I would appreciate it.
Code:
#include "Arduino.h"
#include "PCF8574.h"
#include <Wire.h>
#include <WiFi.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include "esp_system.h"
#include "esp_task_wdt.h"
#include <U8g2lib.h>
#define INT_GPIO 41
#define MISO_GPIO 40
#define MOSI_GPIO 44
#define SCK_GPIO 4
#define CS_GPIO 39
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetClient ethClient;
PubSubClient client(ethClient);
void(* resetFunc) (void) = 0;
void setup() {
while (!Serial && (millis() < 5000));
delay(500);
// Configurar SPI con los pines especificados
SPI.begin(SCK_GPIO, MISO_GPIO, MOSI_GPIO, CS_GPIO);
// Inicializar la conexión Ethernet
Ethernet.init(CS_GPIO); // Inicializar con el pin CS
Ethernet.begin(mac);
// Esperar a que se asigne una dirección IP
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found.");
while (true) {
delay(1); // No continuar
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
} else {
Serial.print("Ethernet IP: ");
Serial.println(Ethernet.localIP());
}
//Inicializar el Watchdog Timer
esp_task_wdt_config_t config;
config.timeout_ms = 30000; // Establece el tiempo de espera a 30 segundos
esp_task_wdt_init(&config);
esp_task_wdt_add(NULL);
}
void loop() {
esp_task_wdt_reset();
}Now my problem is trying to enable the Watchdog, it is not respecting the function esp_task_wdt_reset() since I am constantly resetting the card, if anyone has any example of Watchdog on the esp32 S3 I would appreciate it.

