Above all, I am quite new to the ESP8266 and micro controllers development as a whole. I am now working on a project which is quite simple for now. It basically looks like this:

enter image description here

As you can see, I have an ESP8266 and some input peripheral. Everything works perfectly fine for the moment, I can read the inputs from the motion sensor and 4x3 keypad. And, respectively I can output on the relay and the 5mm LED. In order to make it a real IOT, I have connected it to the internet via Thinger.IO. So, I have my ESP8266 constantly connected to this platform and I can track it anytime, from anywhere.

This is great. But, my optimal goal is to power my configuration from a solar panel and make it independent of the electricity distribution network.

The average working current of the whole system is about 313mA (10000 mAh battery gets completely drained for 32 hours. Its output is 5V, 2.1A).

So, I am now in a search of the best solar panel to fit my needs. An ultimate one would have the following maximal dimensions: 30x35 cm. I am not sure there's a single panel that I can use but I am interested to hear your opinion in this.

Another aspect, that I'd like to optimize is the constant internet connectivity. Basically, I need to have my configuration connected to the internet only when keypad input was made or motion sensor detected something. During the rest of the time, I don't need to be connected to the internet and I assume WiFi module could be suspended somehow. Currently, my code uses SmartConfig and is looks like this:

#include <ESP8266WIFI.h>

void connectToWifi() {


void setup() {


void loop() {


Everything works well. But, as I said, I'd like to be able to start/stop the WiFi module. I tried using the following API:

void toggleWifi(bool isWakeUpCall) {


but without much of a success. Once it gets into this portion of code, it gets completely disconnected and doesn't get connected anymore. I am now struggling with it.

I've read about the sleep modes offered by the ESP8266 but I don't think they are suitable for my case because I can not simulate external interrupt (or maybe I can?).

I am really curious to hear your opinion on this. :)

  • As a solar panel you can use a MEGSUN 10W 12V Mono Solar Panel or similar. They are smaller than what you specified and should be plenty for powering an ESP.
    – Coder_fox
    Commented Nov 3, 2019 at 12:43

1 Answer 1


As described here the ESP8266 can be waken up using Timer Wake Up or external interrupt. The idea is simple: almost everything inside the ESP is powered down (including Wi-Fi and/or System clock or even the CPU) with only a timer running which was told when to activate before the ESP went to sleep. After the desired amount of time has passed the timer triggers GPIO 16 or D0 and if that is connected to the reset pin of the ESP is resets and starts executing code again until it goes to sleep again. For your case you can configure your motion sensor to output a LOW when motion is detected and connect is to a GPIO pin and the reset pin, so it will trigger a restart when motion is detected and in the startup sequence you look at the pin where the sensor is connected and do what you have to do. For the keyboard to work you can have the timer set to reset every 5 seconds, so you would have to hold a button for 5 seconds waiting for the ESP to wake up and accept your input or you could make a dedicated button for waking up the ESP if you want to enter the code. In that case the you don't need a timer, since as you described the ESP only has to do anything if the keyboard is activated or if the motion sensor is triggered and since they can be connected as external interrupts they will wake up the ESP if needed. I would recommend to check out this link for further details about the code and hardware.

  • I have already read a lot of articles regarding Deep Sleep but I am not sure I can achieve that with my current setup. The reason is simple - all of my GPIOs are currently occupied (It is not only what you can see on the diagram. I decided to leave the most important ones there). So, keypad input and motion detection are equal in my use-cases. You can either input on the keypad or you could receive a signal from the motion detection sensor. I don't think 5 seconds timer would be convenient for my case. Because I need to "teach to hold for 5 sec." my end-user which I don't think is a good idea.
    – user60623
    Commented Nov 3, 2019 at 17:06
  • @user60623 In that case you can use a regular Arduino to handle all the IO and use an ESP only when you needed to push the stuff to the cloud. Also, if you are expecting a proper answer provide everything you have not only the "important ones" since solutions are highly specific to the project schematics. And since on the diagram above I saw free pins I assumed you have headroom.
    – Coder_fox
    Commented Nov 3, 2019 at 17:22
  • 1
    Connecting a motion sensor to the reset pin could be problematic. It would cause the ESP to reset every time the motion sensor detected motion, even if it wasn't finished restarting from the last reset. You'd really need some logic that would latch the motion sensing trigger for some time, or until the ESP released the latch. You could build a latching motion sensor trigger with a 555 timer and a few discrete components.
    – Duncan C
    Commented Nov 3, 2019 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.