Theoretically the ESP8285 has 17 GPIO pins and one ADC pin. The bad news is that many of these are already assigned to specific functions. Some of them are still usable, with restrictions, some aren't usable at all.
First here are GPIO states for various boot modes:
GPIO0 | GPIO2 | GPIO15 | |
---|---|---|---|
Normal startup | 1 | 1 | 0 |
Programming | 0 | 1 | 0 |
Boot from SD | 0 | 0 | 1 |
Because these pins have to be in a specific state at startup, they can't be used as inputs. We also need to be aware that GPIO0 might change state if we are using it as an output - i.e., whatever hardware is connected to that pin needs to be able to handle that.
After startup, we can do whatever we want with these pins.
GPIO6, GPIO7, GPIO8 and GPIO11 are completely unuseable.
GPIO16 is used by 'wake from deep sleep', and I would like to play with that.
So, that leaves nine completely unused GPIO pins. We want the following pins:
- MOSI
- SCK
- Latch Enable
- Neopixel data
- HV enable
- HV adjust
In addition, I want to play with USB charge detect, so I also want:
- Charge enable
- Charge 0 enable
- Charge 1 enable
That is all nine free pins. However I would also like, if possible to give access to I2C for expansion - that is an additional two pins.
Fortunately, if we are careful, we can also use the three boot pins (GPIO0, GPIO2 and GPIO15).
So, this is the plan:
Pin | Function | Restrictions | Clock Use |
---|---|---|---|
0 | Boot mode select | Can't be used as an input. State during boot is dependent on boot mode. | Neopixel data |
1 | TX0 | During boot, debug is output on this pin. | SDA |
2 | Boot mode select/TX1 | Can't be used as an input. There is an external pull-up on this pin, so it also can't be used for applications that require Hi-Z (such as I2C). | HV Enable |
3 | RX0 | During boot, while debug is being output on GPIO1, this is held high. So, if we use GPIO1 as SDA and this as SCL, no data will make it to any slaves. | SCL |
4 | SDA | This is the default SDA pin, we moved I2C to GPIO1 and GPIO3 because it can handle the noise at boot, so it frees up this pin. | HV Adjust |
5 | SCL | This is the default SCL pin. But we need it for, we moved I2C to GPIO1 and GPIO3 because it can handle the noise at boot, so it frees up this pin. | CHRen |
6-8 | Flash | On the ESP8266 these are used to interact with the flash memory. Unfortunately, they are not freed up in the ESP8285. | - |
9 | Flash | On the ESP8266, this is used for flash, but on the ESP8285 it is free. Yay! | CHR1 |
10 | Flash | On the ESP8266, this is used for flash, but on the ESP8285 it is free. Yay! | CHR0 |
11 | Flash | Still not available on the ESP8285 | - |
12 | MISO | SPI Master in/slave out. We don't need it for that... | Latch Enable |
13 | MOSI | SPI Master out/slave in | MOSI |
14 | SCK | SPI clock | SCK |
15 | Boot mode select | Can't be used as an input. There is an external pull-down on this pin. | Free |
16 | Wake from sleep | This is used by the deep-sleep mechanism, should we want to use it. | Free |
A0 | ADC | This is used for analog in. We attach a LDR to it. | LDR |
By leaving two pins for I2C, I have an easy way to add more GPIO (including ADC) plus a whole host of peripherals like a little OLED screen for debug.
All control of the clock will be via WiFi, including setting the time, so there is no immediate need to add buttons and switches, but I2C GPIO expansion could be used if more are needed.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.