What you will need:
- ESP-01 (if you want OTA, you will need 1MB of Flash)
- FTDI 3V UART to TTL with USB (make sure you are using a 3V model)
- Breadboard
- 2 x Pushbutton
- 3 x 10k Ohm resistor
- 1 x 470 Ohm resistor
- optional 1 x 100µF capacitor
- Wires
- DuPont connectors
I was recently trying to upload esphome firmware to my ESP-01 Modules. I was using this cheap programmer from aliexpress and nothing was working.
↑ this did not work (for me)
It turns out I needed some extra components to get this to work. Apparently your programmer usually handles all the pin pulling. But mine doesn't for whatever reason. So these instructions are very general purpose.
Wiring
Pieter's Pages has some amazing resources on this and ESP8266 in general.
This was somehow the most difficult part to find out. To enter flash mode, some pins need to be pulled low and some others high on startup. More precisely the GPIO-0 pin needs to be pulled low on chip startup. This can be easily facilitated with a push button.
If your TTL Programmer does not have a capacitor, you should probably add one to your circuit, sudden power surges from Wi-Fi activity might play tricks on you otherwise. Smaller capacitors are probably fine as well.
This is also the wiring you'll need later on to run the ESP-01 on its own!
You could also combine all of this into a cozy board for your ESP-01 to sit in. I would at least recommend making a small break out board for your ESP to fit onto a breadboard, like so:
Installing ESPHome
My python installation is based on anaconda, but you can probably just use whatever python for windows you already have and get esphome with pip or pip3 respectively.
First I made a new anaconda environment for ESPHome
#make new env conda create --name ESPHome # activate env conda activate ESPHome #get esphome pip install esphome
When using anaconda, you will have to re-activate the ESPHome environment every time you restart anaconda prompt.
Making a flashable firmware
If you're new to esphome it's not a bad idea to run the wizard!
mkdir ESPHome cd ESPHome esphome livingroom.yaml wizard
This will create a file called livingroom.yaml which contains all the information to make the firmware. It will ask you about the node name (how it will appear on the Wi-Fi), if you are using ESP32 or ESP8266 and about your board type. Here you should choose esp01_1m. If you choose esp01 OTA will not work, even if your board has 1 MB of flash.
Great you now have a recipe for a firmware file.
I recommend adding this code snippet to your .yaml to get debug messages:
logger:
level: debug
Optional: to just build the firmware you could run
esphome livingroom.yaml compile
Flashing the ESP-01
Make sure your ESP-01 is in programming mode. Either hold the prog button (pulling it low) when connecting power to your ESP-01/plugging your programmer into the USB socket. Or hold the prog button and press reset. Release the prog button.
Now all that's left to do is run
esphome livingroom.yaml run
This will also compile any changes you made to your .yaml file.
If the esphome prompts you to use either your COM port or OTA, choose the COM port for now.
After flashing is complete, reset your ESP-01 with the reset button. You will now see the serial debug, if you have debug enabled.
Exiting logging mode
To leave the logs press Ctrl+C. This might take a while, but you can speed it up/force it by either resetting the ESP or unplugging the USB to Serial adapter.
Over the air updates (OTA)
Best case scenario, you connect your ESP to a power source, run esphome livingroom.yaml run and it just works
[32mINFO Successfully compiled program.[0m
[32mINFO Resolving IP address of livingroom.local[0m
[32mINFO Address not available when adding xxx.xxx.xxx.xxx to multicast group, it is expected to happen on some systems[0m
[32mINFO Address...
Read more »