ATTiny13 as "on-off" switch for ESP8266

Hi all,

I’m no engineer but a curious hobbyist who likes to play around with electronics. So, please bear with me.

I have an ATTiny13 here and want to put it to good use. I thought about using it to start/stop an ESP8266 chip when a button is pressed. The ESP will post something and then signal the ATTiny via GPIO12 / PB3 (green wire) that he is done. The attiny will then stop current supply.

Please have a look at the attached circuit.
The button is connected to PB1 (=INT0), pulled to GND. When button is pressed, PB1 is HIGH, INT0 should be triggered. The ATTiny will than compare the time since last trigger. If x seconds have passed, start the ESP.

Now the part I’m not sure that it is working that way.
I want to use an NPN (AFAIK gain 100) on PB4 to activate the power supply for the ESP8266. 1k Resistor on NPN base should be sufficient (3V/1000Ohm=3mA, with gain 100 of the NPN there should be enough current for the ESP8266 peaks). Because the GPIO of the attiny13 can supply up to 40 mA I could use a lower resistor just in case the NPN I will use is not saturated (or has a lower gain at all).

Will this work? Any further suggestions to optimize it? I do have plenty 1k resistors :wink: and some PNP and a few low voltage P-MOSFET. Just in case that could be used to improve my circuit.

Thanks & Best!

In general, lose the fritzing, it's too hard to follow for a circuit. Either use a cad program and post a schematic, or alternatively-just draw it a post the pic. Fritzing is a bunch of spaghetti with some things in it.

One thing I did notice is your button hookup. It wouldn't work. Most of those 4 lead buttons have 2 pins connected on a side. How can you figure it out? Easy, just use 2 diagonal pins, and only those 2.

Hi tinman13kup,

Thanks your your input!

tinman13kup: lose the fritzing, it's too hard to follow for a circuit.

Thanks for the hint. Actually, it was relatively easy to use and it produced fast results. Despite that I have no CAD programm here but I'm open for suggestions what to use. :)

tinman13kup: button hookup. It wouldn't work. Most of those 4 lead buttons have 2 pins connected on a side. How can you figure it out? Easy, just use 2 diagonal pins, and only those 2.

AFAIK both left and right legs, respectively, are "always connected" and on press all four legs get connected. I wondered myself why the opposite legs are always connected. IMHO it is used for the pullup/pulldown. So, why do you think the button won't work? Without press, PB1 is grounded via 10k resistor. When button pressed, PB1 is also connected to Vcc via 1k resistor. Shouldn't this produce a HIGH an PB1? Btw. I think the 1k resistor between the right button leg and Vcc not necessary.

Thanks & best!

If you understand the implications of the switch leads, then you also understand how to set it up to work. It is lost on many people just starting out. Trying to follow your fritzing, yes, it will act as you stated, and yes, the 1k isn't necessary.

In general, it looks like you are trying to use a npn transistor as a high side switch. They are typically used on the low side of the load. For high side switches, a pnp is normally used, but has a few drawbacks when it comes to biasing.

I don't know what small signal transistor you are using, but I'm hearing the esp can demand up to 1A. I was just playing around with one of mine last night and had power coming from a regulated supply. At 3V, I was seeing up to 60mA on a regular basis.

It sounds like you have a grasp on the electronics thing. Google transistor hi/low side switches and see if you can tweak your circuit. Make sure your transistor will handle the current. Make sure your supply will handle the current.

If you cannot get your transistor saturated with your signal, modify into a darlington configuration.

Thanks again for your feedback. I will have a read on high-side/low-side switches. In regards to ESP current draw: the highest value I ever read about were 300mA but I do not have an oscilloscope to test myself. My ESPs draw around 80ms at 2.6V when normally operating. If WiFi has difficulties to connect, the ESP draws more than 200mA continuously.

Best!

I've also read widely diverging numbers on current requirements for 'the esp', which i'm starting to suspect comes down to the myriad of different boards with crappy linear regs on them. The datasheet shows a max of 170mA (although its listed as the typical value, so maybe add on some margin). Ive tended to power mine using a buck/boost, but on another thread someone 'found' a LDO reg with interesting specs (HT7333).

FWIW, I've got an esp-12f using deepsleep and the power consumption when asleep is down in the microamps. I wonder if theres much need for the ATtiny....

ps. datasheets are here; espressif pps. you can do easy schematics using easyeda.com, or install the likes of eagle for something a bit more capable :)

Hi scrumfled,

I've a bunch of ESP put to work. My (black) ESP-01's work with 2 rechargeable AA down to 2.5 V - no capacitors needed. My ESP-12f's need a regulator. They work fine even with the cheap AMS1117-33. However, deep sleep is useless because these draw 10 mA ;). I've found TLV70033 to be pretty nice. Approx 30 µA when idle. Adding the 12-30 µA my ESP12f consumes in deep sleep results in acceptable 42-60 µA. However, my ATMega328p consumes 4µA when sleeping ;) -- Attiny12 not yet tested.

I want to use the Attiny13 to wake up the ESP on pin change. I thought the ESP is not capable of using pin change interrupt in deep sleep. Am I wrong?

Thank you for the CAD program recommendations. I had a look at EasyEDA but I really dislike online tools - or did I overlook the download/offline version? I must be able to use it offline due to Internet problems. I stumbled across LTspice XVII but it seems to be to complex for my hobbyist needs. Nonetheless, I will do some more test.

Thanks & best!