0

I'm still learning the basics so please bare with me if something seems unclear ;-)

I want to hook up an Attiny85 to a WiFi module (esp8266) and 2 sensors. The VCC will be provided by a battery pack and a step-up/step-down converter to ensure steady voltage without too much efficiency loss. Right now the modules are all hooked up to the VCC rail, together with the Attiny85 in one circuit.

I would like to take a sample, and then make as much of the circuit power down until the next reading with a 2 minute interval or so.

While looking for power saving modes for the esp8266 and struggling a bit with it, it got me thinking. What if I let Attiny85 handle the WiFi and sensors circuit via an OUTPUT pin and just turn that high or low. I read somewhere that an OUTPUT pin would not be able to supply as much current as if it was directly connected. That would probably be the case for me here since the WiFi module draws significant current.

Maybe using a transistor to "flip the switch" be a good solution instead if that is the case?

So my question is, is my way of thinking here even viable? How do I know what kind of max current can go through an OUTPUT pin?

  • Sorry, maybe I don't understand your point but an esp8266 far exceeds that current draw. Would those numbers not confirm my concern? – miccet May 7 '18 at 14:20
  • Sorry, I mis-read. – Majenko May 7 '18 at 14:22
  • No problem. If the numbers are correct though, it sort of answers at least a portion of the question. – miccet May 7 '18 at 14:27
  • Absolute maximum current for a pin is 40mA. A transistor/mosfet would be a good solution. Make sure all other pins going to the ESP are set to LOW before turning off the power to the ESP. Voltage on the input pins of the ESP should not exceed its Vcc, which will become 0Volt once you turn off the transistor. – Gerben May 7 '18 at 15:51
3

What you want is a P-channel MOSFET to control the power. Something with a nice low "logic level" gate threshold.

schematic

simulate this circuit – Schematic created using CircuitLab

R1 keeps it switched off. Set the output to LOW to pull the gate down and enable the MOSFET.

Be sure to "stop" your Serial connection and set both TX and RX pins to INPUT to prevent damage to the ESP8266 (or ATTiny) while powered off.

  • Might need transistors between the Aduino and the ESP8266 to break the Rx/Tx lines. Otherwise they could go higher (due to the USB interface on the Arduino, which is connected to D0/D) then the ESP8266's VCC pin and could damage the diode clamp's on the ESP8266 inputs, or possibly appear to phantom power it. – CrossRoads May 7 '18 at 18:39
  • I will try to find one that suits my needs and try it out. Regarding the tx/rx lines I set them both to LOW and INPUT before cutting the power. Would that be enough or will the above still be an issue? – miccet May 7 '18 at 19:09
  • That is good. That is really all you need to do. – Majenko May 7 '18 at 19:20
  • In my case VCC will be 3.3V and since GPIO is also from the same power source it will also be 3.3V. Also, once the circuit is cut off from power, I would like to put the attiny85 in sleep mode and not use any power for a while. If I understand this correctly, a P-channel MOSFET needs power to cut the power, is that correct? With this in mind, is this component still the one I want? Sorry, I might not have explained this very well in my question. – miccet May 7 '18 at 19:32
  • It needs a voltage. No (or miniscule) current though. The gate is like a capacitor. Once charged it doesn't draw anything to speak of - only tiny leakage current too small to measure. – Majenko May 7 '18 at 19:35

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.