Introduction: Easy IoT Ambient Light Sensor & Lux Meter Using NodeMCU and Cayenne

In this project I will create IoT ambient light sensor to control lamp, using NodeMCU and Cayenne.

Cayenne is so powerfull to create IoT project, with less coding we can get awesome result.

This IoT ambient light sensor work with condition:

1. If the ambient lux value above 50 lux, the relay will switch OFF the lamp.

2. If the ambient lux value below 50 lux, the relay will switch ON the lamp.

3. The lamp will be automatically on everyday at 5 pm and off at 7 am.

Step 1: Bill of Materials

Hardware Required :

1. NodeMCU ESP-12E

2. 1 CH Relay Module

3. TSL2561 Lux Sensor

4. Jumper Cable

Software Required :

1. Arduino IDE

2. Cayenne for iOS/Android/Web Browser

3. TSL2561 Library

4. Adafruit Unified Sensor Library

Step 2: Connecting NodeMCU to TSL2561 and Relay Module

NodeMCU_______TSL2561_________Relay

VIN_____________ Not connected____VCC (+)

3.3V____________ VCC____________Not connected

GND____________GND____________GND

D1______________SDA____________Not connected

D2______________SCL____________Not connected

D5______________Not connected____Not connected

Step 3: Programming the NodeMCU

In this step we will program the NodeMCU with Arduino IDE.

First, you need to import Adafruit TSL2561 library to your Arduino IDE. You can search TSL2561 library from Sketch - Include library - then search Adafruit TSL2561 and install it then search Adafruit unified sensor and install it.

Second, download LUX_METER.ino from this step.

Third, open LUX_METER.ino and edit your Cayenne token, SSID, password and then connect your NodeMCU with USB Cable to your computer and upload the code to NodeMCU.

Step 4: Setting Up Cayenne Widget

Do this step on Cayenne :

  • Add Relay Switch widget from Cayenne Dashboard, and select Virtual Pin 1.
  • Add TSL2561 widget from Cayenne Dashboard, and select Virtual Pin 9
  • Add triggers and set if TSL2561 above 50 lux then relay switch turn off.
  • Add triggers and set if TSL2561 below 50 lux then relay switch turn on.
  • Add schedule and set time to 5 pm, everyday, turn on relay switch
  • Add schedule and set time to 7 am, everyday, turn off relay switch

Step 5: Job Done !!!

And now you can see and control your ambient light sensor.

It's working...

Comments

author
TomV85 (author)2016-10-06

Nice project .. But you forgot to mention that you have to install an extra NODE extension for the IDE..