Pallavi DuttaSourabh Tiwari
Published © GPL3+

Magical Night Illuminator

An automated dazzling night light with a magical power to cheer up the mood of your loved ones. Make your own smart room with this project.

BeginnerProtip15 minutes954
Magical Night Illuminator

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Photo resistor
Photo resistor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

Magical Night Illuminator

Circuit Schematic

Code

Magical Night Illuminator

Python
The threshold checking code to switch on the lamp once the room is dark.
import time
from boltiot import Bolt
import json

api_key = "Your_API_key"
d_id = "Your_device_id

automated_room_illumination_threshold = 5 # in lux
client= Bolt(api_key, d_id)

def get_automated_room_illumination(pin):
    """
    Get light intensity.
    """
    response = client.analogRead(pin)
    print response
    data = json.loads(response)
    return int(data['value'])

def control_lamp(pin, value):
    """
    Control the Lamp
    """
    response = client.digitalWrite(pin, value)
    print response

while True:
    temp = get_automated_room_illumination("A0")
    print "Light Intensity is", temp
    if temp < automated_room_illumination_threshold:
        control_lamp('4','HIGH')
    else:
        control_lamp('4', 'LOW')
    time.sleep(5)

Credits

Pallavi Dutta

Pallavi Dutta

3 projects • 3 followers
Sourabh Tiwari

Sourabh Tiwari

2 projects • 25 followers
Software Developer

Comments