74HC4051 multiplexing and voltage divider

arduinointegrated-circuitmultiplexertransistorsvoltage divider

I need a voltage source for an Arduino analogue input. I'm making a capacitive sensor with an NPN BC548B transistor. In the emitter, I connect the GND, in the collector, I connect the analog port of the arduino, together with a 5v and a 10k resistor. So, when I'm not touching the transistor's base, there's no GND to interact with the voltage divider, and the arduino reads 1023. When I touch the transistor, GND is activated and current flows the collector producing a voltage across the 10K resistorand the arduino reads something much less than 1023, sometimes almost 0, like 12 or 50.

Since I want to read multiple capacitive sensors, I bougth a 74HC4051 chip to multiplex all the sensors. My idea was to include the voltage divider after the demultiplexing, so I would use only one transistor and one resistor at the port 0 of the arduino, and I'd only switch between the sensors using the multiplexing. The problem is that when I tried to do that, it didn't work, I got lots of random values in the reading. Also, in this scheme:
enter image description here

he uses the voltage divider for each LDR before the demultiplexing, not after. Is there a reason behind it? I believe that the 74HC4051 chip has some internal resistance, but I thought it'd work even with this tiny resistance. Is there something I'm making wrong?

Here's what I am doing:enter image description here
In this scheme, I can read exactly as I intended to do, but when I try to switch the transistor base with the multiplexer, it will present strange results. Also, I couldn't just wire each 'analog 0' of the scheme to a different port of the multiplexer, it'd use too many transistors and resistores.

Best Answer

I see that you got your sensor schematic from the lucaszanella website.

Generally it's a bad idea to connect the transistor's base directly to a pad that anyone will be toughing with their finger. An electrostatic discharge can damage the base and short to 5V. Although 5V seems benign for most people it can be deadly for people with pacemakers.

What you should do is put a 10 mega Ohm resistor between the base and the sensor input.