I live in an older neighborhood that is in a growing area of town. In the past few years the number of power outages has grown with the population. Given that we don't have access to natural gas, and I already had purchased WGen12000DF, I set out to see if I could automate the starting, stopping, and transfering to and from utility power. This isn't a complete step by step guide of how to exactly replicate what I did, but should serve as a sufficient starting part for the next dude.
Check out the video of the first automated startup and transfer.
You can find all of the items I purchased in the shopping list
Back of the custom board. As you can see I wired an optocouptler backwards and had to reverse the wires.
UI shows the current state of the sensing (Utility and Generator power) and last events that occurred. Also allows manual controlling of the transfer, starting, and stopping of the generator. Web app requires Wifi connection. Mine has a battery backup so it always statys connected.
Web endpoints can be found at: /state and /data
All actions are implemented using a State Machine design pattern. You can see the state actions below in the diagram. Not all states have a specific class. To reduce the complexity and code some states in the diagram are sub states or events in the code.
Application is written in c++ and the web interface is a very simple html page with jQuery communicating to the backend.
- Install vs code
- Install platformio plugin.
Set the following environment variables on your computer with the ssid and password of your wifi.
- ENV_WIFI_PW
- ENV_WIFI_SSID
Set the a server name to log messages to and the port. For more information about logging see Syslog. I used Synology's logging service to send messages to.
- ENV_LOG_SERVER_NAME
- ENV_LOG_SERVER_PORT
Once the controller starts up it will print out the IP for the website. You can also identify it on your router. If you are here, you should know how to do this.
Install the usb drivers Follow directions here: https://bromleysat.com/installing-drivers-for-the-esp32
Click on Upload Filesystem image under Platfom in the PlatformIo plugin. For more information see: https://randomnerdtutorials.com/esp32-vs-code-platformio-spiffs/
It will use a different task, but the same port as the previous instructions. You will need to delete the task to deploy the code and monitor it.
Currently the only way to config the project is making changes to the gpio pins in main and config. Once the changes are made you can then Upload and Monitor in the Platform IO Tasks.
You need to install mingw and set the bin folder to the path. Download here: https://github.com/niXman/mingw-builds-binaries/releases From the platform io widget Open Native, Open Advanced, and run Test. If the code continues to be grayed out after a run, go to featheresp32 -> Miscellaneous and Rebuild IntelliSense Index.
Pin connector for the generator: https://www.amazon.com/MECCANIXITY-Aviation-Connector-Terminals-Waterproof/dp/B09BMYB9Y4/
Reddit post with pin diagrams. https://www.reddit.com/r/OffGrid/comments/mxygik/westinghouse_generator_automatic_transfer_switch/
https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts
https://www.farnell.com/datasheets/73758.pdf
- T1 120v AC for battery charger. Needs neutral that's not supplied by the control module.
- N1 120v AC utility sense. Needs neutral that's not supplied by the control module.
- N2 120v AC utility sense. Needs neutral that's not supplied by the control module.
- N1 + N2 = 240v AC.
- 0 Ground is neg 12v DC from generator.
- 194 is positive 12v DC from generator.
- 23 Transfer, causes a transfer to utility when:
- generator is running and connected to ATS.
- 0 ground -12v DC is connected to 23.
- +12v DC is supplied to 194.
- I wasn't able to trigger the transfer via optocoupler. I could hear a small click in the ATS, but it never fully engaged. It only worked via relay.