Automated light control
In this recipe, we will look at automated light control using M2M. We will work on a project that will turn a light source on or off, depending on the light intensity of the surrounding environment. Two ESP8266 boards will be used to accomplish this. One of them will have a light dependent resistor, and the other will have a relay connected to it.
Getting ready
You will need the following hardware components:
ESP8266 board
USB cable
Light dependent resistor (LDR) (https://www.sparkfun.com/products/9088)
10 kΩ resistor
Relay module (http://www.dx.com/p/arduino-5v-relay-module-blue-black-121354)
Breadboard
Jumper wires
Connect the analog input of the ESP8266 board to an LDR connected to a 10 kΩ resistor in a voltage divider circuit, as shown in the following image. This setup is going to act as the input for the system:
As for the output of the system, connect a relay to GPIO2 of the other ESP8266 board. The connection will be via an NPN transistor such as the 2N222, and a diode...