Is it wise/right to ground one input pins of a multiplexer/demux if we are not using them!

Actually guys, I am using Nodemcu for my project. As that board only provides 11 GPIO pins (which can be actually used) so I have a question regarding a thing.

As I will be using ESP8266 motor shield and in that shield D1 - D4 pins are dedicated to the 04 DC motors which have to be used. So I can use only 7 pins which are D0, D5 - D8, 2 SD (SD2 and SD3) pins. Also after including couple of sensors I will be left only with 2 GPIO pins.

In those 2 pins I want to use 74HC4051 multiplexer. The pin-layout of this mux is as follows:

As one can see, there are 03 Select lines for the Input. So that is why I will be able to get 2^3 = 8 Output lines from the mux.

I only want to get 4 output lines from the mux which can be achieved through 2 Select lines. So can I Gnd the S2. Will it harm the IC? If yes, then how can I use this IC to use only 2 select lines?

Any help will be of great help :slight_smile:

Yes. You can connect S2 to ground. None of the Sn pins should be allowed to float.

1 Like

Unused CMOS input pins must always have a fixed electric potential.
Don't make it "floating input", you need pull-down or pull-up it.
In this case pull-down is appropriate.

1 Like

@chrisknightley so I can Ground the S2 pin and then I can use the 04 Output pins. Right?

Yes it is.
There is no problem connecting directly tie to GND.

Remember that you did that later when if you tried to add a signal to change to 8ch.

If pull-down to GND with a resistor like 10k, I might do that because it doesn't prevent me from adding a signal later.
(Yeah. That became easy to change even if it's PCB assembled.)
This pull-down with resistor is a measure taken by the inside of many modules and ICs that have "input pins that accept floating".

1 Like

Thanks for the help @chrisknightley . As I will be using the 04 channels of the miltiplexer so I think I am good with GND only.

Just one more question, as I will be using only 2 select lines and therefore I will be using only 4 ouptut lines. So, what should I do with the left out 4 output pins. Can I leave them as it is because I am only using 2 select lines or I have to connect them to ground?

You don't have to connect unused output pins to something, don't connect anything.

Rather, don't connect to GND.
Because significantly increases the risk of causes short circuits condition.

1 Like

Okay I got you. I will connect the last select pin with GND and will leave the 4 output lines as it is. Then it wil work correctly.

Hang on there!

You really have not properly explained what you are trying to do.

You refer to an analog multiplexer, but is seems you are using this in some way to define outputs. This makes no sense as any outputs you are not selecting at any point will not be defined. I cannot see what value that would be.

A multiplexer is a reasonable way to choose analog inputs. For digital inputs it will work, but is not really the best way.

You can control eight outputs using a 74HC595 SIPO register. In fact, you can go on to control 16, 24 and so on by chaining devices using the same three control pins. Similarly, you can use a 74HC166 (or multiple) to read eight inputs (or multiples) using three control pins, one of which (clock) is shared with the 74HC165.

So why do you imagine a multiplexer is useful?

@Paul_B I am also talking about 74HC4051 which is an 8 bit analog multiplexer / demultiplexer. I will use it with Nodemcu to increase the analog pins. The output of the multiplexer will be 8 output line ie A0-A7/ These lines through the Pin 3 ie A (Common Input/output) will be conected to the input to the A0 pin of the nodemcu and thus I will be able to read multiple analog readings. I will use it as a 8*1 multiplexer

Now I hope you get it. If yes, then please confirm that can I use only 2 out of 3 select lines (as I have only 2 GPIO pins left in my modemcu) in order to use 4 analog sensors ? Is it so?

Guys, see in the above example all the 03 select lines have been used with the nodemcu. But in my case as I am having only 02 GPIO pins left so I nned to basially use this 8x1 multiplexer as a 4x1 multilplexer. This is the reason why I am asking that can I use only 02 Select pins (because that wil yield 4 pins at the other end for the 04 analog sensors) and ground the third select pin ?

Because I think Grounding the third select pin will beasically imply a digital 0 for that line! If I can use only 2 select pins then do I have to leave the A4 - A7 output lines as it is (don not have to connect to anything) !

Any take on this @Paul_B @6v6gt @chrisknightley

I'm sure that could work. There may be better way of using those 2 free pins on the NodeMCU like, for example, an I2C port expander and/or I2C ADC, depending on what sensors you wish to connect.

@6v6gt I can't use an I2C expander because in the Esp8266motor shield the 2 I2C pins are taken by the shield to control the motor. So I can't use those along with I2C extender.

So I opted for the multiplexer.

On the ESP8266 you can (normally) change the I2C pins:
You use Wire.begin( SDA, SCL )

No @6v6gt I guess the motor library uses the i2c pin in order to do the communication. So there is no good in changing the pins

Can you provide a link for the motor shield you are actually using?

Regarding grounding inputs.

If you ever make this into a PCB you should ground through a resistor (any value). This way you can still use it as an input.

@chrisknightley , here is the ESP8266 Motor Shield for Nodemcu:

In the GPIO pins section it has D0 - D8 and then 2 more GPIO pins ie SDD3 and SDD2 which makes the total of GPIO pins to 11. Out of 11 D1 - D4 pins are used for controlling the speed and direction of two motors which will be inserted into the shield. (Those pins are internally connected to do the functioning).

I am connecting 2 more sensors after which I will be having only 2 GPIO pins left (D0 and D5). In those I have to use the 8x1 mul. as a 4x1 multiplexer.

Now how do I connect this mux in the left out pins:

  1. What have to be done with the one left out select pin ? EIther I have to ground it or left it as it is?
  2. As I will be using 2 select lines, so only 4 input lines (A0-A3) will be enabled. So what I have to fo with the remaining 4 input lines (A4 - A7). Ground them or leave as it is!
  1. You will have to connect it to GND or 5V. Else the selected IO will vary due to noise in the environment.
  2. In my personal opinion you can leave them floating.
1 Like

@sterretje so I will GND one of the Select pins to the GND so that it sort of gives LOW to the input lines.
And yes, I can leave the 4 input lines floating because I will not be feeding them back to the nodemcu. Hope this works :slight_smile:

To be on the safer side: By the way if the IC gets damaged will it also burn my nodemcu ?