Since I recently started to deal more intensively with the topics "Smart Home" and "Home automation" I decided to publish some of my construction sites, stumbling blocks and solutions here. As already mentioned in the article about my Smart-Home-Project V1 I use the WLAN module ESP8266 ESP01, because it is small, reliable and cheap.
In this article I want to show how to put the ESP01 into flash mode and build a circuit to feed this small WLAN module with the Arduino IDE with its own code.
IMPORTANT: Please read on only if you know what you are doing! When flashing, some things can go wrong, for damages etc. I assume no liability! Use the manual, circuit diagrams, code etc. only at your own risk!
Table of contents:
- Flashing firmware of ESP8266-WiFi-Module
- How to flash the ESP8266-ESP01 - Preparation
- How to flash the ESP8266-ESP01 - Wiring Diagram
- Flashing ESP8266-ESP01 - Arduino IDE Setup
Flashing firmware of ESP8266-WiFi-Module
There are several ways to operate the ESP8266. You can address it via a serial interface, for example via Arduino. Alternatively, the ESP8266-ESP01 offers 1MB flash memory and 2 additional GPIO pins, so you can use it alone (standalone mode) and don't have to use another microcontroller.
I decided to use a mix of the two operating modes to control the living room via app, because the 2 pins on the ESP01 are not enough for me and on the other side of the Arduino UNO has relatively little memory and resources.
The ESP8266 was flashed with my own code and now controls all communication with the app and e.g. the Horizon recorder. The chip only forwards the actual control command for LED lighting and e.g. infrared (TV, HiFi) via serial interface to the Arduino, which then only switches the corresponding pins.
How to flash the ESP8266-ESP01 - Preparation
To flash the ESP8266 you need some hardware and software components:
- USB to TTL converter module FT232RL 3,3V/5V - (FTDI Serial Adapter)
- 2K Ohm Resistor
- 1K Ohm Resistor
- Push-Button (must be pressed and held down later when switching on the ESP8266 to start the ESP8266-ESP01 in flash mode; the push button connects GPIO 0 of the chip to Ground)
- Power Supply Module 3,3v/5v and a power supply
- Plug-in board and jumpers / cable (Male-Female and Male-Male)
- ESP8266 ESP01
- Arduino IDE (ich nutze 1.8.5; Stand: Januar 2018)
- Virtual COM Port Driver (i use Win10 for flashing, because MacOS only causes problems for me)
How to flash the ESP8266-ESP01 - Wiring Diagram
The circuit to flash the ESP8266-ESP01 looks like this:
Such a flash station is practical because then nothing can come loose unintentionally and you can simply put the part somewhere in the cabinet when you don't need it.
If necessary, just take it out, put the USB cable and power in, put the chip on top of the docking station and everything is ready to flash.
Flashing ESP8266-ESP01 - Arduino IDE Setup
As described above I use the official Arduino IDE to flash the ESP01 chip. First you have to prepare the Arduino IDE for flashing, so that the environment knows and can handle the chip.
To do this, click on "Settings" in the main menu and enter the following in the field "Additional board administrator URLs":
Then select the menu point Tools -> Board -> Board administrator. Enter "esp8266" into the search field and install the appropriate package. Then you can select "Generic ESP8266 Module" under the menu item Board.
Since I had some problems with flashing at the beginning, I also list my configuration here. On the internet I found several different Configs, but I stayed with this one which works stable and error free. First I flash only under Windows 10 with installed Virtual COM Port Driver, because as already mentioned above Mac here made some problems since the update to HighSierra.
If you have now selected the board "Generic ESP8266 Module" you can now see several settings under this menu item. The main points in my config are as follows. Among other things I had to reduce the upload speed a little bit to be able to complete the write process into the SPI flash memory successfully:
- Flash Mode: DIO
- Flash Size: 512K (64K SPIFFS)
- Reset Method: ck
- Upload Speed: 57600
- Port: COM4
Now you can program your Sketch (*.ino) within the Arduino IDE and write or flash the chip with it.
If you use the ESP01 parallel with e.g. a Arduino UNO R3, and if you want the two to communicate via a serial interface (TX/RX), I recommend a baud rate of only 9600, which is sufficient for smaller amounts of data or commands and you can confidently use SoftwareSerial (or AltSoftSerial), because they do not create a stable higher data throughput.
This is because the Arduino UNO, for example, only has a hardware interface for serial transmission (Pin 0 and 1 -> TX/RX). Especially when debugging and uploading, it is used on the Arduino for the USB connection to the PC, so that in my opinion it's better to directly use SoftwareSerial (or another library like AltSoftSerial) and let the ESP8266 talk about it with the Arduino.
That's it - send me feedback and suggestions by mail or leave a comment here at the website. Have fun progging your own smart home solutions! 🙂
Related postings3D Printing - 27 Inch iMac Stand Repair
As already known for a long time, the stand of the iMacs (27 inch) from 2012 to mid-2014 is often broken. With these models it happens (not all of them) that the hinge is worn out and the screen position can't be changed anymore or, as in my case, the screen constantly tilts forward. 3D … Continue reading "3D Printing - 27 Inch iMac Stand Repair"
3D Printers: Models, Software and Options
Not just since yesterday 3D printers are a great way of printing on the market, which is constantly evolving. Here it is possible to print whole objects using software or scanned originals. This process has proven to be extremely useful both in private use and in numerous professions. In this article I have collected some … Continue reading "3D Printers: Models, Software and Options"
pi_robot - Playing with Raspberry Pi, iPad and some Code
The Raspberry Pi is still one of the most popular mini computers, not only among hobbyists. Cost-effective (about 30 to 40,- EUR depending on the model), flexible in the field of application and at the latest since the equipped with enough CPU power and memory to solve even more complex tasks. With the 1.2 GHz … Continue reading "pi_robot - Playing with Raspberry Pi, iPad and some Code"
My new 3D printer and housing from Ikea side table
I had the intention to buy myself a 3D printer ages ago. However, this project failed until the end due to bad reviews I had to read about various models and their price-performance ratio. This changed when I discovered the at Amazon. This is rated almost completely positive and was reduced from 499,- to 399,- … Continue reading "My new 3D printer and housing from Ikea side table"
Program your own Screen Recorder / Capture Software
While searching for an easy to use screen recorder tool, I stumbled across all kinds of free and paid software solutions. From my point of view, pretty much all of them were either completely overloaded, difficult or complicated to use. Others were just expensive in relation to the functionality. My conclusion: Program yourself! Table of … Continue reading "Program your own Screen Recorder / Capture Software"