4 Ways to Expand the ADC Inputs on an ESP8266

expand adc inputs on esp8266

Quick answer: to expand adc inputs on esp8266 boards, add an analog multiplexer, an I2C ADC, an SPI ADC or a second microcontroller. The stock chip has a single ADC pin, so every option either shares that pin or bypasses it.

The decision table below puts the four options side by side. For more builds on this theme, see our arduino robotics projects hub.

Why the single ADC pin runs out

An ESP8266 has a single analog input, labelled A0 on most development boards. That is enough for one potentiometer or one light sensor. It is not enough for a soil-moisture array, a bank of gas sensors or several potentiometers on a control panel.

Two software details matter before you add hardware. The same discussion notes that the SDK’s fast ADC read requires WiFi to be disabled. If your project is a connected sensor node, plan around the normal read and not the fast one.

Clamp or check readings in code, whichever method you choose below. That protects you from the occasional out-of-range value.

Scaling a sensor for A0

A 5 V sensor does not. Reduce it with a resistor divider so its maximum output lands inside the range your board accepts.

A sensor-heavy robot chassis shows how quickly inputs pile up. The HC-SR04 shown is a digital module, so this is illustrative of crowded sensor wiring rather than a multiplexer build.

Fixed divider for one sensor

A two-resistor divider is the simplest fix. Choose the ratio from the sensor’s maximum output, not its typical output, and leave headroom so an excursion cannot push the pin past its limit. Measure the result against a multimeter before trusting it, because real resistors drift from their nominal ratio.

Selectable dividers for mixed signals

If one input must handle different ranges, a switchable front end helps. One ESP8266 ADC front-end project picks among 1:20, 1:10, 1:5 and full-range dividers with an analog switch driven from PCF8574 port bits. Its author calibrated count-to-volt factors of 0.020056 V, 0.01014 V and 0.005014 V per count for the 1:20, 1:10 and 1:5 settings. The lesson is to calibrate each range against a known voltage instead of assuming ideal ratios.

Placing jumper wires with test leads nearby. Checking each divider output with a meter before connecting it to the ADC catches wiring mistakes early.

Divider design applies to every method below. A multiplexer still feeds A0 and needs the same scaling. An external ADC has its own input limits, so check them in its datasheet.

The four options compared

Method Channels gained Resolution Wiring effort Cost Planning use
I2C ADC (ADS1115) A few channels per module Higher than A0; a separate converter Low: data and clock lines plus power Low to moderate Precise readings from a handful of sensors
SPI ADC (MCP3008) More channels per chip than the usual I2C module Comparable to the built-in ADC Medium: clock, data in, data out and a chip-select line Low Many channels with faster transfers than I2C
Second microcontroller (Arduino Uno) Whatever the second board’s pins offer Set by the second board’s ADC Highest: serial link, level shifting and two programs Highest Projects that already need a second board

The shared-converter limit driving this comparison is described in the ESP8266 Arduino core discussion; the channel, effort and cost ratings are relative judgements for hobby builds.

Analog multiplexer on A0

A multiplexer such as the CD74HC4051 routes one of its input channels to a single output, chosen by a few digital select lines. Wire that output to A0, drive the select pins from spare GPIOs, set the select pattern, wait for the signal to settle, then read. You gain channels, not speed or precision. Every reading still goes through the same converter, and the same A0 limits apply.

This suits many slow signals: soil moisture, light levels, panel knobs. It is the cheapest route. The effort is in firmware, because you must loop over channels and delay slightly after each switch. Put your divider on the shared output when every channel carries the same voltage range. Otherwise scale each input before it reaches the multiplexer.

I2C ADC module

An I2C converter such as the ADS1115 is a separate ADC on a breakout board. It connects over a data line and a clock line, so it adds channels and better resolution without consuming many GPIOs.

It is the neatest upgrade when accuracy matters, for example battery monitoring or a thermistor. The trade-offs are a modest channel count and slower conversions than a direct A0 read. Several I2C devices can share the same two wires, as long as their addresses differ.

SPI ADC chip

An SPI converter such as the MCP3008 comes in a DIP package that sits happily on a breadboard. It offers more channels per chip than a typical I2C module and a faster bus. It costs more pins: a clock, data in, data out and a chip-select line.

Choose it when you want many analog channels read quickly and can spare the GPIOs. The resolution is comparable to the built-in ADC, so it will not improve precision.

Second microcontroller as an analog front end

A second board, such as an Arduino Uno, reads the sensors with its own analog pins and passes values to the ESP8266 over a serial link. This makes sense when the second board already runs motors or time-critical loops. For a pure ADC upgrade it is the most work: two programs, a message format and a wiring check.

An Arduino Uno wired by jumper wires to a breadboard with two LEDs, with a laptop behind it.

Watch the logic levels. Also keep the ground connected between boards, or the readings will drift.

A development board connected to a laptop over USB for programming. An I2C converter needs only a data and a clock connection added to such a setup.
An Arduino-style board in a case beside a breadboard. A second board adds wiring and code, not just pins.

Choosing the right method

Start from what the readings are for. Many slow, low-precision sensors point to the multiplexer. A few accurate readings point to the I2C module. Many channels with quick sampling point to the SPI chip. A project that already uses a second board for motors or timing points to the serial link.

A cardboard box holding a blue circuit board and loose wires, with a black electronics module nearby.
  • Prototype on a budget: use the multiplexer and accept the shared-converter limits.
  • Measurement quality: use the I2C converter and keep sensor ranges inside its input limits.
  • Channel count with speed: use the SPI converter if you have the free pins.
  • Existing second board: reuse it, but plan the level shifting first.

Whatever you pick, apply the divider rules from earlier before connecting any 5 V sensor. Keep jumper runs short on breadboards, since loose analog wiring picks up noise easily.

Frequently asked questions

Can I use the fast ADC read while WiFi is on?

No. The firmware documentation, as quoted in the ESP8266 Arduino core issue discussion, says WiFi must be disabled when using the fast read. Use the normal read in connected projects.

Why does my ADC reading sometimes show 1024?

The Arduino core’s read function wraps the SDK call directly, so it can pass back that value. Clamp readings in your code to the range you expect.

Does a multiplexer make ADC reads faster?

No. It shares one converter among several inputs, so the channels are read one after another. Gaining speed needs a separate ADC, such as an SPI chip.

Do I still need a divider if I add an external ADC?

Often yes. The external converter has its own input limits, so scale any signal that exceeds them, just as you would for A0.