Adding ADC channels to an ESP8266

One of the drawbacks of the ESP8266 is that it only has one ADC port.
In case you need more ADC ports, you could add an I2C ADC converter like the PCF8591 or the ADS1115, but there is a cheaper way that is easier to program as well.
You could use an analog multiplexer like the HCT4051, that can switch 8 ADC channels individually to the ADC input of your ESP8266.
Does this method have drawbacks? yes, you need 3 I/O pins to control the HCT4051 and the ESP8266 does not have an abundance of pins to begin with.
The circuit looks like this:

I have chosen GPIO12-14 to control the multiplex chip. If all control lines are LOW, the A0 line is patched through to the ADC of the ESP8266. If all control lines are HIGH, then the A7 line is patched through to the ADC channel of the ESP8266, the table below, shows the state of the I/O pins need to be in to read every individual analog channel

      S0      S1      S2
      GPIO14  GPIO13  GPIO12
A0     0       0       0
A1 0 0 1
A2 0 1 0
A3 0 1 1
A4 1 0 0
A5 1 0 1
A6 1 1 0
A7 1 1 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.