ANUJITH BEERAKAYALA
Published © LGPL

Do I Need an Umbrella Today?

With the help of a Bolt IoT module, we can find out if we have to carry an umbrella with us at the click of a button.

BeginnerFull instructions provided30 minutes1,321

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Resistor 330 ohm
Resistor 330 ohm
×1
2 Pin Push Button
×1
Jumper wires (generic)
Jumper wires (generic)
×6
Mini Breadboard
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Digital Ocean
PuTTY

Story

Read more

Schematics

Circuit Diagram

Sorry for the messy diagram :) I was facing some technical isssues.

Code

Code Required for This project

Python
You must enter your Bolt API Key, Bolt Device Name and darksky API URL.
API_KEY = ""              #insert your unique API KEY
DEVICE_ID = "BOLTXXXXXXX" # and Bolt Device ID

from boltiot import Bolt
import json,requests

mybolt = Bolt(API_KEY, DEVICE_ID)

def check_weather(): #function to check today's forecast
    URL = "https://api.darksky.net/forecast/[Your API KEY]/17.432837,78.362292?exclude=minutely,hourly,daily,flags,alert?units=auto"
    response = requests.request("GET",URL)
    result = json.loads(response.text) #returns an object
    current = result["currently"] #accessing the current forecast
    weather = current["icon"] #icon tells us if it is going to rain today
    return weather

def led(): #function to switch on the LED
    mybolt.digitalWrite(1,"HIGH")
    time.sleep(3) #the led is on for 3 seconds
    mybolt.digitalWrite(1,"LOW") #switching off the led

def buzzer(): #function to switch on the buzzer
    mybolt.digitalWrite(3,"HIGH")
    time.sleep(2) # the buzzer is on for 2 seconds
    mybolt.digitalWrite(3,"LOW") # switching off the buzzer

while True:
  response = mybolt.digitalRead(0) #checks if the button is pushed
  data = json.loads(response) #returns an object

  if data["success"] != 1:
     print("ERROR")

  if int(data["value"]) == 1: #if the button is pushed
      check = check_weather() #checking today's forecast
      print(check)
      if check == "rain": #if it is going to rain
        buzzer() #call buzzer function
        print("Take your Umbrella")
      else: #if it is not going to rain
        led() #call the LED function
        print("Do not take your Umbrella")
  

Credits

ANUJITH BEERAKAYALA

ANUJITH BEERAKAYALA

1 project • 0 followers

Comments