INHOUDSOPGAWE:

Centro De Comando Emergencias - Erupção De Vulcão E Terremotos: 7 stappe
Centro De Comando Emergencias - Erupção De Vulcão E Terremotos: 7 stappe

Video: Centro De Comando Emergencias - Erupção De Vulcão E Terremotos: 7 stappe

Video: Centro De Comando Emergencias - Erupção De Vulcão E Terremotos: 7 stappe
Video: VULCÕES: PODER E DEVASTAÇÃO - DOCUMENTÁRIO COMPLETO EM HD 2024, November
Anonim
Centro De Comando Emergencias - Erupção De Vulcão E Terremotos
Centro De Comando Emergencias - Erupção De Vulcão E Terremotos

Projeto acadêmico para atender cenário de colaboração através da internet para divulgação de desastres naturais, onde será possível a detecção dos acontecimentos através de sensores IOT de temperatura, luminosidade, oscilação (tilte) e botão de Ainda no cenário de colaboração prevemos integração com o Twitter e aplicativos com suporte mqtt para acionamento do alerta.

U kan ook 'n uiteenlopende posisionering van outomatiese e-posse gee en 'n moontlikheid vir fakenews bied. Dit is baie belangrik om 'n belangrike besluit te neem.

Waarskuwing vir menslike boodskappe kan ook oorweeg word vir SMS, e -pos, sirene en Twitter.

Ons kan die rekords gebruik van AWS insluitend IOT CORE, EC2 en SNS

Sensors van DragonBord 410c

kliënte Android mqtt

Stuur dit om die python te voltooi

Skrywers:

Diego Fernandes dos Santos - [email protected]

Gabriel Piovani Moreira dos Santos - [email protected]

Gustavo Venancio Luz - [email protected]

Paulo Henrique Almeida Santos - [email protected]

Stap 1: Dragonbord 410c - Publicação Dos Sensores - Analogicos

Dragonbord 410c - Publicação Dos Sensores - Analogicos
Dragonbord 410c - Publicação Dos Sensores - Analogicos

Ons kan 'n publieke inskrywing van ons sensore analoog, ons kan die temperatuur van ons eienskappe ook vir ons opspoor en waarneem om 'n variëteit vir ons te maak.

Este alerta começa a contagem regressiva que pode ser suspensa ou acelerada pelo operador.

Ons kan 'n waarskuwing vir 'n tydperk van 60 gebiede, sowel as 'n herhaling van 20 sekondes.

programa rodando dentro da dragon borad 410c

#!/usr/bin/python3import spidev van libsoc import gpio van tyd af slaap

# Importa lib para comunicacao com MOSQUITTO invoer paho.mqtt.client as mqtt

spi = spidev. SpiDev () spi.open (0, 0) spi.max_speed_hz = 10000 spi.mode = 0b00 spi.bits_per_word = 8

#Gebruik 'n porta ADC1 channel_select1 = [0x01, 0x80, 0x00]

#Para usar a porta ADC2 use o seguinte vetor de configuraҧ࣠o channel_select2 = [0x01, 0xA0, 0x00]

def on_connect (mqttc, obj, vlae, rc): print ("rc:" + str (rc))

def on_message (mqttc, obj, msg): print (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))

def on_publish (mqttc, obj, mid): print ("Message ID:" + str (mid) + "\ n") pass

# Kliënte en klante stel die konfigurasies in mqttc = mqtt. Client ()

mqttc.on_message = on_message mqttc.on_connect = on_connect mqttc.on_publish = on_publish

pub = mqtt. Client ("grupo3")

# Met 'n plaaslike gasheer, kan u dit ook toets. broker_address = "34.230.74.201"

pub.connect (makelaaradres)

as _naam _ == '_ hoof_': gpio_cs = gpio. GPIO (18, gpio. DIRECTION_OUTPUT)

met gpio.request_gpios ([gpio_cs]): contador = 0 adc_value_old = 0 adc_value2_old = 0 terwyl contador <50: gpio_cs.set_high () slaap (0.00001) gpio_cs.set_low () rx = spi.xfer (channel_select1_ g)) contador = contador + 1 adc_value = (rx [1] << 8) & 0b1100000000 adc_value = adc_value | (rx [2] & 0xff) adc_value = (((adc_value * 5) / 1024) - 0.5) * 100 druk ("Temperatuur: % f / n" % adc_value) pub.publish ("temperatuura", str (adc_value)) # teste para acionar contador do alarme, teste ultima leitura + 5%

