I am completely new to electronics and microcontrollers so please bear
with me while I try to explain.
My current working project controls my plant grow light depending on the
brightness (eg. sun is up/very cloudy/blinds are down).
It does so by using an AZDelivery Nano V3.0 with Atmega328 CH340
(Arduino compatible) to poll a light sensor on an analog pin.
It then compares that value to a calibrated value to decide whether the
plant light should be on or off. This then gets sent by means of serial
communication with a ESP-01s over WiFi to my RaspberryPi** which
switches a TP-Link HS100 smart switch on or off.
Although convoluted, it works fairly well but uses a lot of power as I
never put anything in sleep mode and it's constantly connected to WiFi.
Now I would like to implement some means of saving power so that I can
maybe even run this thing on a 9V battery for, I don't know, weeks at a
Additionally I would like to compare the value from the light sensor not
against a single value because a cloud moving in for a few seconds would
unnecessarily switch the light quickly. I thought that maybe I instead
use an upper and lower bound and only switch when the value exceeds
either, and do nothing in the middle range. I could easily do this in
code however with the power saving I thought that maybe there is a nice
way to do this with some additional parts.
Here are some of the points I'm having trouble with as I have no
experience in electronics:
1. I've read that putting the ATmega328 in sleep disables the ADC,
enabling the ADC in sleep so that it can be used as interrupt consumes a
lot of power. Is there a way to make the lower/upper bound check in
discrete* parts (while not using a lot of power?) so that I just use one
or two digital pins which can wake up the ATmega328 for processing the
2. I've also read that the ESP-01s does not have the means to wake up
from deep sleep without soldering to the extremely tiny chip or by doing
a reset (RST to GND). I would maybe just trigger a reset by pulling the
RST pin of the ESP-01s to LOW through a 330 Ohm resistor and through an
ATmega328 digital pin. Does that make sense?
3. Maybe there is even a way to accomplish the whole thing without even
having to use the ATmega328***. The ESP-01s has a fairly capable
microcontroller that can be programmed and two GPIO pins, so if I was
able to do the brightness comparison in discrete* parts and then use one
or two GPIO pins of the ESP-01s I could technically read the light level
(not the exact value, just whether its below or above the lower and
upper bounds) directly on the ESP-01s and then trigger the RaspberryPi**
from there. Although that leaves the problem with the ESP-01s not being
able to wake up from deep sleep without a reset, or maybe this can be
implemented in discrete* logic too?
I hope that I have explained my issue in a comprehensible manner and
that maybe you guys could give me some pointers what could be possible
or even a completely different and more power saving approach. My main
concern is the ability to save power to be able to run the whole thing
on battery power, although the lower-upper-bound-thing would be a
necessary addition in the future anyways.
For the lulz I have added a picture of the thing that I've made so you
can point and laugh at some shitty beginners project ;) Note that right
now I am using USB to supply power as the 9V battery has already
Thank you for your time,
\* Excuse my probably misuse of the term "discrete logic" or "discrete
parts" - I don't just mean and/or gates and the likes but rather
comparators and other parts outside of the two microcontrollers that I
am currently using.
\*\* I'll probably be able to implement talking to the HS100 directly
from a microcontroller so I can even skip having to talk to the RPi
first but that should not be of concern right now. The Pi right now is
necessary as it contains a real time clock which checks whether the time
is between 8am and 8pm because the plant light should not be on outside
of these hours.
\*\*\* I suppose an even better approach would be to use a variant of
the ESP8266 that has more pins available but I already have three
ESP-01s so I'd like to stick with them now.