An Arduino sketch for setting up a NodeMCU 1.0 (ESP-12E) to control the grow lights for our house plants.
espGrowLights is an Arduino sketch for setting up a NodeMCU 1.0 (ESP-12E) to
control the grow lights for our house plants.
To use this sketch you will need to copy config.sample.h
toconfig.h
and edit it for your wifi (these modules only support 2.4GHz).
You may also want to change the device names in config.sample.h
.
espGrowLights emulates two Belkin Wemo smart plugs that can be
discovered by an Echo so long as they are on the same network. The first device
is the builtin LED. The second controls both relays.
To turn on the grow lights simply say “Alexa, turn on the disco lights.”
To trun on the on board led you can say “Alexa, turn on the esp led.”
You may have noticed that I call the grow lights disco lights… thats because
Alexa kept thinking I was saying “garage lights” when I actually said
“grow lights.” The lights have a bit of a disco feel and that is not similar to
other words so it should keep her from getting cofused.
There is also a momentary push button on the edge of the board that can be used
to toggle the grow lights on or off. The code for this button includes logic to
make it only respond about every 3 seconds after its first pressed. This is so
that you don’t end up rappidly turning the lights on and off multiple times. If
you want to toggle the lights more than once you can either wait a moment or
just hold the button down.
A schedule has also been incorporated into this so that our lights turn
themselves on every morning and off every evening. The on and off hours are also
in config.sample.h
. Note that the off hour uses the 24-hour format. Lastly,
note also that there are also settings for your timezone. I have included sample
entries for UTC and US Eastern (with and without daylight savings).
I’ve added mDNS so that you can verify the device is up by browsing to
http://espGrowLights.local or pinging espGrowLights.local
. That name
corresponds to the HOST_NAME
entry in config.sample.h
. This page also acts
as a sudo console that displays log messages. This allows for basic debugging
withoug connecting to the serial port.
Note: the page automatically refreshes every 30 seconds.
Once the initial setup is done you can push updates OTA directly from the
Arduino IDE without having to connect to it physically so long as you are on the
same network.