Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Arduino & Microcontrollers

Arduino Multiplexer 74HC4051: Read 8 Analog Sensors on 3 Pins

Arduino Multiplexer 74HC4051: Read 8 Analog Sensors on 3 Pins

March 11, 2026 /Posted byJayesh Jain / 0

The 74HC4051 multiplexer (or MUX) solves one of the most frustrating limitations of the Arduino Uno — only 6 analog input pins. With the arduino 74hc4051 multiplexer, you can connect 8 analog sensors to a single Arduino analog pin, selecting each sensor with just 3 digital control pins. This makes it possible to read temperature sensors, potentiometers, force sensors, light sensors, and more, all without upgrading to a larger board. This guide covers everything from the theory to working code and practical project ideas.

Table of Contents

  1. How a Multiplexer Works
  2. 74HC4051 Pinout and Key Specs
  3. Wiring the 74HC4051 to Arduino
  4. Basic Code: Reading All 8 Channels
  5. Expanding to 16 or 64 Channels
  6. Bidirectional Use: Digital and Analog
  7. Project: 8-Sensor Environmental Monitor
  8. Accuracy Tips and Common Mistakes
  9. Frequently Asked Questions

How a Multiplexer Works

A multiplexer is essentially an electronically controlled switch. The 74HC4051 contains 8 individual CMOS transmission gates, each connecting one of 8 channel pins (C0–C7) to a common I/O pin (Z). Three address/select pins (A, B, C) form a binary address (0–7) that chooses which channel is connected to Z at any given moment.

Think of it as a rotary selector switch that can change position in nanoseconds. When you set address 000 (binary), channel C0 connects to Z. Address 011 connects C3, address 111 connects C7, and so on. Only one channel is connected at a time — all others are open circuits.

Crucially, the 74HC4051 is bidirectional. Signal can flow in either direction through the switch, making it useful for both input (reading sensors) and output (routing signals to different destinations).

Recommended: Arduino Uno R3 Beginners Kit — the Uno is the ideal starting board for multiplexer projects, and this kit includes everything you need to begin.

74HC4051 Pinout and Key Specs

The 74HC4051 is a 16-pin DIP IC. Here are the pins you need to know:

Pin(s) Name Function
1, 2, 4, 5, 12, 13, 14, 15 C0–C7 8 multiplexed channel I/Os
3 Z Common I/O (connect to Arduino analog pin)
6 E (Enable) Active LOW — tie to GND to always enable
9, 10, 11 A, B, C Binary address select (A = LSB, C = MSB)
7 VEE Negative supply (tie to GND for single-supply)
8 GND (VSS) Ground
16 VCC (VDD) Power supply (2 V–10 V)

Key Electrical Specifications

  • Supply voltage: 2 V–10 V (use 5 V with Arduino Uno)
  • Signal voltage range: VSS to VDD (0 V to 5 V in single-supply mode)
  • On resistance (RON): ~80Ω at 5 V (affects ADC accuracy — see tips)
  • Switching time: ~10 ns at 5 V — effectively instant for Arduino applications
  • Crosstalk between channels: −60 dB typical

Wiring the 74HC4051 to Arduino

For the standard configuration reading 8 analog sensors on one analog pin:

Power Connections

  • 74HC4051 VCC (pin 16) → Arduino 5V
  • 74HC4051 GND (pin 8) → Arduino GND
  • 74HC4051 VEE (pin 7) → Arduino GND (single-supply mode)
  • 74HC4051 E/Enable (pin 6) → Arduino GND (always enabled)

Signal Connections

  • 74HC4051 Z (pin 3) → Arduino A0 (analog read pin)
  • 74HC4051 A (pin 11) → Arduino digital pin 2
  • 74HC4051 B (pin 10) → Arduino digital pin 3
  • 74HC4051 C (pin 9) → Arduino digital pin 4
  • 74HC4051 C0–C7 → your 8 sensors (the other sensor lead connects to GND or VCC as appropriate)

Add a 100 nF decoupling capacitor between VCC and GND, and a 10 kΩ pull-down resistor from the Z pin to GND. The pull-down prevents floating readings when channels are switching.

