The Setup
I'm using a 74HC4051N multiplexer to interface with several analog sensors. I'm using a Wemos D1 Mini to read Z (output from the mux) using the Wemos ADC.

I've only illustrated one (of 4) TMP36 temperature sensors. I'm also monitoring the 12 V line from the battery. I use a 1.6 M ohm resistor to bring the 12 V down to 3.3 V at A0 in conjunction with the internal potential divider of the Wemos.

circuit diagram

The Problem
If I disconnect all sensors (y0-y7) and iterate through all mux addresses, reading off values I get something like the following:

Address 0: Val 12  
Address 1: Val 8  
Address 2: Val 9  
Address 3: Val 13  
Address 4: Val 12  
Address 5: Val 15  
Address 6: Val 10  
Address 7: Val 8  

The low values are expected, the Wemos ADC is a bit noisy.

If I now connect the 12 V sense line only to say y1, the readings look like this:

Address 0: Val 476  
Address 1: Val 802  
Address 2: Val 436  
Address 3: Val 410  
Address 4: Val 469  
Address 5: Val 398  
Address 6: Val 401  
Address 7: Val 451  

The 12 V reading (value of 802) on address 1 looks to be correct. The Mux chip appears to be fine as using the TMP36 sensors on their own I see the expected output:

Address 0: Val 240  
Address 1: Val 920  
Address 2: Val 786  
Address 3: Val 870  
Address 4: Val 12  
Address 5: Val 15  
Address 6: Val 10  
Address 7: Val 8  

What am I missing? Why does it appear to raise the ground level of the ADC?


When anything other than address 1 is selected Y1 will attempt to go to +12V. This will exceed the input rating of the 74HC4051 and almost anything can happen.

Most analog multiplexers do not allow any input voltage to go outside the supply rail limits or current can leak through unintended paths within the device.

It will work correctly when Y1 is selected because the voltage is within range because of the load of the resistors in the D1.

It looks like the 12V is leaking to all the other inputs under the fault condition.

If you want good accuracy I would not recommend relying on the resistor values of the D1 Mini. I would instead use a relatively low-value resistor potential divider to bring down the voltage to one acceptable to the D1.

The resistor values in the potential divider would need to be much lower than the values in the D1. Say 10K ohms.

If you just want to avoid the fault you could use a diode clamp to +5V to avoid the overvoltage condition.

  • \$\begingroup\$ ah perfect answer thanks. I completely overlooked Y1 going to +12v when the mux 'disconnects' from that channel. I assume the resistors in the separate potential divider need to be low(ish) to minimise the parallel resistor effects? \$\endgroup\$ – Oliver9523 May 21 '20 at 8:30

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.