Bhoomika S
Published © GPL3+

Automatic Street Light Controller with Alarm using Bolt Iot

Street lights can be automatically controlled based on the sensor value and also alarm clock to wake up in the morning

IntermediateFull instructions provided2 hours148
Automatic Street Light Controller with Alarm using Bolt Iot

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Snappy Ubuntu Core
Snappy Ubuntu Core
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

street_light.py

Python
import conf,json,time
from boltiot import Sms, Bolt

minimum_limit = 0
maximum_limit = 400 


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)


while True: 
    print ("Reading sensor value")
    response = mybolt.analogRead('A0') 
    data = json.loads(response) 
    print("Sensor value is: " + str(data['value']))
    try: 
        sensor_value = int(data['value']) 
        if sensor_value < maximum_limit or sensor_value > minimum_limit:
            print(mybolt.digitalWrite('1','HIGH'))
            print(mybolt.analogWrite('2','0'))
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value))
            print("lights are turned on")
            print("Status of SMS at Twilio is :" + str(response.status))
        else:
            print(mybolt.digitalWrite('1','LOW'))
            print(mybolt.analogWrite('2','100'))
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value))
            print("lights are turned off")
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

conf.py

Python
SID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' 
AUTH_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxx' 
FROM_NUMBER = 'xxxxxxxxxxxx'
TO_NUMBER = '+91 xxxxxxxxxxx'
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxx'
DEVICE_ID = 'xxxxxxxxxxxxxxxx' 

Credits

Bhoomika S

Bhoomika S

1 project • 0 followers

Comments