Recommended: LM35 Temperature Sensors — analog sensors that pair perfectly with the 74HC4051 MUX to read 8 temperature points from a single Arduino analog pin.

Basic Code: Reading All 8 Channels

Here is a complete, production-ready sketch for reading all 8 channels sequentially:

const int S0 = 2;  // Address A
const int S1 = 3;  // Address B
const int S2 = 4;  // Address C
const int SIG = A0; // Common output from 74HC4051

int muxChannel[8][3] = {
  {0,0,0}, // CH0: A=0, B=0, C=0
  {1,0,0}, // CH1
  {0,1,0}, // CH2
  {1,1,0}, // CH3
  {0,0,1}, // CH4
  {1,0,1}, // CH5
  {0,1,1}, // CH6
  {1,1,1}  // CH7
};

void setup() {
  Serial.begin(115200);
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
}

int readMux(int channel) {
  digitalWrite(S0, muxChannel[channel][0]);
  digitalWrite(S1, muxChannel[channel][1]);
  digitalWrite(S2, muxChannel[channel][2]);
  delayMicroseconds(10); // Allow switch to settle
  return analogRead(SIG);
}

void loop() {
  for (int i = 0; i < 8; i++) {
    int val = readMux(i);
    Serial.print("CH"); Serial.print(i);
    Serial.print(": "); Serial.println(val);
  }
  Serial.println("---");
  delay(500);
}

The 10 µs delay in readMux() is important. After changing the address pins, the MUX switch needs a short time to settle before the ADC takes a reliable reading. Without this delay, you may read a blend of the previous and current channel’s voltage.

Expanding to 16 or 64 Channels

Two 74HC4051s → 16 Channels

Connect two 74HC4051s to the same A, B, C address lines. Use one additional Arduino digital pin for chip select: connect it to the Enable (E) pin of each IC, but invert it for the second (use a NOT gate or simply connect E of IC1 to the select pin and E of IC2 to the inverted select). Each IC’s Z pin connects to a separate Arduino analog pin (A0 and A1). This gives you 16 channels using 4 Arduino digital pins and 2 analog pins.

74HC4067: The 16-Channel Single-IC Alternative

The 74HC4067 is a 16-channel single-supply MUX in a 24-pin package. It uses 4 address lines (A, B, C, D) and a single Enable pin. One 74HC4067 gives you 16 channels using 5 Arduino digital pins and 1 analog pin — simpler than cascading two 74HC4051s.

Recommended: DHT11 Digital Relative Humidity and Temperature Sensor Module — while digital sensors don’t need a MUX, they complement analog-muxed setups in multi-parameter environmental monitoring stations.

Bidirectional Use: Digital and Analog

Because the 74HC4051 switch is bidirectional, you can use it for digital signals too — routing one digital output to 8 different destinations, or reading 8 digital inputs through one Arduino pin.

Audio Signal Routing

The 74HC4051 is rated for audio frequencies. Its −3 dB bandwidth exceeds 100 MHz at 5 V, and with −60 dB channel-to-channel isolation, it is used in audio mixing, switching between microphone inputs, and test equipment. The ~80Ω on-resistance causes a small signal attenuation (typically <1 dB into a high-impedance input) which is usually negligible.

Digital I2C Bus Switching

Route one Arduino I2C bus to 8 different I2C sensor groups, each with the same address. Select the group via the address pins, then communicate normally. This solves the common I2C address conflict problem without needing expensive I2C multiplexer ICs like the TCA9548A.

Project: 8-Sensor Environmental Monitor

This project uses 8 LM35 temperature sensors connected through a 74HC4051 to monitor temperatures at 8 locations simultaneously. Results are displayed on a Serial monitor and could easily be sent to a web dashboard via an ESP8266 or logged to an SD card.

Hardware

  • 8× LM35 temperature sensors
  • 1× 74HC4051 MUX
  • Arduino Uno
  • Optional: SD card module for data logging

LM35 Connection per Channel

Each LM35: VCC → 5V, GND → GND, OUT → Cx pin of 74HC4051. The LM35 outputs 10 mV/°C, so at 25°C the output is 250 mV. Reading the analog pin: float tempC = analogRead(A0) * (5.0 / 1023.0) * 100.0;

