Created
June 11, 2019 03:24
-
-
Save drisanateixeira/acb3a0d940967bc4e64e2934247ff2c9 to your computer and use it in GitHub Desktop.
Fase 3
This file contains 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 urllib3 | |
import RPi.GPIO as gpio | |
import Adafruit_DHT as dht | |
import time as t | |
gpio.setmode(gpio.BOARD) | |
gpio.setup(32, gpio.OUT) | |
chave = 'TTN9Y84915G60MJY' | |
url ='https://api.thingspeak.com/update?api_key={}&field1={}&field2={}' | |
while True: | |
# Raspberry Pi e Sensor de Temperatura e Umidade DHT11 | |
umid, temp = dht.read_retry(dht.DHT11, 4) # CONECATDO NA PORTA 4 | |
urllib3.PoolManager().request('GET', url.format(chave, temp, umid)) | |
if temp > 31 or umid > 70: | |
gpio.output(32, 1) #Liga Rele | |
else: | |
gpio.output(32, 0) #Desliga Rele | |
#t.sleep(5) # Pausa de 5 segundos | |
print('Temperatura: {0:0.1f} Umidade: {1:0.1f}'.format(temp, umid)) # Imprimir a temperatura e umidade | |
t.sleep(5) # Pausa de 5 segundos | |
Muito obrigada Douglas! Era só um projeto simples mesmo, mas obrigada pela
dica.
Em sex, 14 de jun de 2019 às 18:54, Douglas J.A.M <notifications@github.com>
escreveu:
… remova a chave do script publico, caso contrario outros poderao utiliza-la
e atrapalhar seu DB, no seu caso n e critico, mas fica a dica para projetos
futuros
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/acb3a0d940967bc4e64e2934247ff2c9?email_source=notifications&email_token=ALRMNQQWUA52AJ2HEEBFGETP2QHRLA5CNFSM4HYNMGN2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFTWNA#gistcomment-2944208>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALRMNQXJKNG7ZVBI3YVPHO3P2QHRLANCNFSM4HYNMGNQ>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
remova a chave do script publico, caso contrario outros poderao utiliza-la e atrapalhar seu DB, no seu caso n e critico, mas fica a dica para projetos futuros