Orodha ya maudhui:
- Hatua ya 1: Dragonbord 410c - Publicação Dos Sensores - Analogicos
- Hatua ya 2: Sensores Digitais - Publicação
- Hatua ya 3: Codigo Para Acionamento Sirene
- Hatua ya 4: Codigo Twitter - Chapisha
- Hatua ya 5: Centro De Comando
- Hatua ya 6: Codigo Twitter - Monitoração
- Hatua ya 7: Estrutura AWS
Video: Centro De Comando Emergencias - Erupção De Vulcão E Terremotos: Hatua 7
2024 Mwandishi: John Day | [email protected]. Mwisho uliobadilishwa: 2024-01-30 12:51
Projeto acadêmico for atender cenário de colaboração através da internet for 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) na botão de pâico. Ainda no cenário de colaboração prevemos integração com on Twitter and aplicativos com suporte mqtt para acionamento do alerta.
Diante a possibilidade de diversos meios de entrada na solução, caberá um centro de de operações avaliar se a informação esta correta evitando assim falsos-positivos dos dispositivos automatizado e avaliar a possibilidade de fakenews. Tal tomada de decisão ni muhimu diante ao pânico ya kwamba wewe ni mtu anayeweza kufanya hivyo.
Como solução de alerta de mensagem estamos kuzingatia ujumbe wako kupitia SMS, onyoza barua pepe, barua pepe, barua pepe na barua pepe.
Ondoa maoni yako kwa sababu ya kujionea kwa AWS ikiwa ni pamoja na IOT CORE, EC2 na SNS
Sensores da DragonBord 410c
wateja android mqtt
Sendo todo desenvolvido em chatu
Autores:
Diego Fernandes dos Santos - [email protected]
Gabriel Piovani Moreira dos Santos - [email protected]
Gustavo Venancio Luz - [email protected]
Paulo Henrique Almeida Santos - [email protected]
Hatua ya 1: Dragonbord 410c - Publicação Dos Sensores - Analogicos
Huduma hizi zinatokana na matangazo ya umma, ambayo inaweza kutumika kwa sababu ya kusanidi mipango ya kufanya uchunguzi wa hali ya juu ikiwa utafanyika kwa sababu ya kufanya mpango wa kuanzisha programu ya kutafakari kufanya protocolo mqtt sinalizando um evento.
Este alerta come a contagem regressiva que pode ser suspensa ou acelerada pelo operador.
Ondoa yako kwa njia ya utaftaji wa rejeleo kati ya sehemu 60, na kwa hivyo utafahamisha kugundua utaftaji wa habari kati ya sehemu 20.
programa rodando dentro da dragon borad 410c
#! / usr / bin / python3import spidev kutoka libsoc kuagiza gpio kutoka wakati wa kuagiza usingizi
# Ingiza kwa para comunicacao com MBUU kuagiza kuagiza paho.mqtt.client kama mqtt
spi = spidev. SpiDev () spi.open (0, 0) spi.max_speed_hz = 10000 spi.mode = 0b00 spi.bits_per_word = 8
#Usando porta ADC1 channel_select1 = [0x01, 0x80, 0x00]
#Para tumia porta ADC2 tumia o seguinte vetor de configura''§ÃÆ' £ o channel_select2 = [0x01, 0xA0, 0x00]
def on_connect (mqttc, obj, bendera, rc): chapisha ("rc:" + str (rc))
def on_message (mqttc, obj, msg): print (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))
def on_publish (mqttc, obj, mid): chapa ("Kitambulisho cha Ujumbe:" + str (katikati) + "\ n") pitisha
# Criamos o mteja na setamos suas configuracoes mqttc = mqtt. Mteja ()
mqttc.on_message = on_message
pub = mqtt. Mteja ("grupo3")
# Conexao com localhost, uma vez que testamos fora do labredes. broker_adress = "34.230.74.201"
kiunganishi. kiunganishi (broker_adress)
ikiwa _ jina _ == '_ kuu_': gpio_cs = gpio. GPIO (18, gpio. DIRECTION_OUTPUT)
na gpio. 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 print ("Temperatura:% f / n"% adc_value) pub. chapisha ("temperatura", str (adc_value)) # teste kwa acionar contador do alarme, test ultima leitura + 5%
ikiwa adc_value_old == 0: adc_value_old = adc_value ikiwa adc_value> (adc_value_old * 1.05): pub.chapisha ("ALARME", "ON") chapisha ("Alarmado temperatura") adc_value_old = adc_value usingizi (1)
gpio_cs.set_high () usingizi (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_value2 | (rx [2] & 0xff) adc_value2 = adc_value2 / 10 chapa ("Luminosidade:% f / n"% adc_value2) pub. chapisha ("luminosidade", str (adc_value2))
# jaribio la acionar contador do alarme, teste ultima leitura + 50%
ikiwa adc_value2_old == 0: adc_value2_old = adc_value2 ikiwa adc_value2> (adc_value2_old * 1.5): pub. chapisha ("ALARME", "ON") chapisha ("Alarmado Luminosidade") adc_value2_old = adc_value2 (3)
Hatua ya 2: Sensores Digitais - Publicação
código para publicação dos sensores digitais
Huduma zote za kidato cha nne zinatokana na njia hii ya kugundua utetemekaji na utaftaji wa simular au uso wa uso wa mtu.
quando detectado uma anomalia ou botão de pânico pressionado a contagem regressiva é iniciada.
programa rodando dentro da dragon borad 410c
kutoka libsoc_zero. GPIO kuagiza Button kutoka libsoc_zero. GPIO kuagiza Tilt kutoka wakati kuagiza kuagiza kulala paho.mqtt.client kama mqtt kuagiza sys
def on_connect (mqttc, obj, bendera, rc): chapisha ("Conectado" + str (rc))
def on_message (mqttc, obj, msg): print (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))
def on_publish (mqttc, obj, mid): # chapa ("Kitambulisho cha Ujumbe:" + str (katikati) + "\ n") pitisha
def detectaTilt (): hesabu = 0 sleep_count = 0 wakati Kweli: jaribu: tilt.wait_for_tilt (1) isipokuwa: sleep_count + = 1 mwingine: hesabu + = 1 sleep_count + = 1 ikiwa sleep_count> 999: break
chapa ("hesabu:", hesabu) ikiwa hesabu> 200: pub = mqttc.chapisha ("TERREMOTO", "ON") pub = mqttc.chapisha ("SISMOGRAFO", str (hesabu)) # Criamos o mteja e setamos suas configuracoes mqttc = mqtt. Mteja ()
mqttc.on_message = on_message
mada = "grupo3"
# Conexao com localhost, uma vez que testamos fora do labredes. mqttc.connect ("34.230.74.201", 1883)
tilt = Tilt ('GPIO-A')
btn = Kifungo ('GPIO-C')
wakati Kweli: lala (0.25) detectaTilt () ikiwa btn.is_press (): pub = mqttc.chapisha ("PANICO", "ON") chapa ("Botao ON") lala (1) pub = mqttc.chapisha ("PANICO "," OFF ") # mwingine: # pub = mqttc.chapisha (" PANICO "," OFF ") # chapa (" Botao OFF ")
Hatua ya 3: Codigo Para Acionamento Sirene
Codigo para subscrição para acionamento da SIRENE, programme rodando dentro ya joka bodi 410c
# Importa lib para comunicacao com MOSquITTOportport paho.mqtt.client as mqtt
kutoka libsoc_zero. GPIO kuagiza LED kutoka wakati kuagiza kulala led = LED ('GPIO-E') # led.off ()
# Fafanua o que fazer ao conectar def on_connect (mteja, obj, bendera, rc): chapisha ("ConexÃÆ'Â £ o estabelecida com broker")
# Fafanua o que fazer ao receiver uma mensagem def on_message (mteja, obj, ujumbe): chapisha ("LED" + str (message.payload.decode ("utf-8"))) ikiwa str (message.payload.decode ("utf-8")) == "kwenye": chapa ("Sirene ligada") led.on () mwingine: chapa ("Sierene apagada") led.off ()
# IP fanya broker broker_adress = "34.230.74.201"
# Cria o cliente ndogo = mqtt. Client ("grupo3")
sub.connect (broker_adress)
sub.on_message = on_message sub.on_connect = kwenye_connect
# Ongeza hakuna topico sub.subscribe ("SIRENE", qos = 0)
# Kitanzi para escuta sub.loop_forever ()
Hatua ya 4: Codigo Twitter - Chapisha
Código para publicação do twitter assim que acionado o alarme.
código rodando na maquina virtual ya AWS EC2
#! / usr / bin / env chatu # ---------------------------------------- ------------------------------ -------------------------------------------------- ------------------ kuagiza paho.mqtt.jisajili ili ujiandikishe
muda wa kuagiza
kutoka kwa kuagiza kwa twitter *
# ------------------------------------------------- ---------------------- # hadhi yetu mpya inapaswa kuwa nini? # ------------------------------------------------- ---------------------- new_status = "#Terremoto Pata uma zona segura - teste"
# ------------------------------------------------- ---------------------- # pakia hati zetu za API # ---------------------- --------------------------------------------------- kuagiza sys sys.path.append (".") kuagiza usanidi
# ------------------------------------------------- ---------------------- # tengeneza kitu cha API ya twitter # ---------------------- ------------------------------------------------- twitter = Twitter (auth = OAuth ('senha removida))
# ------------------------------------------------- ---------------------- # chapisha hali mpya # hati za twitter za Twitter: https://dev.twitter.com/rest/reference/post/statu… # ------------------------------------------------- ----------------------
wakati 1: m = subscribe.simple ("twitteralarme", hostname = "172.31.83.191", iliyohifadhiwa = Uongo) ikiwa m.topic == "twitteralarme" na str (m.payload.decode ("utf-8")) == "on": results = twitter.statuses.update (status = (new_status) + str (time.time ())) # print ("hali iliyosasishwa:% s"% new_status)
Hatua ya 5: Centro De Comando
semper que acionado um dispositivo manual ou detectado um alerta manual do usuário é acionada uma contagem regressiva para envio de mensagem. O operador pode cancelar o envio ou acionar o envio imediato do alerta.
Para uso do dasboard utilizamos um android do telefone for compor a mesa de operação do centro de comando.
código rodando na maquina virtual ya AWS EC2
kuagiza paho.mqtt.client kama pahoimport paho.mqtt.jisajili ili uandikishe kuagiza paho.mqtt.chapisha kama kuchapisha kuagiza json kuagiza muda kuagiza kuagiza sita ssl kutoka wakati wa kuagiza kulala
mada = ['#']
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 ") chapisha. Single (" sensor2 "," OFF ", qos = 1, hostname =" 172.31.83.191 ")
connflag = Uongo
def on_connect (mteja, userdata, bendera, rc): global connflag connflag = True print (connflag) print ("Uunganisho ulirudisha matokeo:" + str (rc))
def on_message (mteja, userdata, msg): # print ("teste") print (msg.topic + "" + str (msg.payload))
def on_log (mteja, data ya watumiaji, kiwango, buf): chapisha (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 mtejaId = "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, ciphers = Hakuna) mqttc., kuweka = 60) mqttc.loop_start ()
wakati 1: hora = time.time () kulala (.1) kuchapisha. single ("LEDTERREMOTO", "on", qos = 1, hostname = "172.31.83.191")
# if connflag == True: # mqttc.publish ("message", json.dumps ({'message': "TERREMOTO"}), qos = 1) ikiwa gatilho == 1: publish.single ("TEMPO", str (round (hora_disparo-hora, 0)), qos = 1, hostname = "172.31.83.191") publish.single ("LEDTERREMOTO", "on", qos = 1, hostname = "172.31.83.191") mwingine: chapisha.single ("TEMPO", "99", qos = 1, hostname = "172.31.83.191") # chapa ("") ikiwa (hora> hora_disparo) na (gatilho == 1): # chapa ("TERREMOTO") # chapa (connflag) ikiwa connflag == Kweli: # mqttc.publish ("message", json.dumps ({'message': "TERREMOTO"}), qos = 1) # mqttc.chapisha ("message", "TERREMOTO ", qos = 1) mqttc.publish (" message ", json.dumps (" TERREMOTO - UTARATIBU UMA ZONA SEGURA "), qos = 1)
# chapa ("teste SNS") # publish.single ("LED", "on", hostname = "172.31.83.191") publish.single ("SIRENE", "on", qos = 1, hostname = "172.31. 83.191 ") chapisha. Single (" TEMPO "," TERREMOTO ", qos = 1, hostname =" 172.31.83.191 ") publish.single (" ACIONADO "," OFF ", qos = 1, hostname =" 172.31.83.191 " uchapishaji.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 kulala (5) m = jiandikishe. Rahisi (mada, jina la mwenyeji =" 172.31.83.191 ", iliyohifadhiwa = Uongo) ikiwa m.topic ==" ACIONADO "na str (m.payload.decode (" utf-8 ")) ==" ZIMA ": gatilho = 0 print (" cancelado ") ikiwa m.topic ==" medico "na str (m.payload.decode (" utf-8 ")) ==" imewashwa ": ikiwa connflag == Kweli: mqttc.publish (" medico ", json.dumps (" MEDICOS - EMERGENCIA TERREMOTO "), qos = 1) ikiwa m.topic ==" bombeiro "na str (m.payload.decode ("utf-8")) == "kwenye": ikiwa connflag == Kweli: mqttc.publish ("bombeiro", json.dumps ("BOMBEIRO - EMERGENCIA TERREMOTO"), qos = 1) ikiwa m.topic == " ambulancia "na str (m.payloa d.decode ("utf-8")) == "kwenye": ikiwa ni connflag == Kweli: mqttc.publish ("ambulancia", json.dumps ("AMBULANCIA - EMERGENCIA TERREMOTO"), qos = 1) ikiwa m. mada == "haraka" na 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 ikiwa str (m.payload.decode ("utf-8")) == "ON": ikiwa gatilho == 1: chapa ("acelerado 20") hora_disparo = hora_disparo -20 kingine: chapa ("Acionado") chapisha. Single ("ACIONADO", 1, qos = 1, hostname = "172.31.83.191") gatilho = 1 hora_disparo = time.time () + 60
Hatua ya 6: Codigo Twitter - Monitoração
código monitoração do twitter, barua pepe ya posta na regiao de sorocaba
código rodando na maquina virtual ya AWS EC2
n
kutoka kwa uingizaji wa twitter * kuagiza kuagiza kuagiza paho.mqtt.chapisha kama kuchapisha
kutoka wakati kuagiza kuagiza
twitter = Twitter (auth = OAuth (config.access_key, config.access_secret, config.consumer_key, config.consumer_secret))
latitudo = -23.546211 longitudo = -46.637840 alcance = 50 matokeoados = 1
chapisha.single ("twitter_alarme", "ON", jina la mwenyeji = "34.230.74.201")
result_count = 0 last_id = Hakuna bendera = 0
kwa mimi katika anuwai (60): # ------------------------------------------ ---------------------- twitter.com/rest/reference/get/search …… # ------------------------------------- ---------------------------------- jaribu: swala = twitter.search.tweets (q = "#Terremoto", geocode = "% f,% f,% dkm"% (latitudo, longitudo, alcance), max_id = mwisho_id) chapisha ("leu")
isipokuwa: kuchapisha ("erro acesso twitter") kuvunja
kwa matokeo ya swala ["hadhi"]:
# ------------------------------------------------- ---------------------- # husindika tu matokeo ikiwa ina geolocation # ----------------- -------------------------------------------------- ---- ikiwa matokeo ["geo"]: result_count + = 1 last_id = matokeo ["id"] kulala (1) ikiwa result_count == resultados: bendera + = 1 publish.single ("twitter_alarme", "ON", jina la mwenyeji = "34.230.74.201") publish.single ("twitter", "TERREMOTO - DETECTADO", jina la mwenyeji = "34.230.74.201") mapumziko
Hatua ya 7: Estrutura AWS
Utilizamos uma maquina virtual rodando ubuntu na estrutura AWS EC2
Utilizamos ni AWS IOT CORE kwa huduma ya MQTT juu ya usanidi kama utaftaji wa huduma kwa wanaume
Mada ya kufanya ni AWS SNS kwa njia ya AWS IOT CORE
Ilipendekeza:
Mfumo wa Tahadhari ya Kuegesha Magari ya Arduino - Hatua kwa Hatua: 4 Hatua
Mfumo wa Tahadhari ya Kuegesha Magari ya Arduino | Hatua kwa Hatua: Katika mradi huu, nitatengeneza Mzunguko rahisi wa Sura ya Maegesho ya Arduino kwa kutumia Arduino UNO na Sense ya Ultrasonic ya HC-SR04. Mfumo wa tahadhari ya Gari ya Arduino ya msingi inaweza kutumika kwa Urambazaji wa Kujitegemea, Kuanzia Robot na anuwai zingine
Hatua kwa hatua Ujenzi wa PC: Hatua 9
Hatua kwa hatua Jengo la PC: Ugavi: Vifaa: MotherboardCPU & Baridi ya CPU
Comando Por Voz - DragonBoard410c: 5 Hatua
Comando Por Voz - DragonBoard410c: Este guia ir á kuanzisha programu ya kusanidi programu Julius Julius com com Coruja, que s ã o heshima ya programu ya utaftaji wa hesabu za njia na uwakili;
Ufuatiliaji wa Acoustic Na Arduino Uno Hatua kwa Hatua (hatua 8): Hatua 8
Ufuatiliaji wa Acoustic Na Arduino Uno Hatua kwa hatua (hatua-8): transducers za sauti za ultrasonic L298N Dc umeme wa umeme wa adapta na pini ya kiume ya dc Arduino UNOBreadboard Jinsi hii inavyofanya kazi: Kwanza, unapakia nambari kwa Arduino Uno (ni mdhibiti mdogo aliye na dijiti na bandari za analog kubadilisha msimbo (C ++)
Centro De Cómputo Para Niños Con Raspberry Pi: Hatua 7
Centro De Cómputo Para Niños Con Raspberry Pi: Estos ser á n los primeros pasos de la Raspberry Pi na para ello necesitaremos: Raspberry Pi 2 Adaptador ya red a micro USB Tarjeta micro SD (de 8 gb) Cable HDMI Cargador Rat ó n Teclado para computadoraEn caso de contar con Un Kit de inicio