if adc_value_old == 0: adc_value_old = adc_value if adc_value> (adc_value_old*1.05): pub.publish ("ALARME", "ON") print ("Alarmado temperatura") adc_value_old = adc_value sleep (1)

gpio_cs.set_high () slaap (0.00001) gpio_cs.set_low () rx = spi.xfer (channel_select2) gpio_cs.set_high () contador = contador + 1 adc_value2 = (rx [1] << 8) & 0b1100000000 adc_value2 = adc_ (rx [2] & 0xff) adc_value2 = adc_value2 /10 druk ("Luminosidade: % f / n" % adc_value2) pub.publish ("luminosidade", str (adc_value2))

# teste for acionar contador do alarme, teste ultima leitura + 50%

as adc_value2_old == 0: adc_value2_old = adc_value2 if adc_value2> (adc_value2_old*1.5): pub.publish ("ALARME", "ON") print ("Alarmado Luminosidade") adc_value2_old = adc_value2 slaap (3)

Stap 2: Sensores Digitais - Publicação

Sensores Digitais - Publicação
Sensores Digitais - Publicação

código para publicação dos sensores digitais

Ons kan die volgende formele inligting vir ons opspoor, of dit kan 'n soortgelyke weergawe wees van die gebruik van die pânico.

ons kan 'n anomalie opdoen of 'n besmette regressiva inskakel.

programa rodando dentro da dragon borad 410c

vanaf libsoc_zero. GPIO invoer knoppie vanaf libsoc_zero. GPIO invoer Kantel van tyd af slaap slaap invoer paho.mqtt.client as mqtt invoer sys

def on_connect (mqttc, obj, flags, rc): print ("Conectado" + str (rc))

def on_message (mqttc, obj, msg): print (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))

def on_publish (mqttc, obj, mid): # print ("Message ID:" + str (mid) + "\ n") pass

def detectaTilt (): count = 0 sleep_count = 0 while True: try: tilt.wait_for_tilt (1) behalwe: sleep_count += 1 else: count += 1 sleep_count += 1 if sleep_count> 999: break

print ("count:", count) if count> 200: pub = mqttc.publish ("TERREMOTO", "ON") pub = mqttc.publish ("SISMOGRAFO", str (count)) # Criamos of client e setamos suas konfigurasie mqttc = mqtt. Client ()

mqttc.on_message = on_message mqttc.on_connect = on_connect mqttc.on_publish = on_publish

topic = "grupo3"

# Met 'n plaaslike gasheer, kan u dit ook toets. mqttc.connect ("34.230.74.201", 1883)

kantel = kantel ('GPIO-A')

btn = Knoppie ('GPIO-C')

terwyl True: sleep (0.25) detectaTilt () as btn.is_pressed (): pub = mqttc.publish ("PANICO", "ON") print ("Botao ON") sleep (1) pub = mqttc.publish ("PANICO "," OFF ") # else: # pub = mqttc.publish (" PANICO "," OFF ") # print (" Botao OFF ")

Stap 3: Codigo Para Acionamento Sirene

Codigo Para Acionamento Sirene
Codigo Para Acionamento Sirene

Codigo para subscrição para acionamento da SIRENE, programa rodando dentro da dragon board 410c

# Importa lib para comunicacao com MOSQUITTOinvoer paho.mqtt.client as mqtt

vanaf libsoc_zero. GPIO invoer LED van tyd af slaap led = LED ('GPIO-E') #led.off ()

# Definieer o que fazer ao conectar def on_connect (kliënt, obj, vlae, rc): druk ("ConexÃÆ'à £ o estabelecida com broker")

# Definieer die funksie wat ons kan ontvang tydens die definisie van on_message (kliënt, obj, boodskap): druk ("LED" + str (message.payload.decode ("utf-8"))) as str (message.payload.decode ("utf-8")) == "on": print ("Sirene ligada") led.on () else: print ("Sierene apagada") led.off ()

# IP doen makelaar broker_address = "34.230.74.201"

# Cria of cliente sub = mqtt. Client ("grupo3")

subverbinding (makelaaradres)

sub.on_message = on_message sub.on_connect = on_connect

# Verhoog geen sub -sub -intekening nie ("SIRENE", qos = 0)

# Lus vir escuta sub.loop_forever ()

Stap 4: Codigo Twitter - Plaas

Codigo Twitter - Plaas
Codigo Twitter - Plaas
Codigo Twitter - Plaas
Codigo Twitter - Plaas

