SALES INQUIRIES: 1 (888) 767-9864

ESP8266 ESP-12E Arduino LUX Monitor/Controller w/ IFTTT API :: Student Project

What started out as a simple LDR project has turned into a neat multi-part masterpiece from John Hart! A little background to this project: John has a SmartThings home automation hub that controls some of the indoor house RGB bulbs and things via Z-wave and TCP.

His wife mentioned that it would be much Cooler if those lights came on automatically based on the amount of light in the room, instead of using a specific time or the outside brightness. He decided to see what he could come up with… ‘Arduino Style’!

Parts and Apps used:

  • NODEMCU 0.9 board with ESP8266-12E
  • LDR and 100k resistor
  • LED and 220k resistor
  • HC-06 Bluetooth module
  • Arduino IDE
  • Ardutooth Android App
  • IFTTT.COM account
  • IFTTT applet
  • SmartThings Home Automation System
The current hardware

The current hardware

The current project has the hardware setup relatively simply on a breadboard with the NODEMCU 0.9, HC-06 Bluetooth module, LDR+resistor, LED, and a few jumper wires for connections. The ESP8266 ESP-12E NodeMCU is not strictly an Arduino, but you can use the Arduino IDE to program it.

This is what happens when the light in the room is above the set lux threshold:

  1. Bluetooth starts  
  2. WiFi is put to sleep immediately
  3. It read LDR output values
  4. LDR output values are sent to BTserial port to the HC-06 for broadcast to the Ardutooth App on a phone or tablet
“Phone displaying lux values taken by the Arduino and sent via Bluetooth”

Phone displaying lux values taken by the Arduino and sent via Bluetooth

The Bluetooth connection is not absolutely necessary, but it allows the ESP/LDR to be placed out of the way on a shelf, not tethered to a laptop. Since there is only one dedicated Analog pin on the NODE boards, it is used it for the LDR, and SoftwareSerial is used for the TX/RX Bluetooth pins.

The LDR measures the brightness and if it stays above the threshold, all the Node  does is continue  broadcast the brightness value via Bluetooth,nothing else.

When the lux value drops below the threshold, the magic begins!

  1. A message is sent via Bluetooth “It’s too dark in here…”
  2. The LED turns on, to visually indicate that the threshold has been exceeded
  3. The WiFi wakes up and connects to the router, with Bluetooth status update
  4. Connects to the IFTTT site, with Bluetooth status update
  5. Sends a POST request to IFTTT which contains creds, API, applet_name, etc.
  6. Disconnects from IFTTT
  7. The LED turns off
  8. The WiFi sleeps
  9. A 22 hour delay begins, with Bluetooth status update (We don’t expect dark enough conditions until the next afternoon/evening)
  10. That IFTTT applet_name contains ‘what to do’ with which SmartThings device(s)
  11. IFTTT calls the SmartThings website’s backend, which has been granted permissions
  12. SmartThings tells the house hub via internet/TCP to do what the IFTTT applet_name said to do. (Turn family room lights on)
  13. The SmartThings Hub continues control the lights for 22 hours, until tomorrow evening when the delay expires on the Node, and the LDR above threshold loop starts again


Youtube demonstration of the project in action…

There isn’t too much to ‘show-off’ as far as eye-candy goes, but integrating Arduino, Bluetooth, Wi-Fi, IFTTT, an Android app, and SmartThings into one project is really neat. John’s next step is to simplify the setup using a ESP12F Witty Dev Board that has Arduino, Wi-Fi, LDR, and LED on one board. By testing with this current 

Bluetooth setup, he already has a range of threshold values established and can set those in the sketch on the new board, and can eliminate the breadboards, jumpers, LDR, resistor, and BT board altogether.

ESP8266 programmed with Arduino IDE

The next step John will take is to use one ESP12F board to replace all this

John saysALL THANKS TO YOU and your online goodness that I started learning last summer!”; but Cooler status was achieved by you, John Hart and your great work!


Arduino Code:


Leave a Comment