Often electronic equipment is damaged due to a sudden power outage. This often happens due to uncertain natural conditions, forcing PLN to carry out maintenance on its electricity distribution equipment. In addition, many electrical equipment can be damaged by sudden power outages. To be able to overcome this, people usually use generator to overcome supply failures manually. Based on this background, the author created an Automatic Transfer Switch (ATS) – Automatic Main Faillure (AMF) based on the STM32F103C8T6 microcontroller which is applied to generators when there is a power outage. The ATS – AMF device is made using Relays, PZEM004T Voltage Sensors, magnetic contactors, Miniature Circuit Breakers, stepdown circuits, LCD TFT and STM32F103C8T6 as control systems. This system uses the Fault Tolerance method so that the system can continue to run even if there is damage to the main battery by adding a backup battery as a backup. The results of this study, the Automatic Transfer Switch (ATS) circuit found that the average time needed for the generator to start is 2.5 seconds and the time needed for the generator to produce a stable voltage is 5.7 seconds, thus this time is used as the author's reference in determining the right time to switch the load on the microcontroller so that the load is not damaged due to unstable generator voltage. Whereas in the Automatic Main Failure (AMF) it was found that the Stepdown circuit used to detect whether or not PLN electricity was very responsive because the stepdown circuit was installed in parallel at the PLN source and can be proven by the results in the Arduino application.