Raji Chitturi
Published © GPL3+

Automatic Light Controller

An automatic light controller that controls the light intensity according to the surroundings brightness automatically

BeginnerFull instructions provided2 hours29
Automatic Light Controller

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
LED (generic)
LED (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Schematics

schematics diagram

Code

light automation

Python
import conf
from boltiot import Bolt
import json, time 
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
def convert(sensor_value):
	led_intensity= 255-(sensor_value*255/1024)
	return led_intensity
while True: 
    print ("Reading Sensor Value")
    response_ldr = mybolt.analogRead('A0') 
    data = json.loads(response)    
    print("Sensor value is: " + str(data['value'])) 
    try: 
        sensor_value = int(data['value'])
        print("Calculating required Light Intensity for LED")
        led_value_float=convert(sensor_value)  
        led_value= int(led_value_float)           
        print(led_value)
        mybolt.analogWrite('1', led_value)                                                   
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(5)

configuration file

Python
""" BOLT IOT CONFIGURATION """
API_KEY = '1d4cdeee-10bc-4255-82a4-9c2319f533e2'
DEVICE_ID = 'BOLT6097300'

Credits

Raji Chitturi
3 projects • 1 follower

Comments