Código para publicação do twitter assim que acionado o alarme.

'n virtuele weergawe van AWS EC2

#!/usr/bin/env python #---------------------------------------- ------------------------------- # twitter-post-status #-plaas 'n statusboodskap op u tydlyn # --- -------------------------------------------------- ------------------ invoer paho.mqtt. teken in as inteken

invoer tyd

vanaf Twitter invoer *

#------------------------------------------------- ---------------------- # wat moet ons nuwe status wees? #------------------------------------------------- ---------------------- new_status = "#Terremoto Procure uma zona segura-teste"

#------------------------------------------------- ---------------------- # laai ons API-geloofsbriewe # ---------------------- ------------------------------------------------- invoer sys sys.path.append (".") invoeropstelling

#------------------------------------------------- ---------------------- # skep twitter API-voorwerp # ---------------------- ------------------------------------------------- twitter = Twitter (auth = OAuth ('senha removalida'))

#------------------------------------------------- ---------------------- # plaas 'n nuwe status # twitter API-dokumente: https://dev.twitter.com/rest/reference/post/statu… #------------------------------------------------- ----------------------

terwyl 1: m = subscribe.simple ("twitteralarme", hostnaam = "172.31.83.191", behou = onwaar) as m.topic == "twitteralarme" en str (m.payload.decode ("utf-8")) == "aan": resultate = twitter.statuses.update (status = (new_status)+str (time.time ())) # print ("status opgedateer: % s" % new_status)

Stap 5: Centro De Comando

Centro De Comando
Centro De Comando

'n handmatige gebruiksaanwysing of 'n waarskuwingshandleiding vir die gebruik van 'n mens kan ons registreer. U kan die operasie kanselleer of u kan onmiddellik 'n waarskuwing doen.

Vir die gebruik van die bord vir Android vir telefone vir 'n operasionele sentrum.

'n virtuele weergawe van AWS EC2

invoer paho.mqtt.client as pahoimport paho.mqtt.subscribe as subscribe invoer paho.mqtt.publiseer as publiseer import json import time import six import ssl from time import sleep

onderwerpe = ['#']

gatilho = 0 hora_disparo = 0 publish.single ("ACIONADO", "OFF", qos = 1, hostname = "172.31.83.191") publish.single ("sensor1", "OFF", qos = 1, hostname = "172.31.83.191 ") publish.single (" sensor2 "," OFF ", qos = 1, hostname =" 172.31.83.191 ")

connflag = Onwaar

def on_connect (kliënt, gebruikersdata, vlae, rc): global connflag connflag = True print (connflag) print ("Connection return result:" + str (rc))

def on_message (client, userdata, msg): # print ("teste") print (msg.topic+""+str (msg.payload))

def on_log (kliënt, gebruikersdata, vlak, buf): print (msg.topic+""+str (msg.payload))

mqttc = paho. Client ("Broker_MSG") mqttc.on_connect = on_connect mqttc.on_message = on_message

awshost = "data.iot.us-east-1.amazonaws.com" awsport = 8883 clientId = "a2rczvc6ni8105" thingName = "Ufscar2018" caPath = "aws-iot-rootCA.crt" certPath = "9e85dfd42a-certificate.pem. crt "keyPath =" 9e85dfd42a-private.pem.key "mqttc.tls_set (caPath, certfile = certPath, keyfile = keyPath, cert_reqs = ssl. CERT_REQUIRED, tls_version = ssl. PROTOCOL_TLSv1_2, ciphc.sw, keepalive = 60) mqttc.loop_start ()

terwyl 1: hora = time.time () slaap (.1) publish.single ("LEDTERREMOTO", "on", qos = 1, hostname = "172.31.83.191")

# if connflag == True: # mqttc.publish ("message", json.dumps ({'message': "TERREMOTO"}), qos = 1) if gatilho == 1: publish.single ("TEMPO", str (rond (hora_disparo-hora, 0)), qos = 1, hostname = "172.31.83.191") publish.single ("LEDTERREMOTO", "on", qos = 1, hostname = "172.31.83.191") anders: publiseer.single ("TEMPO", "99", qos = 1, hostname = "172.31.83.191") # print ("") if (hora> hora_disparo) en (gatilho == 1): # print ("TERREMOTO") # print (connflag) if connflag == True: # mqttc.publish ("message", json.dumps ({'message': "TERREMOTO"}), qos = 1) # mqttc.publish ("message", "TERREMOTO ", qos = 1) mqttc.publish (" boodskap ", json.dumps (" TERREMOTO - PROCURE UMA ZONA SEGURA "), qos = 1)

