Skip to content

Instantly share code, notes, and snippets.

@mridubhatnagar
Last active February 16, 2019 19:15
Show Gist options
  • Save mridubhatnagar/292c27841b384a47d13497a9fb690723 to your computer and use it in GitHub Desktop.
Save mridubhatnagar/292c27841b384a47d13497a9fb690723 to your computer and use it in GitHub Desktop.
Using Python with Raspberry Pi Talk
import requests
import jso
from gpiozero import LED
API_KEY = ''
count = 0
threshold = 15
response = requests.get('http://api.openweathermap.org/data/2.5/weather?q=delhi&APPID=%s' % API_KEY)
print(response.status_code)
print(response.text)
response = json.loads(response.text)
print("*********************************")
print('weather data %s' % response['weather'])
for data in response['weather']:
print(data['main'])
red_led = LED(4)
blue_led = LED(7)
while count < 5:
if temp < threshold:
red_led.on()
time.sleep(1)
red_led.off()
else:
blue_led.on()
time.sleep(1)
blue_led.off()
count +=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment