ESP8266 as ISP program for ATMega16
1. Uploading the sketch to your ESP8266


Tools > Board > select the appropriate ESP8266 board
File > Examples > ESP8266AVRISP > Arduino_Wifi_AVRISP
Change lines 7 and 8 to match the SSID and password of your WiFi router
Sketch > Upload
After the upload completes unplug the ESP8266 from your computer.


2. Generating the .hex file and the upload command


Open the sketch you want to upload to your ATmega16
Tools > Board > ATmega16
File > Preferences > Show verbose output during: > upload (check)
Sketch > Upload
The sketch will compile and then the upload will fail. This is the expected behavior. The goal of this process is to generate the .hex file that will be uploaded and the correct upload command.
Scroll the black console window at the bottom of the Arduino IDE window up until you see a line that looks something like:


>

E:\Arduino\hardware\tools\avr/bin/avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM54 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_288143/Blink.ino.hex:i


3. Connecting the ESP8266 to the ATmega16

Connect the ESP8266 to your ATmega16 board as follows:

+----------+-----------+
| ESP8266  | ATmega16  |
+----------+-----------+
| GPIO12   | MISO      |
| GPIO13   | MOSI      |
| GPIO14   | SCK       |
| GPIO5    | RESET     |
+----------+-----------+


You also need to power the ATmega16. It is recommended to use 3.3 V since this is what the ESP8266 is running at. Make sure the ground of the ESP8266 is connected to the ground of the ATmega16.

4. Starting the ESP8266AVRISP


Plug the ESP8266's USB cable back in to your computer
Tools > Serial Monitor
Select 115200 from the baud rate menu in the bottom right corner of Serial Monitor
You should see something like



  IP address: 192.168.0.100
  Use your avrdude: avrdude -c arduino -p  -P net:192.168.0.100:3000 -t # or -U ...


5. Uploading via ESP8266AVRISP


The second line you saw in the Serial Monitor in step 4 is the sketch's attempt to give you the AVRDUDE command you need to run to upload to your ATmega16 via the ESP8266AVRISP. Unfortunately they got a bit vague at the end. Apparently they are trying to steer you towards using AVRDUDE in terminal mode via the -t option but also mentioning that -U might be preferred. I recommend the latter since the Arduino IDE has helpfully generated the -U command for you already.
Since you need to run a custom AVRDUDE command to upload to your ATmega16 over the network you will not be able to do the upload via the Arduino IDE. Start the command line on your computer.
Now you need to merge the upload command you generated when you did the intentionally failed upload to the ATmega16 in step 2 with the command that was printed to Serial Monitor in step 4. In my examples, this merged command would be:


>

E:\Arduino\hardware\tools\avr/bin/avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -c arduino -p atmega16 -P net:192.168.0.100:3000 -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_288143/Blink.ino.hex:i



Your command will be similar to mine but the path to avrdude, avrdude.conf, the IP address, port, and path to the .hex file will be different. Enter your merged AVRDUDE command at the command line.
The upload should now proceed successfully.


Comments

The above is quite a complex process. Although it will be significantly easier with subsequent uploads, it will likely still not be as easy as an upload via the Arduino IDE. I would not recommend regularly using the ESP8266 as an AVR ISP simply because it's what you have on hand. Instead I would strongly recommend you to just buy a cheap (~$3 USD with free shipping from China) 6 pin USBasp from eBay.

The primary benefit of using the ESP8266 for this application is that it can be done over the WiFi network rather than the traditional USB connection but it's questionable how often that will truly be useful.