AVR/wdt.h:41:10: fatal error: avr/io.h: No such file or directory
this happens because UNO R$ is not a AVR board so how do I fix this issue since the latest Arduino IDE will not allow wdt.h or Io.h or any non-AVR board to load wdt.h or any of the other AVR ".h" files
#include <wdt.h>
/* sensor settings: G1/4 0-1.2 MPa Hydraulic Pressure Sensor */
/* the sensor is cheap and extraordinarily good. Search for models: HK1100C */
const float Voffset = 0.52; /* Volts, depends on the stability of the supply voltage. ideal is 0.5V */
const float Vmin = 0.5; /* Volts */
const float Vmax = 4.5; /* Volts */
const float Pmin = 0; /* MPa */
const float Pmax = 1.2; /* MPa */
const float kPV = (Pmax - Pmin) / (Vmax - Vmin);
/* arduino settings */
/* To avoid voltage variations when switch ON/OFF relays, I strongly recommend that you powering arduino board through USB port, a phone charger is very suitable. */
/* The second solution is to drive the relay block from a separate power supply. I've used the first solution! */
/* Do not forget these recommendations, they are very important, the project will not work properly if the supply voltage is not stable! */
const float SupplyVoltage = 5.0; /* depends on the power supply and the stability of the voltage conversion on the board */
const float MaxDAC = 1024.0;
/* pump sesttings */
const float max_bar_off = 1.85; /* max pressure (permited or posible) */
const float delta = 0.4; /* delta pressure */
const float min_bar_on = max_bar_off - delta; /* the minimum pressure at which the pump starts. The pump will operate from "min_bar_on" to max_bar_off" */
const int Sensor = A2; /* Analogic A2 pin for the pressure sensor */
/* To connect the sensor to a larger distance, use twisted wires, such as in the network cables, */
/* use two pairs of twisted wires, a pair of power supply (+ 5V / GND) and a pair with signal (Data / GND) */
void setup() {
Serial.begin(9600);
pinMode(7, OUTPUT); digitalWrite(3, HIGH); /* We use two control pins for two relays */
pinMode(4, OUTPUT); digitalWrite(4, HIGH); /* to isolate both phases of the pump */
pinMode(Sensor, INPUT); /* enable INPUT mode for sensor */
// wdt_enable(WDTO_4S); /* enable Arduino watchdog, 4 seconds */
Serial.print("START!");
}
// unsigned long time_end = 0; /* "delay for stop" variable, we do not stop the pump immediately, but wait for a few seconds */
// unsigned long stop_delay = 5*1000; /* 5 seconds waiting when the pressure has reached the desired value, then checking if it should be stopped */
void loop(){
int sensorVal=analogRead(Sensor);
unsigned long time_end = 0; /* "delay for stop" variable, we do not stop the pump immediately, but wait for a few seconds */
unsigned long stop_delay = 5*1000; /* 5 seconds waiting when the pressure has reached the desired value, then checking if it should be stopped */
float voltage = (sensorVal* SupplyVoltage) / MaxDAC;
float pressure_bar = abs(kPV *( (float)voltage - Voffset ) ) * 10 ; /* x10 = MegaPascal to Bar; use abs() to avoid negative pressure */
Serial.print("Sensor Value: "); Serial.print(sensorVal); Serial.print(" | ");
Serial.print("Volts: "); Serial.print(voltage); Serial.print(" | ");
Serial.print("Pressure: "); Serial.print(pressure_bar); Serial.println(" bars ");
if (pressure_bar >= max_bar_off) { /* Check if the pressure remains above the limit "max_bar_off" */
if (time_end != 0) { /* Check if the "delay for stop" time is activated */
if ( time_end < millis() ) { /* "delay for stop" end ? then turn OFF the pump */
digitalWrite(4, HIGH);
digitalWrite(3, HIGH);
Serial.println("PUMP => OFF");
time_end = 0; /* reset "delay for stop" and start new Check */
}
} else {
time_end = millis() + stop_delay; /* init "delay for stop" and Check if the pressure remains above the limit "max_bar_off" */
Serial.println("PUMP => WAIT FOR STOP...");
}
} else if (pressure_bar <= min_bar_on) { /* the pressure is lower than the "min_bar_on" and we start the pump */
time_end = 0; /* reset "delay for stop", start de pump and start/loop new Check */
digitalWrite(4, LOW);
digitalWrite(3, LOW);
Serial.println("PUMP => ON");
}
delay(333); /* A check of 3 times per second in the loop is enough for my case */
// wdt_reset(); /* reset Arduino watchdog */
}