I'm currently using an Arduino Uno with the Wireless SD shield with an XBEE attached so I can wirelessly send voltages from sensors to a computer. This works great but I am limited to 5 analog inputs. I am thinking of using a Mega but the Wireless SD Shield is the same for both models. Are there any shields/techniques were I can wirelessly transmit up to 15 analog inputs to a PC using XBEE or otherwise,

Many Thanks,



See 74HC4051 multiplexer / demultiplexer. That describes how you can use a multiplexer chip to multiplex analog inputs.

The 74HC4051 multiplexes 8 inputs into one, and the 74HC4067 multiplexes 16 inputs into one. Thus you would only use one analog input, plus 3 or 4 pins to tell the chip which input you want at a particular moment.

The general way a multiplexer works is like this:

Multiplexer example

By outputting a binary pattern to the A/B/C pins you select which input you want active at a particular moment. That is then copied to the output pin (pin 3 in this case). You would connect that to your analog port on the Arduino.

The code would rotate between each of the 8 pins (or 16 pins with the bigger chip), and then do an analogRead.

Example wiring

Connect 4051 chip to Arduino Uno

Example code

// Example of using the 74HC4051 multiplexer/demultiplexer

// Author: Nick Gammon
// Date:   14 March 2013

const byte sensor = A0;  // where the multiplexer in/out port is connected

const byte addressA = 5; // the multiplexer address select lines (A/B/C)
const byte addressB = 6;
const byte addressC = 7;

void setup ()
  Serial.begin (115200);
  Serial.println ("Starting multiplexer test ...");
  pinMode (addressA, OUTPUT); 
  pinMode (addressB, OUTPUT); 
  pinMode (addressC, OUTPUT); 
  }  // end of setup

int readSensor (const byte which)
  // select correct MUX channel
  digitalWrite (addressA, (which & 1) ? HIGH : LOW);
  digitalWrite (addressB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressC, (which & 4) ? HIGH : LOW);
  // now read the sensor
  return analogRead (sensor);
  }  // end of readSensor

void loop ()
  // show all 8 sensor readings
  for (byte i = 0; i < 7; i++)
    Serial.print ("Sensor ");
    Serial.print (i);
    Serial.print (" reads: ");
    Serial.println (readSensor (i));
  delay (1000);
  }  // end of loop

That only does 8 ports, but the 16-port chip would be conceptually similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.