I'm wanting to do the following.
If my computer crashed my gpu cards are not working anymore and are cooling down.
If they cool down i know i need the restart the system. I thought an arduino would be a perfect way for auto resetting my system so tried the following code.
But now with my 30 minute delay in my "if" function it will not give me data in that 30 minutes. I understand that, but don't know how to make it better.
I also want to add a piezo buzzer, so first make an audioble sound for 5 minutes (so if i'm there a know something is wrong) and of temp is still not high enough do the reset. and a blinking led that blinks same amount of crashes.
Hope somebody can please give me some tips.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SHT1x.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
int relay1 = 8;
int relay2 = 9;
int led = 7; //led that blinks how many times crash have occured.
int buzzer = 10; //Make max 5 minutes beep sound before it goes to auto restart
#define dataPin A3 //sht sensor
#define clockPin A2 //sht sensor
SHT1x sht1x(dataPin, clockPin);
int crash = 0; // CRASH NUMBER???
void setup()
{
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(relay1, HIGH); //If i set it high de relay is off.
digitalWrite(relay2, HIGH);// same here
// if I start up my arduino my relay's are not working when it's HIGH instead of Low
// so inverse of like a led;
lcd.init(); // initialize the lcd
lcd.clear();
lcd.setCursor(0,0);
lcd.backlight(); //light up because otherwise my "starting up ..." is in the dark
lcd.print("Starting up...");
delay(1000);
}
void loop()
{
float temp_c;
float humidity;
temp_c = sht1x.readTemperatureC();
humidity = sht1x.readHumidity();
if (temp_c > 23) // now > so i can make temp hotter to follow procedure, but will be other way around
{
//Wants buzzer to make sound (beep, stop, beep, stop) if temp stay low, and stop if temp gets hight.
//think and "if" in an "if" function?
digitalWrite(relay1, LOW); // set relay on for 8 seconds, will push power button HIGH for 8 seconds so computer will shut off
delay(10000);
digitalWrite(relay1, HIGH);
delay(3000);
digitalWrite(relay1, LOW); //start up computer again
delay(3000);
digitalWrite(relay1,HIGH);
delay (18000); // now 30 second but will be 30 minute wait so whole system can restart and temp can go up again.
crash = crash+1;
//LED should blink amount a crashes but don't know how
}
else {
lcd.clear();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("T ");
lcd.setCursor(2,0);
lcd.print(temp_c);
lcd.setCursor(6,0);
lcd.print("C");
lcd.setCursor(8,0);
lcd.print("H");
lcd.setCursor(10,0);
lcd.print(humidity);
lcd.setCursor(0,2);
lcd.print(crash);
delay(500);
}
}