Giving it a brain
After the necessary wires inside the PC have been identified and tapped, the next step is to program the NodeMCU. The first step in this process is to install the Arduino IDE from Arduino.cc. The IDE is available for Windows, Mac OS X 10.7 or newer, and Linux. I don't have a Mac, and I have only used the IDE on Windows, so alternative OS users following along at home will have to do some of their own research. I'm sure only minor deviations from the instructions are all that would be necessary. Because we are not using genuine Arduino hardware, the wonderful people at Arduino don't see a dime. Consider donating money so its developers can continue their fine work.
Out of the box, the Arduino IDE really only supports Arduino boards and their clones. The developers are such upstanding people that they blessed the IDE with the ability to support third-party boards like the ESP8266-based NodeMCU used in this project. Adding the third-party board support is easy, but not exactly intuitive. Adafruit has a wonderful tutorial, but it is written for Adafruit's Huzzah dev board, which doesn't have a USB port. Setting up for the NodeMCU is even easier because we don't need to fidget with pins or buy a separate USB-to-serial device to get things working.
To add the board support needed for this project, start the Arduino IDE, then click File, Preferences. A window with many options will pop up. Enter "http://arduino.esp8266.com/stable/package_esp8266com_index.json" in the field labeled "Additional Boards Manager URLs:" and click OK. Next, click Tools, Board, and select Boards Manager. Type "8266" in the field labeled "Filter your search". Only one option should appear, so click Install. This might take a minute depending on the state of your computer and your Internet connection. When that is done, click Tools, Board, and select "NodeMCU 1.0 (ESP-12E Module)". The IDE is now ready to program our mighty mite NodeMCU dev board.
The USB-to-serial chip on the NodeMCU requires a driver. Every NodeMCU I have used has a CH340 chip, but given the grab-bag nature of the boards, some units may have FTDI 232 or other USB-to-serial chips. The CH340's Windows driver is available from the Chinese manufacturer's web site, here. Installation is very simple and takes only a second, though the installer will not really give any indication that it has completed its work.
Now that the Arduino IDE is ready and the serial driver is installed, plug the NodeMCU into the PC using a microUSB cable. Windows might take a moment to recognize the new hardware. When Windows stops thrashing and gnashing its teeth, go back into the Arduino IDE.
Flashing the final code onto the NodeMCU and connecting it to the system would be fool-hardy. Testing the board is quite simple, and the board support downloaded in earlier steps includes some code that can help test the integrity of the NodeMCU. Select File, Examples, ESP8266, Blink. The IDE will probably pop open a new window with some simple code. This short program is the "Hello World" of displayless microcontrollers. For now, try not to get bogged down in what the code does—the goal is to make sure the IDE and the NodeMCU work together. Select Tools, Port, and the correct COM port for the NodeMCU. Typically, COM1 is not the NodeMCU. Note that the COM port number will probably change if a different USB port is used.
With the first test code loaded and the correct COM port selected, select Sketch, Upload, or press Ctrl-U. The program should compile, then the IDE should upload the compiled code to the NodeMCU. The blue LED on the NodeMCU will flash rapidly while it receives code from the PC. The compile time and upload speed will vary by computer, but I expect it'll always take longer than one would expect from such simple code. If everything worked, the blue light on the NodeMCU should blink slowly, turning on for one second, then turning off for one second. If you are anything like me, you will probably now waste an hour changing the numbers in the code to make the device blink faster and slower.
If compilation fails, check to make sure the correct board is selected in Tools, Board and reload the example code to make sure it wasn't modified in some way. If the upload fails, try selecting a different COM port from the options in the Tools, Port menu. The third (less likely) scenario is that the PC does not provide enough power for the NodeMCU over the USB port. Try a different port (don't forget to change the COM port in Tools, Port) or try a different PC.
Assuming the IDE and driver software are set up and working properly, the next step is to download the testing and final source code from TR. I've provided Arduino sketches to test the power sensing and control circuits on the device, so you can make sure that the project board is put together properly before flashing the final code and installing the contraption in a PC.