Sathya P
Published © GPL3+

Based on Sunlight, Requesting Light Using Bolt IoT

Using Bolt IoT, an LDR will detect light intensity and will send message to your phone when it cross min / max values.

BeginnerShowcase (no instructions)-60 minutes89
Based on Sunlight, Requesting Light Using Bolt IoT

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

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

main_code

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

min_value=15
max_value=1000

mybolt=Bolt(conf.API_key,conf.Device_Id)
sms=Sms(conf.SSID,conf.AUTH_TOKEN,conf.To_number,conf.From.number)

while True:
  print("Reading the 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 < min_value:
      print("Making request to twilio to send sms ","The light intensity is low")
      response=sms.send_sms("Please turn on the light . The current sensor value is"str(sensor_value))
    elif sensor_value > max_value:
      print("Making request to twilio to send sms ","The light intensity is great")
      response=sms.send_sms("you can turn off light . The current sensor value is"str(sensor_value))
  except Exception as e:
    print("Error occured:",e)
  time.sleep(10)

conf_code

Python
SSID='you will find this in your twilio account'
AUTH_TOKEN='you can get this from twilio account'
FROM_number='twilio account'
TO_number='your phone no & dont forget to add +91 before your no'
API_key='your bolt api'
Device_ID='your bolt device id'

Credits

Sathya P

Sathya P

1 project • 0 followers

Comments