Some of you might know the framework ESPEasy. It helps you with very common problems and gives you enough flexibility to be able to solve tasks with medium complexity. After some smaller projects I learned a few things about the microcontroller and the framework. This knowledge could be useful if you plan to realize projects with this setup.
Some of the pins of the ESP8266 have special functionality during startup. (this applies to the ESP8266 in general and not only in combination with ESPEasy) The following GPIOs belong to this group of pins: 0, 2 and 15. The following table gives you a hint about the impacts of the different pin-combinations. The first line shows the default combination.
D3 (GPIO 0) | D4 (GPIO 2) | D8 (GPIO 15) | Result | Comment |
---|---|---|---|---|
3.3 V | 3.3 V | GND | Flash | Boot from SPI Flash (Normal startup) |
GND | 3.3 V | GND | UART | Program via UART (TX/RX) |
indifferent | indifferent | 3.3 V | SDIO | Boot from SD-Card |
As you can see it is not advisable to change the states of the pins during startup! Best practice for me: Do not use any of them in my projects.
If you have a look at the webinterface of your ESP8266 flashed with ESPEasy you will notice that the following pins can not be used as switches: D1, D2, D9 and D10. Some of you just ignore this fact, some of you might wonder about it. I would like to use the "Austrian way" => just investigate which needs to be investigated. This means I will not spend too much time to get the point behind D9 and D10, because there is no pin for them on the Wemos D1 Mini. So let's focus on D1 (GPIO 4) and D2 (GPIO 5). If we have a look at the specs we will notice that these two ports are reserved for i²c.
What does this mean for us if we want simple IOs? In this case we are a bit limited with the Wemos D1 Mini. (and most of the other boards based on an ESP8266) If we want to be on the safe side we should stick to A0, D0, D5, D6 and D7. If we would like to use A0 as the only analog pin we only have 4 pins left for our simple IOs.
I hear some of you saying "That is not enough...has to be a solution for this problem". And you are right! If we need more than these pins, we have to use additional hardware like the PCF8574 or the MCP23017. Both communicate with the ESP8266 via i²c (pins D1 and D2) and extend the microcontrollers IOs with 8 additional IOs (PCF8574) or 16 additional IOs (MCP23017).