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:
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() {
WiFi.mode(WIFI_STA);
WiFi.beginSmartConfig();
while(!WiFi.smartConfigDone()){
delay(500);
}
}
void setup() {
connectToWifi();
}
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) {
if(isWakeUpCall)
WiFi.forceSleepWake();
else
WiFi.forceSleepBegin(30000000);
delay(500);
}
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. :)