Last active
February 16, 2019 19:15
-
-
Save mridubhatnagar/292c27841b384a47d13497a9fb690723 to your computer and use it in GitHub Desktop.
Using Python with Raspberry Pi Talk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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