Code for an Arduino Automatic Transfer Switch

Greetings all!

I'm pretty new at this and I hope I'm in the right category, apologies if I'm not. Anyhoo I'm building an automatic transfer switch to switch house power to a generator. I have a generator panel which is separate from the main breaker panel, and in the generator panel my MAX draw would be 50 amps. I have 200 amp service in the house but the circuits in the generator panel only draws 50 amps.

Equipment / Parts:

General Description:

I'm using the Nano for a few things, first and foremost to detect Mains power loss, add a delay of a specified amount to give the generator a few minutes to start before switching to generator power. Of course the generator has to be running before the power gets switched at all. So I have the power supply AC to DC converters sensing on a specified pin.

I also have a temperature sensor which will be located inside the box which will switch on intake and exhaust fans (PC Case Fans) when the inside of the box reaches 80 degrees or above. Currently I'm only turning on and off 2 LED's based on temperature.

Lastly, I have a separate red LED that illuminates when mains and generator power are running. Simulating the mains power coming back on while the generator is running.

Problems:

Most of the code seems to work well with some issues that seem small but would be catastrophic in the event of a power outage.

First, I'm not sure how to use the "if" statements because when I simulate a power outage, and switch to generator power everything seems to work just fine. But when I add Mains power back into the mix along with the generator power, I want the SSR to remain on for a specified about of time then shut off. What ACTUALLY happens is the SSR stays on for the specific amount of time but then it turns off then back on again in that loop. It seems to have something to do with my use of the "delay" lines but I'm not sure where to put them. After all sometimes the mains power will return then go back out again so I want the system to stay on generator power for a specified amount of time.

I'm going to add my complete code so if anyone can help I would sure appreciate it. Thanks to you all in advance.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define Type DHT11
//Define LCD pinout
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

//Define I2C Address
const int i2c_addr = 0x27;
LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

int mainsLED = 2;
int genLED = 3;
int mainsDetect = 4;
int mainsPin = 5;
int genDetect = 6;
int genPin = 7;
int sensePin = 8;
int naLED = 9;
int intakeFan = 10;
int genMnLEDred = 11;
int exhaustFan = 12;
int dt = 1000;
int genDelay = 30000;
int mainsDelay = 1000;
int mainsStatus;
int genStatus;
float humidity;
float tempC;
float tempF;
DHT HT(sensePin, Type);

void setup() {
  Serial.begin(115200);
  lcd.begin(20, 4);
  HT.begin();
  pinMode(mainsLED, OUTPUT);
  pinMode(genLED, OUTPUT);
  pinMode(mainsDetect, INPUT);
  pinMode(mainsPin, OUTPUT);
  pinMode(genDetect, INPUT);
  pinMode(genPin, OUTPUT);
  pinMode(naLED, OUTPUT);
  pinMode(genMnLEDred, OUTPUT);
  pinMode(intakeFan, OUTPUT);
  pinMode(exhaustFan, OUTPUT);
}

void loop() {
  delay(2000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temperature: ");
  lcd.print(tempF);
  lcd.print(" F");
  lcd.setCursor(0, 1);
  lcd.print("Humidity:    ");
  lcd.print(humidity);
  lcd.print(" % ");
  lcd.setCursor(0, 2);
  lcd.print("Mains Status:  ");

  if (digitalRead(mainsDetect) == HIGH) {
    lcd.print("On");
    digitalWrite(mainsLED, HIGH);
    digitalWrite(mainsPin, HIGH);
  } else {
    lcd.print("Off");
    digitalWrite(mainsLED, LOW);
    digitalWrite(mainsPin, LOW);
  }
  lcd.setCursor(0, 3);
  lcd.print("Gentr Status:  ");
  if (digitalRead(genDetect) == HIGH) {
    lcd.print("On");
    digitalWrite(genLED, HIGH);
    digitalWrite(genPin, HIGH);
  } else {
    lcd.print("Off");
    digitalWrite(genLED, LOW);
    digitalWrite(genPin, LOW);
  }
  if ((digitalRead(mainsDetect) == HIGH) && (digitalRead(genDetect) == HIGH)) {
    delay(10000);
    digitalWrite(genPin, LOW);
  }

  if ((digitalRead(mainsDetect) == LOW) && (digitalRead(genDetect) == LOW)) {
    digitalWrite(naLED, HIGH);
    delay(dt);
    digitalWrite(naLED, LOW);
  }

  if ((tempF) >= 69.00) {
    digitalWrite(genMnLEDred, HIGH);
    digitalWrite(intakeFan, HIGH);
    digitalWrite(exhaustFan, HIGH);
  } else {
    digitalWrite(genMnLEDred, LOW);
    digitalWrite(intakeFan, LOW);
    digitalWrite(exhaustFan, LOW);
  }
  humidity = HT.readHumidity();
  tempC = HT.readTemperature();
  tempF = HT.readTemperature(true);

  Serial.print(genStatus);
  Serial.println(" Gen Status ");
  Serial.print(mainsStatus);
  Serial.println(" Mains Status ");
  mainsStatus = digitalRead(mainsDetect);
  genStatus = digitalRead(genDetect);
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" % ");
  Serial.print(" Temperature ");
  Serial.print(tempF);
  Serial.println(" F ");
}

How do you make the phase of the generator power match the phase of the mains power so there is no voltage difference?

the function delay() should have been named

freeze_microcontroller_totally_pause_all_code_exection_until_freezingtime_is_over()

The long and clearly speaking name would make users very hesistant to use it.

If you estimate: how many hours of learning is it worth to make your code execute more reliable?
If your answer is 20 hours or more.
Well it will take maybe 2 to 3 hours to learn the basics of non-blocking timing and another 5 to 10 hours to apply it your your code.

here is a tutorial to learn the basic principle of non-blocking timing

best regards Stefan

After having understood how non-blocking timing works
you should learn how to write code that are called state-machines

The combination of non-blocking timing with a state-machine results in reliable always responding code that is easy to maintain.

best regards Stefan

Not sure what you mean. Currently if the power goes out the generator starts automatically but I have to throw a manual transfer switch.

Thank you so much for the direction. I'm going to get on it right now.

That statement tells me you are mixing the generator power with the mains power with no regard to the phase difference in the AC power from each. If you did not mean you are paralleling the generator with the mains, then I do not understand what you are meaning.

Now I understand what you're saying. In this particular scenario the phase doesn't matter since the two phases never cross. If you take a look at the ATS I'm using, in can only be in one of two positions. Either mains power OR generator power but not both, even though both might be running. What I'm attempting to do is keep the switch on generator power for an extra 10 or so minutes before switching back to mains once it's restored. The Nano mains and generator pins might both be high at the same time but the actual switch wouldn't be.

Hello musicman608

Greetings back and welcome to the worldbest Arduino forum ever.

Post a circuit diagram.
A picture is worth a thousand words.

Have a nice day and enjoy coding in C++.

1 Like

Thanks for the explain. Yes, many time the repaired mains power will still have problems when the repair is first tested and power will be restored for a few seconds and then another breaker will open up and kill you power.
I was partners in an emergency computer check processing business and the only thing automatic with our generator was the monthly test run for 10 minutes, as I recall. Once on generator, always on generator until the emergency processing was finished.

Hi @musicman608,

below is a code which should have the same functionality as yours.

The differencies are

  • uses a library called SafeString that allows to use Strings as the name says in a safe way you can install this library from the library-manager

  • completely non-blocking timing for

    • blinking the LED in case mains-power and generator-power are off
    • after mains-power is back on again waiting 10 seconds before switching generator off
    • updating the LCD only once every two seconds
  • all code is structured into functions where each function has a self-explaining name that describes what the code inside the function does
    and does one senseful sub-unit of code

So your function loop() looks like this

void loop() {
  readSensor();
  switchOnOffFans();

  //instead of delay(2000);
  // check if 2000 milliseconds of time have passed by
  // since last time this happened
  if ( TimePeriodIsOver(myLcdTimer, 2000) ) {
    // only when REALLY 2000 milliseconds have passed by
    updateLcd();
    printToSerial();
  }
  
  checkMainsGeneratorStatus();
  myGeneratorStateMachine();
  blinkIfMainsAndGenOff();  
}

Reacting on the mains-power-status and generator-status is done inside a state-machine

This way of programming enables that function loop can run at maximum-speed which means the code is always responsive to whatever changes in combination with delayd actions like waiting 10 seconds before switching off the generator.

The code does compile but it might well be that there is a logical bug because this is a fundamental restructering of your code.

So if you can test this code-version "on the worktable" without really switching generator- and mains-power this would be good.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <SafeString.h> // StefanL38 new library

#define Type DHT11
//Define LCD pinout
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

//Define I2C Address
const int i2c_addr = 0x27;
//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);
LiquidCrystal_I2C lcd(i2c_addr, 20, 4); //, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

int mainsLED = 2;
int genLED = 3;
int mainsDetect = 4;
int mainsPin = 5;
int genDetect = 6;
int genPin = 7;
int sensePin = 8;
int naLED = 9;
int intakeFan = 10;
int genMnLEDred = 11;
int exhaustFan = 12;
int dt = 1000;
int genDelay = 30000;
int mainsDelay = 1000;
int mainsStatus;
int genStatus;
float humidity;
float tempC;
float tempF;
DHT HT(sensePin, Type);

// StefanL38 additional variables
unsigned long myLcdTimer;
unsigned long myBlinkTimer;
unsigned long myGenOffTimer;

cSF(MainsOnOffState_SS, 8);
cSF(GenOnOffState_SS, 8);

byte myState;

const byte sm_normalOperation  = 0;
const byte sm_waitForGenOn     = 1;
const byte sm_waitForMainsOn   = 2;
const byte sm_waitBeforeGenOff = 3;


void setup() {
  Serial.begin(115200);
  Serial.println("Setup-Start");
  
  lcd.begin(20, 4);
  HT.begin();
  pinMode(mainsLED, OUTPUT);
  pinMode(genLED, OUTPUT);
  pinMode(mainsDetect, INPUT);
  pinMode(mainsPin, OUTPUT);
  pinMode(genDetect, INPUT);
  pinMode(genPin, OUTPUT);
  pinMode(naLED, OUTPUT);
  pinMode(genMnLEDred, OUTPUT);
  pinMode(intakeFan, OUTPUT);
  pinMode(exhaustFan, OUTPUT);
  myLcdTimer = millis(); // initialise timing-variable
}



void loop() {
  readSensor();
  switchOnOffFans();

  //instead of delay(2000);
  // check if 2000 milliseconds of time have passed by
  // since last time this happened
  if ( TimePeriodIsOver(myLcdTimer, 2000) ) {
    // only when REALLY 2000 milliseconds have passed by
    updateLcd();
    printToSerial();
  }
  
  checkMainsGeneratorStatus();
  myGeneratorStateMachine();
  blinkIfMainsAndGenOff();  
}


void readSensor() {
  humidity = HT.readHumidity();
  tempC = HT.readTemperature();
  tempF = HT.readTemperature(true);
}


void switchOnOffFans() {

  if ((tempF) >= 69.00) {
    digitalWrite(genMnLEDred, HIGH);
    digitalWrite(intakeFan, HIGH);
    digitalWrite(exhaustFan, HIGH);
  }
  else {
    digitalWrite(genMnLEDred, LOW);
    digitalWrite(intakeFan, LOW);
    digitalWrite(exhaustFan, LOW);
  }
}


void updateLcd() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temperature: ");
  lcd.print(tempF);
  lcd.print(" F");

  lcd.setCursor(0, 1);
  lcd.print("Humidity:    ");
  lcd.print(humidity);
  lcd.print(" % ");

  lcd.setCursor(0, 2);
  lcd.print("Mains Status:  ");
  lcd.print(MainsOnOffState_SS);

  lcd.setCursor(0, 3);
  lcd.print("Gentr Status:  ");
  lcd.print(GenOnOffState_SS);
}


void printToSerial() {
  mainsStatus = digitalRead(mainsDetect);
  genStatus = digitalRead(genDetect);

  Serial.print(" Gen Status ");
  //Serial.println(genStatus);
  Serial.println(GenOnOffState_SS);

  Serial.print(" Mains Status ");
  //Serial.println(mainsStatus);
  Serial.println(MainsOnOffState_SS);

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" % ");

  Serial.print(" Temperature ");
  Serial.print(tempF);
  Serial.println(" F ");
}


void checkMainsGeneratorStatus() {
  
  if (digitalRead(mainsDetect) == HIGH) {
    //lcd.print("On");
    MainsOnOffState_SS = "On";
    digitalWrite(mainsLED, HIGH);
    digitalWrite(mainsPin, HIGH);
  }
  else {
    //lcd.print("Off");
    MainsOnOffState_SS = "Off";
    digitalWrite(mainsLED, LOW);
    digitalWrite(mainsPin, LOW);
  }


  if (digitalRead(genDetect) == HIGH) {
    //lcd.print("On");
    GenOnOffState_SS = "On";
    digitalWrite(genLED, HIGH);
    digitalWrite(genPin, HIGH);
  }
  else {
    //lcd.print("Off");
    GenOnOffState_SS = "Off";
    digitalWrite(genLED, LOW);
    digitalWrite(genPin, LOW);
  }
}


void blinkIfMainsAndGenOff() {
  if ((digitalRead(mainsDetect) == LOW) && (digitalRead(genDetect) == LOW)) {
    // check if "dt" milliseconds have passed by
    if ( TimePeriodIsOver(myBlinkTimer, dt) ) {
      // only when "dt" milliseconds REALLY have passed by
      digitalWrite(naLED, !digitalRead(naLED) ); // invert state of IO-pin naLED with the not-operator "!"
    }
  }
}


// easy to use helper-function for non-blocking timing
boolean TimePeriodIsOver (unsigned long &startOfPeriod, unsigned long TimePeriod) {
  unsigned long currentMillis  = millis();
  if ( currentMillis - startOfPeriod >= TimePeriod ) {
    // more time than TimePeriod has elapsed since last time if-condition was true
    startOfPeriod = currentMillis; // a new period starts right here so set new starttime
    return true;
  }
  else return false;            // actual TimePeriod is NOT yet over
}


void myGeneratorStateMachine() {

  switch (myState) {

    case sm_normalOperation:
      // check if mains-power is lost
      if ( digitalRead(mainsDetect) == LOW)  {
        myState = sm_waitForGenOn;
      }
      break; // IMMIDIATELY jump down to END-OF-SWITCH

    case sm_waitForGenOn:
        // check if generator produces power
        if ( digitalRead(genDetect) == HIGH)  {
          myState = sm_waitForMainsOn;
        }
      break; // IMMIDIATELY jump down to END-OF-SWITCH

    case sm_waitForMainsOn:
        // check if mains-power is back ON again
        if ( digitalRead(mainsDetect) == HIGH)  {
          // when mains-power is really ON
          myGenOffTimer = millis();       // initialise timing-variable
          myState = sm_waitBeforeGenOff;  // start waiting
        }
      break; // IMMIDIATELY jump down to END-OF-SWITCH


    case sm_waitBeforeGenOff:
        // check if 10000 milliseconds have passed by
        if ( TimePeriodIsOver(myGenOffTimer, 10000) ) {
          // when REALLY 10000 milliseconds have passed by (with mains-power on)
          digitalWrite(genPin, LOW);
          myState = sm_normalOperation;
        }

      // check if mains-power is lost
      if ( digitalRead(mainsDetect) == LOW)  {
        // when mains-power is lost
        myState = sm_waitForGenOn; // continue with waiting for generator on
      }
      break; // IMMIDIATELY jump down to END-OF-SWITCH

  } // END-OF-SWITCH
}

best regards Stefan

There was something strange about this line of code

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

you are including a library for I2C-LCDs

#include <LiquidCrystal_I2C.h>

you are using the I2C-library-object

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

but with a paremeter list that caused an compiler-error if I compiled
and for real I2C-displays you only need these parameters

LiquidCrystal_I2C lcd(i2c_addr, 20, 4);

SO are you sure that you posted that code-version that is really running on your microcontroller??

best regards Stefan

You have the wrong library :smiley:

As the names are identical: which library is it?

I have no idea :frowning: I would have told you if I knew; I've seen the use before.

That's the crap with the LiquidCrystal_I2C libraries.

I googled with

and found this one

just as the keyword that occurs

LCD I2C constructor compiler-error: POSITIVE was not declared in this scope

This is the library that works with that constructor https://github.com/fmalpartida/New-LiquidCrystal

My preference is the hd44780 library by Bill Perry (available in the IDE library manager), it is able to automatically configure the wiring of the I2C adapter to the LCD, so no need to specify all the pins, or even the I2C address.