# print ("teste SNS") # publish.single ("LED", "on", hostname = "172.31.83.191") publish.single ("SIRENE", "on", qos = 1, hostname = "172.31. 83.191 ") publish.single (" TEMPO "," TERREMOTO ", qos = 1, hostname =" 172.31.83.191 ") publish.single (" ACIONADO "," OFF ", qos = 1, hostname =" 172.31.83.191 ") publish.single ("twitteralarme", "on", qos = 1, hostname = "172.31.83.191") publish.single ("twitter", "TERREMOTO - PROCURE UMA ZONA SEGURA", qos = 1, hostname = "172.31.83.191 ") gatilho = 0 slaap (5) m = subscribe.simple (onderwerpe, gasheernaam =" 172.31.83.191 ", behou = Onwaar) as m.topic ==" ACIONADO "en str (m.payload.decode (" utf-8 ")) ==" OFF ": gatilho = 0 print (" cancelado ") as m.topic ==" medico "en str (m.payload.decode (" utf-8 ")) ==" op ": if connflag == True: mqttc.publish (" medico ", json.dumps (" MEDICOS - EMERGENCIA TERREMOTO "), qos = 1) if m.topic ==" bombeiro "en str (m.payload.decode ("utf -8")) == "on": if connflag == True: mqttc.publish ("bombeiro", json.dumps ("BOMBEIRO - EMERGENCIA TERREMOTO"), qos = 1) if m.topic == " ambulancia "en str (m.payloa d.decode ("utf -8")) == "on": if connflag == True: mqttc.publish ("ambulancia", json.dumps ("AMBULANCIA - EMERGENCIA TERREMOTO"), qos = 1) as m. topic == "urgente" en str (m.payload.decode ("utf-8")) == "on": publish.single ("ACIONADO", 1, qos = 1, hostname = "172.31.83.191") gatilho = 1 hora_disparo = time.time ()+5 if str (m.payload.decode ("utf-8")) == "ON": if gatilho == 1: print ("acelerado 20") hora_disparo = hora_disparo -20 anders: druk ("Acionado") publish.single ("ACIONADO", 1, qos = 1, hostnaam = "172.31.83.191") gatilho = 1 hora_disparo = time.time ()+60

Stap 6: Codigo Twitter - Monitoração

Codigo Twitter - Monitoração
Codigo Twitter - Monitoração

kan u monitor op Twitter, of na 'n regstreekse pos

'n virtuele weergawe van AWS EC2

n

vanaf Twitter invoer *invoer config invoer paho.mqtt.publiseer as publiseer

van tyd af slaap invoer

twitter = Twitter (auth = OAuth (config.access_key, config.access_secret, config.consumer_key, config.consumer_secret))

breedtegraad = -23.546211 lengtegraad = -46.637840 alcance = 50 resultados = 1

publish.single ("twitter_alarme", "ON", hostname = "34.230.74.201")

result_count = 0 last_id = Geen vlag = 0

vir i in bereik (60): #----------------------------------------- ------------------------------ # soek 'n soektog gebaseer op breedtegraad en lengtegraad # twitter API-dokumente: https:// dev. twitter.com/rest/reference/get/search… #------------------------------------- ---------------------------------- probeer: navraag = twitter.search.tweets (q = "#Terremoto", geokode = " %f, %f, %dkm" %(breedtegraad, lengtegraad, alcance), max_id = laaste_id) print ("leu")

behalwe: druk ("erro acesso twitter") breek

vir resultaat in navraag ["status"]:

#------------------------------------------------- ---------------------- # verwerk slegs 'n resultaat as dit 'n geografiese ligging het # ----------------- -------------------------------------------------- ---- if result ["geo"]: result_count += 1 last_id = result ["id"] sleep (1) if result_count == resultados: flag += 1 publish.single ("twitter_alarme", "ON", hostnaam = "34.230.74.201") publish.single ("twitter", "TERREMOTO - DETECTADO", hostname = "34.230.74.201") breek

Stap 7: Estrutura AWS

Estrutura AWS
Estrutura AWS
Estrutura AWS
Estrutura AWS
Estrutura AWS
Estrutura AWS

Gebruik ook virtuele funksies vir die bestuur van AWS EC2

Gebruik en AWS IOT CORE vir MQTT -diens en konfigurasies

Die onderwerpe vir AWS SNS kan ook vir AWS IOT CORE gebruik word

Aanbeveel: