denvir gama
Published © GPL3+

Automated Street Light

An Automated Street Light, That turns on when it starts getting dark and turns itself off when there's plenty of Sunlight

AdvancedFull instructions provided2 hours338
Automated Street Light

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
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

schematic

Code

automated street light

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

minimum_value = 200
flag=0

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 < minimum_value:
            if flag is 0:
                print("Making request to Twilio to send a SMS")
                response = sms.send_sms("Turning on street lights")
                mybolt.digitalWrite('0','HIGH')
                print("Response received from Twilio is: " + str(response))
                print("Status of SMS at Twilio is :" + str(response.status))
                flag=1
        else:
            mybolt.digitalWrite('0','LOW')
            flag=0
    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(900)

conf file

Python
SID = 'You can find SID in your Twilio Dashboard' 
AUTH_TOKEN = 'You can find  on your Twilio Dashboard' 
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device' 

Credits

denvir gama

denvir gama

1 project • 0 followers

Comments