Hello again,

Sorry for the late response, not sure if I mentioned it but I'm a truck driver and am away from home most of the time.

Stefan I tried your code but something wasn't quite right as nothing worked at all, lol. It happens to the best of us. But using the millis function I tried to incorporate the delay that I need for the LCD, but now everything pulsates including the SSR which would cause the generator power to pulsate because the circuit would be broken every 2 seconds. Here's my new code and I'm already taring my hair out and I'm a bald guy so use your imagination :wink: Thanks again in advance for any help.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <TimerOne.h>
#define Type DHT11
#define LCDINT 2000
#define GENSTART 5000
byte lcdd;
unsigned long PreviousTime = 0;
unsigned long TimeForAction;
//Define LCD pinout
const int en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

//Define I2C Address
const int i2c_addr = 0x27;
LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

int mainsLED = 2;
int genLED = 3;
int mainsDetect = 4;
int mainsPin = 5;
int genDetect = 6;
int genPin = 7;
int sensePin = 8;
int naLED = 9;
int intakeFan = 10;
int genMnLEDred = 11;
int exhaustFan = 12;
int mainsStatus;
int genStatus;
float humidity;
float tempC;
float tempF;
String gentrStatus = "ON";
DHT HT(sensePin, Type);

void setup() {
  Serial.begin(115200);
  lcd.begin(20, 4);
  HT.begin();
  pinMode(mainsLED, OUTPUT);
  pinMode(genLED, OUTPUT);
  pinMode(mainsDetect, INPUT);
  pinMode(mainsPin, OUTPUT);
  pinMode(genDetect, INPUT);
  pinMode(genPin, OUTPUT);
  pinMode(naLED, OUTPUT);
  pinMode(genMnLEDred, OUTPUT);
  pinMode(intakeFan, OUTPUT);
  pinMode(exhaustFan, OUTPUT);
  // Timer1.initialize(1000000);
  // Timer1.attachInterrupt(MainGenHigh);
}

void loop() {

  if ((tempF) >= 67.00) {
    digitalWrite(genMnLEDred, HIGH);
    digitalWrite(intakeFan, HIGH);
    digitalWrite(exhaustFan, HIGH);
  } else {
    digitalWrite(genMnLEDred, LOW);
    digitalWrite(intakeFan, LOW);
    digitalWrite(exhaustFan, LOW);
  }
  humidity = HT.readHumidity();
  tempC = HT.readTemperature();
  tempF = HT.readTemperature(true);
  unsigned long currentTime = millis();
  if (currentTime - PreviousTime >= LCDINT) {
    PreviousTime = currentTime;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Temperature: ");
    lcd.print(tempF);
    lcd.print(" F");
    lcd.setCursor(0, 1);
    lcd.print("Humidity:    ");
    lcd.print(humidity);
    lcd.print(" % ");
    // lcd.setCursor(0, 2);
    // lcd.print("Mains Status:  ");

    if ((digitalRead(mainsDetect) == HIGH) && (digitalRead(genDetect)) == LOW) {
      digitalWrite(mainsLED, HIGH);
      digitalWrite(mainsPin, HIGH);
      digitalWrite(naLED, LOW);
      lcd.setCursor(0, 2);
      lcd.print("Mains Status:  ");
      lcd.print(" On ");
      lcd.setCursor(0, 3 );
      lcd.print("Gentr Status:  ");
      lcd.print(" Off ");
    } else {
      digitalWrite(mainsLED, LOW);
      digitalWrite(mainsPin, LOW);
      lcd.setCursor(0, 2);
      lcd.print("Mains Status:  ");
      lcd.print(" On ");
      lcd.setCursor(0, 2);
      lcd.print("Gentr Status:  ");
      lcd.print(" Off ");
    } 
    } else {

    if ((digitalRead(genDetect) == HIGH) && (digitalRead(mainsDetect)) == LOW) {
      digitalWrite(genLED, HIGH);
      digitalWrite(genPin, HIGH);
      digitalWrite(naLED, LOW);
      lcd.setCursor(0, 3);
      lcd.print("Gentr Status:  ");
      lcd.print(" On ");
      lcd.setCursor(0, 2);
      lcd.print("Mains Status:  ");
      lcd.print(" Off ");
    } else {
      lcd.setCursor(0, 3);
      lcd.print("Gentr Status:  ");
      lcd.print(" Off ");
      lcd.setCursor(0, 2);
      lcd.print("Mains Status:  ");
      lcd.print(" Off ");
      digitalWrite(genLED, LOW);
      digitalWrite(genPin, LOW);
    } 
      if ((digitalRead(mainsPin) == HIGH) && (digitalRead(genPin) == HIGH)) {
    digitalWrite(genPin, HIGH);
    digitalWrite(genLED, HIGH);
    digitalWrite(mainsLED, LOW);
    digitalWrite(naLED, HIGH);
  }
    


    if ((digitalRead(genDetect) == LOW) && (digitalRead(mainsDetect)) == LOW) {
      digitalWrite(genLED, LOW);
      digitalWrite(genPin, LOW);
      digitalWrite(naLED, HIGH);
      lcd.setCursor(0, 3);
      lcd.print("Gentr Status:  ");
      lcd.print(" Off ");
    } else {
      lcd.setCursor(0, 3);
      lcd.print("Gentr Status:  ");
      lcd.print(" Off ");
      digitalWrite(genLED, LOW);
      digitalWrite(genPin, LOW);
      digitalWrite(naLED,LOW);
    }

    Serial.print(genStatus);
    Serial.println(" Gen Status ");
    Serial.print(mainsStatus);
    Serial.println(" Mains Status ");
    mainsStatus = digitalRead(mainsDetect);
    genStatus = digitalRead(genDetect);
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println(" % ");
    Serial.print(" Temperature ");
    Serial.print(tempF);
    Serial.println(" F ");
  
    }
  }


