16ch Sparkfun Multiplexer Breakout Board

I am currently playing around with the breakout board from sparkfun to add more analog inputs to my nodemcu. The problem I am running into in that i cannot seem to find a good source to help me understand the coding in order to reach each of the pins on the board to read the data coming from sensors. Was wondering if anyone had any advice or resources?

Thanks in advance :slight_smile:

Did you read the description over at SparkFun? SparkFun Analog/Digital MUX Breakout - CD74HC4067 - BOB-09056 - SparkFun Electronics

You have to connect 4 pins from your nodemcu to the select lines of the breakout board and the signal pin on the breakout board to an analog input pin. By setting your address pins, you select channel 0 to 15 to connect to your signal pin which you then read. If you look at it in binary, it looks like this:

S3 S2 S1 S0
0 0 0 0 = channel 0
0 0 0 1 = channel 1
0 0 1 0 = channel 2
0 0 1 1 = channel 3
...

blh64:
Did you read the description over at SparkFun? SparkFun Analog/Digital MUX Breakout - CD74HC4067 - BOB-09056 - SparkFun Electronics

You have to connect 4 pins from your nodemcu to the select lines of the breakout board and the signal pin on the breakout board to an analog input pin. By setting your address pins, you select channel 0 to 15 to connect to your signal pin which you then read. If you look at it in binary, it looks like this:

S3 S2 S1 S0
0 0 0 0 = channel 0
0 0 0 1 = channel 1
0 0 1 0 = channel 2
0 0 1 1 = channel 3
...

I read the material posted on the site about the product, but my question is more of how do I code for it to read values from each individual channel and where do I put the code for the sensor to operate.

// change S0..S3 to the actual pins you use
// make sure they are least significant bit to most significant bit (S0 to S3)
const int addressPins = { S0, S1, S2, S3 };
const int analogPin = X;  // set to whatever pin you connect to
int analogValue[16];

void readAllChannels() {
  for ( int ch = 0; ch < 16; ++ch ) {
    for ( int i = 0; i < 4; ++i ) {
      digitalWrite( addressPins[i], bitRead( ch, i ) ); // set the address lines
    }
    analogValue[ch] = analogRead(analogPin);
  }
}