So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By shivansps
#94977 Hi,
im working on a simple project that is pressing a button, the ESP-01S plays a message via a speaker, then it needs to shut down, as it going to be powered by AA bats or a 3.7v Lithium.

The problem i have is that im good at coding but not at electronics, so i went ahead and by using the examples of the ESP8266 audio lib i quickly managed to have the ESP-01 playing a flac audio file stored on LittleFS via the software delta-sigma DAC using just a NPN transistor and a 1K resistor. It is recomended to use a 2n3409 but i found that a 2n2222 produces a higher volume.

This part is fine, but after the audio is played i need everything to shutdown in order not to drian the battery. I tried to use ESP.deepSleep();, but i found out that cant be used while the ESP is wired to a transistor, the pin state after during deepSleep causes the transistor to be active and a constant current passing trought the speaker. This also overheats the transistor to the point it may burn it, i didnt allow it to get to the point.

If the 8266 could be placed into sleep mode i trought maybe just a push button wired to RST and GND may be enoght, but that is impossible it seems. Also that would leave the 3.3v regulator and the 5v step up active.

So im not sure how to do this, maybe a mosfet? something that is enabled by pressing the button, then a GPIO enables to maintain it so when the audio is done i can just change the GPIO state?
User avatar
By btidey
#94981 You have 2 separate issues here. First how to avoid drawing current from your 'DAC' output when in deep sleep. Second is how to trigger the start up from the push button and shut it down.

You can avoid the output problem in a number of ways. You could use an output that goes hi-z in deep sleep and use a pull down resistor to ensure your npn transistor defaults off. You could use a pnp transistor (e to 3.3V, c to load). This way any pull up current from the output will keep the transistor off. You could also use a mosfet instead of the bipolar transistor which will give even more drive capability and help eliminate heating problems if you are driving a speaker directly.

For the trigger issue, my preferred solution to wake using a button is to use it to start the ESP from the EN pin. A GPIO is then set high to keep the ESP enabled via diode. When you need to sleep you just set the GPIO low and the enable goes low to turn the device off. Note this assumes the EN does not already have a pull up like on an ESP-12. If you are using a dev module (not a good idea for battery powering) then this will have a pull up and you would need to adjust the resistor values to ensure it gets pulled down by default.

SwitchEnable.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
By shivansps
#94988 The ESP-01S does not need to enable EN for some reason. Most ESP-01 projects i saw has the EN pin wired to 3.3v, but thats not needed with the S version. What also prevents the use of a switch enable i think.

Im not sure how or why, but the ESP8266 audio lib says i should use a 2N3904 transistor, and that one is active during deep sleep. But now that i tested it, this does not happens with a 2N2222 transistor, but i dont know why. That one also produces higher volume than the 3904.

Since this does not happens im testing right now consumption during deep sleep, but im petty sure the AMS1117 is going to kill the battery.