So what do you estimate how much time can you work per month on this project?
I have chosen the long time unit month to get a more averaged value as answer from you.

You did not really tell the forum how much experience you have with programming.
The code that you have posted looks like your programming-knowledge is somehow beyond real beginner.

From your latest questions and your last code I estimate that you are a real beginner.
Nothing wrong with beeing a real beginner. Your project will be finished faster if it is clear what your knowledge-level really is.

Putting all code into a 2 seconds timer makes everything blink with a 2 seconds period.

You seem to have not yet a deep understanding how writing code works.
As I mentioned pretty short, my code-version requires an additional library.
and
writing

Is too unprecise as feedback for analysing what is wrong.
As you are a truck-driver:
Imagine you tell an extra-terrestrian beeing seeing a truck for he first time in his life
and say to him for start driving turn the key.

Well if you Insert the key into the truck cab door and turn the key
while what was really meant is Insert the key into the ignition and turn the key

  • Nothing will work. - Of course !
    Maybe these are even different keys for ignition / truck cab door.

Same thing with programming:
Things must be described very precise, code must be written carefully etc.

Taring hair out from whatever part of your body does not help learning programming.

Do you know what it means to install a library with the library-manager?
I assume you don't

Do you know how non-blocking timing works?
I assume you don't

Do you know how to put multiple if-conditions inside a function?
I assume you don't

So what is your imagination how

looks like?

Your latest code-version does

as a short overview

void loop()
  if (2 seconds of time have passed by) 
    do_everything_update_display____switching_transferSwitch_etc_etc

And that is what you have observed.

You did a quick copy and paste of my code. Got an compiler-error
and
immidiately switched back to other code.
Which now does not work too.

Well you have to learn some more details.

best regards Stefan

I'm sorry, yes, I'm a beginner to the extent that I've watched some YouTube videos which were very helpful. I have some basics down like inputs and outputs, digital read and write and when to use them. I didn't copy and paste any of my code, it's all mine which is why I'm probably having so many issues. Finally, Yes, my latest code blew everything up.

I'm usually home every other Friday, Saturday, & Sunday. Hectic work schedule but I still try to fit in time for this project. It's important to me because it's going to be part of my electrical panel so I have to get it right. I thought this was a place to post the kinds of problems I'm having so I could learn from the experts and hopefully move foreword in my project. This is why I said "any help" would be appreciated.

I certainly appreciate the help you've given me this far but as stated before I'm new at this and if my skill level is lacking to your standards then again, I apologize. We all have to learn somehow and I thought this was the forum for it.