I'm using a PCF 8591 ADC for the sake of the photo resistor on it - here.

The project doesn't seem too complicated for a software engineer like myself but I seem to need some help. I'm using an ESP01 to talk to the PCF8591 via i2c which is working fine as far as I can tell. I am also using the ESP01 to switch it on only when I need it (to conserve power). Currently it's going to a basic small NPN transistor. When I switch the ADC from the transistor it seems to have a max value of 127 for the onboard photo resistor BUT if I power it directly via my 3.7v battery, it has a full range up to 255.

Why does it max out? Is there a better way to do this?

enter image description here

  • 2
    \$\begingroup\$ We need a schematic to be sure about what you're doing, but if you're using an NPN transistor to do high-side switching, you're not going to get full voltage to the load. \$\endgroup\$ – Dave Tweed Jun 12 '18 at 19:28
  • \$\begingroup\$ Dave is right, the output is ratiometric but you might go under the minimum voltage of 8591 2.5V \$\endgroup\$ – Dorian Jun 13 '18 at 5:31
  • \$\begingroup\$ Okay I just included the schematic. This may be the first time I ever created a schematic so apologies for any poor form or notation. Hopefully its understandable. I'm using RX on the ESP01 (GPIO3) to send a signal to the base of the transistor. The MCP1826S is a 3.3 LDO voltage regulator. \$\endgroup\$ – BLowe Jun 15 '18 at 3:14
  • \$\begingroup\$ The transistor is put in the wrong place, still it should work. R2 is a bit to big, it steals 100..200 mV, also the transistor. Why do you use a transistor at all ? ESP01 can drive up to 12mA, enough for the AD board. \$\endgroup\$ – Dorian Jun 15 '18 at 13:16
  • \$\begingroup\$ You mean just put GPIO3 staight into VCC of the AD? I'm not sure why I used the resistor (probably left over from a previous problem I tried to solve). For the transistor, I thought I'd use that to be safe. I found the input mA for the AD chip but the board has extra LEDs and I wasn't sure if that would affect the current draw so I just used a transistor to be safe. So where should the transistor be placed if I were to use it? I'll try without but I still want to learn the "right" way. \$\endgroup\$ – BLowe Jun 15 '18 at 13:24

The issue is the voltage drop on R2

I suppose the module schematic is similar to this one:

enter image description here

The current consumption is is the sum of th currents through

  • LED-s ~4mA if the module is like the one in the picture, 2mA if using 1K resistors, you can see on the back
  • POT1 ~ 0.33mA , i can see in the picture it is a 10k pot
  • R3 and R4 ~0.33mA together at most
  • R7 and R8 ~ 1.4mA

I total will be a maximum of 6mA which will translate in 5mA*330ohm = 1.65V voltage drop on R2 (from your schematic) that would leave only 3.3V - 1.65V = 1.65V for the board ( the real value is a bit higher since the current will drop when the supply voltage drops.)

You should lower the value of R1 accordingly only to not endanger the transistor with power on surge current

The maximum collector current of 2N2222 is 600mA , the minimum value for R2 will be 3.3V/600mA = 5.5ohm

The maximum value is given by the maximum voltage drop on R2 let's say 300mV to leave 3V for the AD module than Maximum value for R2 will be 300mV/5mA = 60ohm

It's a good practice to keep the same ground and to switch Vcc rather than GND.


simulate this circuit – Schematic created using CircuitLab

About using the GPIO to supply the module without the transistor there are 99.9% chances that it can work better than with transistor even not needing a current limiting resistor because the GPIO output saturation limits the current at a safe value but since is not clearly documented in the datasheet you do this at your own responsibility.

  • \$\begingroup\$ Thanks for the detailed answer. Why the capacitor? Also when I put the transistor on the VCC side of the AD module it looks like I'll need a PNP vs what I'm using now - NPN. Is that correct? \$\endgroup\$ – BLowe Jun 15 '18 at 15:27
  • \$\begingroup\$ Yes , you need a PNP transistor. The capacitor is needed by MCP1826 to prevent the oscillations on Vcc it is in the datasheet to and also for good working of ESP01. You should also put one before the MCP1826. \$\endgroup\$ – Dorian Jun 15 '18 at 15:33
  • \$\begingroup\$ Okay. I'll give this a shot this weekend and give an update. Thanks! \$\endgroup\$ – BLowe Jun 15 '18 at 15:34
  • \$\begingroup\$ Change only R2 to quickly check that you're on the good path. \$\endgroup\$ – Dorian Jun 15 '18 at 15:37

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.