Mundarija:
- 1 -qadam: Dragonbord 410c - Publicação Dos Sensores - Analogicos
- 2 -qadam: Sensor Digitais - Publicação
- 3 -qadam: Codigo Para Acionamento Sirene
- 4 -qadam: Codigo Twitter - Xabar
- 5 -qadam: Centro De Comando
- 6 -qadam: Twitter -ni kuzatib boring
- 7 -qadam: Estrutura AWS
Video: Centro De Comando paydo bo'lishi - 7 qadam
2024 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2024-01-30 13:25
Ilova harorati, yorug'lik darajasi, oscilaco (yuqori darajali), Internet -tarmoqlar, Internet -saytlar va tarmoqlar uchun javob beradi. Aloqa hech qanday imkoniyatga ega emas.
Bu erda siz turli xil operatsiyalarni amalga oshirishingiz mumkin, bu sizning ma'lumotlaringizni avtomatlashtirishga yordam beradi. Aniqlanishicha, bu juda muhim voqea.
SMS -xabarlar, mijozlar uchun elektron pochta xabarlari, twitter va elektron pochta xabarlarini yuborish kerak.
AWS va IOT CORE, EC2 va SNS -ni o'z ichiga olgan holda, biz o'z loyihamizni o'rnatamiz.
DragonBord 410c sensorlari
Android mqtt mijozlari
Python -ni ishlating
Avtomobillar:
Diego Fernandes dos Santos - [email protected]
Gabriel Piovani Moreira dos Santos - [email protected]
Gustavo Venansio Luz - [email protected]
Paulo Anrike Almeyda Santos - [email protected]
1 -qadam: Dragonbord 410c - Publicação Dos Sensores - Analogicos
Ommaviy axborot vositalari, sensorlar, sensorlar, temperatura va luminosidadlar, agar ular aniqlansa, aniqlanadi, chunki siz har qanday protokolni o'rnatishingiz mumkin.
Qachonki, bu operatsion tizimni o'chirib qo'yish mumkin bo'lsa, u holda siz regressiya qilishingiz mumkin.
Bu 60 ta regressiv registratsiya, keyin esa 20 ta o'yinni o'chirib qo'yish.
Dragon borad 410c uchun rodando dentro dasturi
#!/usr/bin/python3import spidev libsoc import gpio import uyqu vaqtidan.
# MOSQUITTO paho.mqtt.client -ni mqtt sifatida import qilish
spi = spidev. SpiDev () spi.open (0, 0) spi.max_speed_hz = 10000 spi.mode = 0b00 spi.bits_per_word = 8
#ADC1 portini ishlating channel_select1 = [0x01, 0x80, 0x00]
#ADC2 portidan foydalanish kanal_select2 konfiguratsiyasidan foydalanadi = [0x01, 0xA0, 0x00]
def on_connect (mqttc, obj, bayroqlar, rc): chop etish ("rc:" + str (rc))
def on_message (mqttc, obj, msg): chop etish (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))
def on_publish (mqttc, obj, mid): chop etish ("Xabar identifikatori:" + str (o'rtada) + "\ n") o'tish
# Criamos yoki mijozlar sozlamalari mqttc = mqtt. Client ()
mqttc.on_message = on_message mqttc.on_connect = on_connect mqttc.on_publish = on_publish
pub = mqtt. Client ("guruho3")
# Conexao com localhost, bu erda test sinovlari o'tkaziladi. broker_adress = "34.230.74.201"
pub.connect (broker_adress)
agar _ nomi _ == '_ asosiy _' bo'lsa: gpio_cs = gpio. GPIO (18, gpio. DIRECTION_OUTPUT)
gpio.request_gpios ([gpio_cs]) bilan: contador = 0 adc_value_old = 0 adc_value2_old = 0, contador <50: gpio_cs.set_high () uxlash (0.00001) gpio_cs.set_low () rx = spi.xfer (channel_selcs._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 chop etish ("Temperatura: % f / n" % adc_value) pub.publish ("temperatura", str (adc_value)) # teste para acionar contador do alarme, teste ultima leitura + 5%
agar adc_value_old == 0: adc_value_old = adc_value agar adc_value> (adc_value_old*1.05): pub.publish ("ALARME", "ON") chop etish ("Alarmado temperatura") adc_value_old = adc_value uyqu (1)
gpio_cs.set_high () uyqu (0.00001) gpio_cs.set_low () rx = spi.xfer (channel_select2) gpio_cs.set_high () contador = contador + 1 adc_value2 = (rx [1] << 8) va 0b1100000000 adc_value2 = adc_value2 | (rx [2] & 0xff) adc_value2 = adc_value2 /10 chop etish ("Luminosidade: % f / n" % adc_value2) pub.publish ("luminosidade", str (adc_value2))
# test sinovlari + 50%
agar adc_value2_old == 0: adc_value2_old = adc_value2 agar adc_value2> (adc_value2_old*1.5): pub.publish ("ALARME", "ON") chop etish ("Alarmado Luminosidade") adc_value2_old = adc_value2 uyqu (3)
2 -qadam: Sensor Digitais - Publicação
código para publicação dos sensores raqamlar
Sensorli signallar aniqlansa, tremorlar ham, simular ham, pankino ham aniqlanadi.
anomaliya yoki kasallik aniqlansa, bu regressiya va inisiada sodir bo'ladi.
Dragon borad 410c uchun rodando dentro dasturi
libsoc_zero. GPIO import tugmachasidan libsoc_zero. GPIO import Vaqtdan import uyqu import paho.mqtt.client mqtt import tizim sifatida
def on_connect (mqttc, obj, bayroqlar, rc): chop etish ("Conectado" + str (rc))
def on_message (mqttc, obj, msg): chop etish (msg.topic + "" + str (msg.qos) + "" + str (msg.payload))
def on_publish (mqttc, obj, mid): # print ("Xabar identifikatori:" + str (o'rtada) + "\ n") o'tish
def detectaTilt (): count = 0 sleep_count = 0 True bo'lsa: harakat qilib ko'ring: tilt.wait_for_tilt (1) tashqari: sleep_count += 1 boshqa: 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 yoki mijozni sozlash configuracoes mqttc = mqtt. Client ()
mqttc.on_message = on_message mqttc.on_connect = on_connect mqttc.on_publish = on_publish
mavzu = "guruho3"
# Conexao com localhost, bu erda test sinovlari o'tkaziladi. mqttc.connect ("34.230.74.201", 1883)
qiyalik = burilish ('GPIO-A')
btn = Tugma ('GPIO-C')
while True: uxlash (0.25) detectaTilt () if btn.is_pressed (): pub = mqttc.publish ("PANICO", "ON") chop etish ("Botao ON") uyqu (1) pub = mqttc.publish ("PANICO) "," OFF ") # boshqa: # pub = mqttc.publish (" PANICO "," OFF ") # print (" Botao OFF ")
3 -qadam: Codigo Para Acionamento Sirene
SIRENE uchun dasturiy ta'minot, ajdaho taxtasi 410c uchun dasturiy ta'minot.
# MOSQUITTOimport paho.mqtt.client -ni mqtt sifatida import qilish
libsoc_zero. GPIO import LED vaqtdan import uyqu LED = LED ('GPIO-E') #led.off ()
# On_connect (mijoz, obj, bayroqlar, rc) ni aniqlang: chop eting ("Conex £ £ tashkil etuvchi broker")
# Belgilang u_message (mijoz, obj, xabar): mijoz (obuna, xabar): chop eting ("LED" + str (message.payload.decode ("utf-8"))) if str (message.payload.decode ("utf-8"))) == "on": print ("Sirene ligada") led.on () else: print ("Sierene apagada") led.off ()
# IP broker broker_adress = "34.230.74.201"
# Mijoz sub = mqtt. Client ("guruho3")
sub.connect (broker_adress)
sub.on_message = on_message sub.on_connect = on_connect
# Sub.subscribe mavzusini ko'paytirmang ("SIRENE", qos = 0)
# Loop para escuta sub.loop_forever ()
4 -qadam: Codigo Twitter - Xabar
Ommaviy axborot vositalari uchun twitter -ni oching.
AWS EC2 -da virtual mashinalar yordamida
#!/usr/bin/env python #---------------------------------------- ------------------------------ # twitter-post-status #-vaqt jadvalingizga status xabarini yuboradi # --- -------------------------------------------------- ------------------ import paho.mqtt.subuna sifatida obuna bo'ling
import vaqti
twitter importidan *
#------------------------------------------------- ---------------------- # bizning yangi maqomimiz qanday bo'lishi kerak? #------------------------------------------------- ---------------------- new_status = "#Terremoto Procure uma zona segura-teste"
#------------------------------------------------- ---------------------- # API hisob ma'lumotlarini yuklang # ---------------------- ------------------------------------------------- Import sys sys.path.append (".") import konfiguratsiyasi
#------------------------------------------------- ---------------------- # twitter API obyektini yaratish # ---------------------- ------------------------------------------------ twitter = Twitter (auth = OAuth ("senha removida"))
#------------------------------------------------- ---------------------- # yangi status yozish # twitter API docs: https://dev.twitter.com/rest/reference/post/statu… #------------------------------------------------- ----------------------
while 1: m = subscribe.simple ("twitteralarme", hostname = "172.31.83.191", ret = False), agar m.topic == "twitteralarme" va str (m.payload.decode ("utf-8")) == "yoqilgan": natijalar = twitter.statuses.update (status = (new_status)+str (time.time ())) # chop etish ("yangilangan holat: % s" % new_status)
5 -qadam: Centro De Comando
har bir foydalanuvchi uchun qo'llanma yoki aniqlansa, bu sizning qo'lingizdan kelganini aniqlashga yordam beradi. Operator pode kanselar u envio ou acionar yoki envio imediato alerta.
Ma'lumotlar panelini Android -da, telefonda ham, markazda ham, kompyuterda ham ishlatish mumkin.
AWS EC2 -da virtual mashinalar yordamida
paho.mqtt.client ni pahoimport sifatida paho.mqtt.subolang
mavzular = ['#']
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 = noto'g'ri
def on_connect (mijoz, foydalanuvchi ma'lumotlari, bayroqlar, rc): global connflag connflag = Haqiqiy chop etish (connflag) chop etish ("Aloqani qaytarish natijasi:" + str (rc))
def on_message (mijoz, foydalanuvchi ma'lumotlari, msg): # print ("teste") print (msg.topic+""+str (msg.payload))
def on_log (mijoz, foydalanuvchi ma'lumotlari, daraja, buf): chop etish (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_TLSvcnn, ctq), keepalive = 60) mqttc.loop_start ()
while 1: hora = time.time () sleep (.1) publish.single ("LEDTERREMOTO", "on", qos = 1, hostname = "172.31.83.191")
# if connflag == To'g'ri: # mqttc.publish ("xabar", json.dumps ({'xabar': "TERREMOTO"}), qos = 1) agar 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") boshqa: chop etish.single ("TEMPO", "99", qos = 1, hostname = "172.31.83.191") # print ("") if (hora> hora_disparo) va (gatilho == 1): # print ("TERREMOTO") # print (connflag) if connflag == True: # mqttc.publish ("xabar", json.dumps ({'xabar': "TERREMOTO"}), qos = 1) # mqttc.publish ("xabar", "TERREMOTO") ", qos = 1) mqttc.publish (" xabar ", json.dumps (" TERREMOTO - UMA ZONA SEGURA SARBOTI "), qos = 1)
# print ("test 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 ")) publs.single ("twitteralarme", "on", qos = 1, hostname = "172.31.83.191") nashr qilish..83.191 ") gatilho = 0 uyqu (5) m = yozilish utf-8 ")) ==" OFF ": gatilho = 0 chop etish (" bekor qilish "), agar m.topic ==" medico "va str (m.payload.decode (" utf-8 ")) ==" yoqilgan bo'lsa ": agar connflag == To'g'ri: mqttc.publish (" medico ", json.dumps (" MEDICOS - EMERGENCIA TERREMOTO "), qos = 1) if m.topic ==" bombeiro "va str (m.payload.decode ("utf -8"))) == "on": if connflag == True: mqttc.publish ("bombeiro", json.dumps ("BOMBEIRO - EMERGENCIA TERREMOTO"), qos = 1) if m.topic == " tez tibbiy yordam "va str (m.payloa d.decode ("utf -8")) == "on": if connflag == True: mqttc.publish ("tez tibbiy yordam", json.dumps ("AMBULANSIA - EMERGENCIA TERREMOTO"), qos = 1) if m. mavzu == "favqulodda" va str (m.payload.decode ("utf-8")) == "yoqilgan": publish.single ("ACIONADO", 1, qos = 1, xost nomi = "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 boshqa: print ("Acionado") publish.single ("ACIONADO", 1, qos = 1, hostname = "172.31.83.191") gatilho = 1 hora_disparo = time.time ()+60
6 -qadam: Twitter -ni kuzatib boring
twitter -dagi kuzatuvlar va xabarlarni ro'yxatdan o'tkazish
AWS EC2 -da virtual mashinalar yordamida
n
twitter importidan *import konfiguratsiyasini import qilish paho.mqtt.publish sifatida nashr eting
vaqtdan boshlab uyqu
twitter = Twitter (auth = OAuth (config.access_key, config.access_secret, config.consumer_key, config.consumer_secret))
kenglik = -23.546211 uzunlik = -46.637840 alcance = 50 natijaados = 1
publish.single ("twitter_alarme", "ON", hostname = "34.230.74.201")
result_count = 0 last_id = Yo'q bayroq = 0
i uchun (60): #----------------------------------------- ------------------------------ # kenglik va uzunlik bo'yicha qidiruvni amalga oshiring # twitter API docs: https:// dev. twitter.com/rest/reference/get/search… #------------------------------------- ---------------------------------- harakat qilib ko'ring: so'rov = twitter.search.tweets (q = "#Terremoto"), geokod = " %f, %f, %dkm" %(kenglik, uzunlik, alkans), max_id = oxirgi_id) chop etish ("leu")
bundan tashqari: chop etish ("erro acesso twitter") tanaffus
so'rov natijasi uchun ["statuslar"]:
#------------------------------------------------- ---------------------- # natijani faqat geolokatsiya bo'lsa ishlov beradi # ----------------- -------------------------------------------------- ---- agar natija ["geo"]: result_count += 1 last_id = result ["id"] sleep (1) if result_count == resultados: flag += 1 publish.single ("twitter_alarme", "ON", hostname = "34.230.74.201") publish.single ("twitter", "TERREMOTO - DETECTADO", hostname = "34.230.74.201") tanaffus
7 -qadam: Estrutura AWS
AWS EC2 -ni ishlatish uchun virtual qurilmalarni ishlating
AWS IOT CORE -dan foydalanish MQTT -ni sozlash va sozlash uchun ishlatiladi.
AWS SNS va AWS IOT CORE -ning asosiy mavzulari.
Tavsiya:
AVTOMATIK CHIQARLARNI BO'LISHI VA BIN BO'LISHI. Sayyorani qutqarish uchun: 19 qadam (rasmlar bilan)
AVTOMATIK CHIQARLARNI BO'LISHI VA BIN BO'LISHI. Sayyorani qutqarish uchun: Ishni boshlashdan oldin, uni o'qishdan oldin birinchi videoni ko'rishni tavsiya qilaman, chunki bu juda foydali. Salom, mening ismim Yoqub va men Buyuk Britaniyada yashayman. Qayta ishlash - bu men yashaydigan katta muammo, men dalalarda ko'p axlatni ko'raman va bu zararli bo'lishi mumkin. Th
Sichqonchani "Ishga tushirish" tugmachasida harakatlantirganda paydo bo'ladigan matnni qanday o'zgartirish mumkin: 4 qadam
Sichqonchani "Ishga tushirish" tugmachasini bosganingizda paydo bo'ladigan matnni qanday o'zgartirish mumkin: Sarlavha hammasini o'z ichiga oladi
Bog'langan qo'lning paydo bo'lishi: 5 qadam (rasmlar bilan)
Bog'langan qo'lning paydo bo'lishi: tez emas, lekin iflos! Bu erda siz asta-sekin intro, statik-robot-ekstremalni qanday payvandlash va qattiq yog'ochdan oddiy stendni qanday rejalashtirishni olasiz. Agar xohlasangiz, zavqlaning va uni qayta yarating
Windows Live Messenger ishga tushganda paydo bo'lishini qanday to'xtatish kerak: 6 qadam
Windows Live messenjerining ishga tushishidan qanday to'xtash kerak: Men yaqinda Windows Live Messenger -ning ishga tushishidan bezovta bo'ldim, chunki har safar noutbukga kirganimda kirishni xohlamayman … Shunday qilib, men Men bu harakatni qanday o'chirish/yoqish yo'lini topdim va men uni ko'rsatma bilan bo'lishishni o'yladim
Farzandingizni tug'ilgan kunida qanday qilib peri paydo bo'lishi mumkin !: 4 qadam
Farzandingizni tug'ilgan kunida qanday qilib peri paydo bo'lishi mumkin ?: Mening yaqinda 8 yoshga to'lgan qizim ertak mavzusida tug'ilgan kunni xohlardi, shuning uchun men uni o'zgacha bayram qilishga qaror qildim. Men juda oddiy effekt yaratdim, bu esa ziyofatning barcha ishtirokchilarini haqiqiy perilar aynan ular uchun paydo bo'ldi deb o'ylashga majbur qildi