Sayani Ghosh
Published

Light Intensity Monitoring System

Checks the light intensity of a place and sends alert with increase or decrease in intensity of the surrounding of a certain level.

IntermediateFull instructions provided2 hours678
Light Intensity Monitoring System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App
SMS Messaging API
Twilio SMS Messaging API
Mailgun
Ubuntu-VMware Workstation

Story

Read more

Schematics

Light Monitoring System

Code

Untitled file

Python
import sendingmail, sendingsms, json,time
from boltiot import Email, Sms, Bolt

minimum_limit=100
maximum_limit=400

mybolt=Bolt(sendingsms.api_key, sendingsms.device_id)
sms=Sms(sendingsms.SID,sendingsms.AUTH_TOKEN,sendingsms.TO_NUMBER, sendingsms.FROM_NUMBER)
mybolt=Bolt(sendingmail.api_key, sendingmail.device_id)
mailer=Email(sendingmail.MAILGUN_API_KEY,sendingmail.SANDBOX_URL,sendingmail.SENDER_EMAIL,sendingmail.RECIPIENT_EMAIL)

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_limt or sensor_value<minimum_limit:
      print("Making request to Twilio to send a SMS")
      print("Making request to Mailgun to send a mail")
      response=sms.send_sms("The current intensity value is:" +str(sensor_value))
      print("Response received fron Twilio is:" +str(response))
      print("Status of SMS at Twilio is:" +str(response.status))
      response=mailer.send_mail("Alert!","The current intensity sensor value is:" +str(sensor_value))
      response_text=json.loads(response.text)
      print("Respone received from MAilgun is:" +str(response_text['message']))
  
  except Exception as e
    print("Error  occured: Below are the details")
    print(e)
  
  time.sleep(5)

Credits

Sayani Ghosh

Sayani Ghosh

1 project • 0 followers

Comments