float readTemp(int channel) {
  int raw = readMux(channel);
  float voltage = raw * (5.0 / 1023.0);
  return voltage * 100.0; // LM35: 10mV per degree
}

void loop() {
  for (int i = 0; i < 8; i++) {
    float temp = readTemp(i);
    Serial.print("Sensor "); Serial.print(i+1);
    Serial.print(": "); Serial.print(temp, 1);
    Serial.println(" °C");
  }
  delay(2000);
}
Recommended: BMP280 Barometric Pressure and Altitude Sensor I2C/SPI Module — add atmospheric pressure monitoring alongside your muxed temperature sensors for a comprehensive weather station.

Accuracy Tips and Common Mistakes

  • On-resistance error: The 74HC4051’s ~80Ω RON forms a voltage divider with your sensor’s output impedance. For best accuracy, use sensors with low output impedance (<1 kΩ), or buffer each sensor output with a rail-to-rail op-amp (e.g., MCP6004).
  • Settling time: Always add at least 10 µs delay after setting address pins. For high-impedance sensors, increase to 100 µs.
  • Floating channels: Unconnected MUX channels float and can inject noise into adjacent channel readings. Connect unused channels to a known voltage (e.g., tie to GND through a 10 kΩ resistor).
  • ADC reference: Use analogReference(INTERNAL) (1.1 V internal reference on Uno) for sensors with output ranges below 1 V — this significantly improves resolution.
  • VEE pin: In single-supply mode (VEE = GND), the signal voltage must stay between GND and VCC. Negative input voltages will damage the IC. For bipolar signals, apply a negative supply to VEE.
  • Power supply noise: The MUX switching current can inject noise into the analog supply. Use a separate 5 V regulator for the MUX and sensors, or at minimum add a 10 µF electrolytic + 100 nF ceramic capacitor bank near the IC.

Frequently Asked Questions

Can I use the 74HC4051 with a 3.3 V Arduino (Nano 33, Zero, MKR)?

Yes. The HC-series operates down to 2 V. At 3.3 V, RON increases slightly to around 100–120Ω, but the IC works correctly. Keep signal voltages within 0–3.3 V. The 74HC4051 is particularly useful with the Nano 33 BLE which has only 8 ADC pins.

What is the maximum sampling speed across all 8 channels?

The Arduino Uno’s ADC conversion takes about 104 µs. Adding 10 µs switching delay per channel, reading all 8 channels takes approximately (104 + 10) × 8 = ~912 µs — about 1,100 full scans per second. For faster scanning, reduce ADC prescaler to 16 (800 kHz ADC clock) to cut conversion time to ~16 µs, achieving ~4,500 full scans/second.

Can the 74HC4051 handle PWM signals?

Yes. PWM signals are digital square waves and the 74HC4051 passes them correctly within its bandwidth. However, if you read the common Z pin with analogRead(), you will get the average DC voltage of the PWM signal, not the duty cycle. Use digitalRead() or pulse timing for PWM signals.

What is the difference between 74HC4051 and CD4051?

Both are 8-channel MUXes with the same pinout. The HC version is faster, has lower on-resistance, operates at lower voltage, and consumes less power. The CD4051 is a CMOS legacy part that can handle wider supply voltages (3 V–18 V) and higher signal voltages relative to supply. For Arduino projects, the 74HC4051 is preferred for its better performance at 5 V.

Can I use the 74HC4051 to multiplex SPI devices?

Not recommended for full SPI buses because the on-resistance and capacitance degrade high-speed SPI signals. However, you can MUX the SPI chip-select (CS) lines — connect each device’s CS to a MUX channel and use the MUX to assert CS on the target device. This is a legitimate and widely used technique.

Expand your Arduino’s sensor capabilities without upgrading boards. Explore our wide range of Arduino boards, sensors, and ICs at Zbotic — with fast shipping across India and expert technical support.

Tags: 74HC4051, analog sensors, arduino input expansion, multiplexer, MUX, sensor interfacing
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Arduino Starter Kit Comparison...
blog arduino starter kit comparison best kits to buy in india 2026 594807
blog arduino voice recognition ld3320 and easyvr module guide 594811
Arduino Voice Recognition: LD3...

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now