I am doing a project that sends data over the Internet using an ethernet shield and then process this data on computer. Arduino is running 24 hours a day and for this reason I want to implement a watchdog but the problem that the maximum time that can be included in the watchdog is 8 seconds.
The question is if there is any way to increase this time.
This is a schematic sketch of what my program. In the loop I'm calling each function to do its particular task but lab_eth function takes 20 to 30 seconds,
/************ LIBRERIAS *************/
#include <avr/wdt.h> //
#include ........................
#include ........................
#include ........................
#include ........................
/********************* DEFINE ******************************/
#define ........................
#define ........................
#define ........................
#define ........................
/********************* VARIABLE ******************************/
char ..........
int .................
/************** SETUP *************************/
void setup()
{
wdt_disable();
Serial.begin(9600);// Velocidad de comunicacion con el monitor
Serial1.begin(9600);// Velocidad de comunicacion por RS485
Wire.begin();
RTC.begin();
if (! RTC.isrunning()){
Serial.println("RTC No Conectado");
}
pinMode(SS_SD_CARD, OUTPUT);
pinMode(SS_ETHERNET, OUTPUT);
pinMode(53, OUTPUT);
digitalWrite(SS_SD_CARD, HIGH); // SD Card not active
digitalWrite(SS_ETHERNET, HIGH);// Ethernet not active
SD.begin(SS_SD_CARD);
Ethernet.begin(mac, ip);//Inicializacion protocolo TCP/IP
labview.begin();// Inicia la comunicacion del servidor
// wdt_enable(WDTO_8S);
}
/*****************************************************************
* *
* PROGRAMA PRINCIPAL *
* *
****************************************************************/
void loop() {
// wdt_reset();
temp ();
debug();
delay(10);
placa_p ();
delay(100);
placa_f ();
delay(10);
card();
delay(10);
lab_eth ();//This function takes 20 to 30 seconds
}
void lab_eth ()
{
digitalWrite(SS_ETHERNET, LOW); // Ethernet ACTIVE
if (digitalRead(SS_ETHERNET) == HIGH){
Serial.println ("ETHERNET NOT ACTIVE");
}
else {
Serial.println ("ETHERNET ACTIVE");
}
EthernetClient clv = labview.available();
if (clv) { //El cliente esta conectado
while (clv.connected()) { //El cliente sigue conectado
if (clv.available()) { // Si el cliente envia datos lo alamaceno
char b = clv.read();
// Envio al cliente la informacion de los sensores DS18B20 y RS485
if (b = 'B'){
clv.print("DS1");
clv.println(DS1);
clv.print("DS2");
clv.println(sensors.getTempC(DS_2));
clv.print("DS3");
clv.println(sensors.getTempC(DS_3));
clv.print("DS4");
clv.println(sensors.getTempC(DS_4));
clv.print("DS5");
clv.println(sensors.getTempC(DS_5));
clv.print("DS6");
clv.println(sensors.getTempC(DS_6));
// clv.print("RS485_1");
// clv.print(hum_p);
// clv.print("\t");
// clv.println(temp_p);
// clv.print("RS485_2");
// clv.print(hum_f);
// clv.print("\t");
// clv.println(temp_f);
}
}//Si el cliente no envia datos acaba la conexion
delay(1);//Retardo de 1 milisegundos
}//Cliente desconectado
clv.stop();// Termina la conexion con el cliente
}// Fin de conxion del servidor con el cliente
else {
clv.stop();
}
digitalWrite(SS_ETHERNET, HIGH); // Ethernet Not Active
if (digitalRead(SS_ETHERNET) == HIGH){
Serial.println ("ETHERNET NOT ACTIVE");
}
else {
Serial.println ("ETHERNET ACTIVE");
}
}
This is a schematic sketch of what my program. In the loop I'm calling each function to do its particular task but lab_eth function takes 20 to 30 seconds,
So, if the wdt_ stuff wasn't commented out, how would that make lab_eth() faster?
What, exactly, do you want to have happen when the watchdog wakes up?
I understand that when the watchdog timer reaches zero restarted the system.
So when the timer reaches zero is that the system is blocked at some point and I want to restart the system starting again