Mundarija:

Aqlli uyni ishga tushirish - Projeto Final: 6 qadam
Aqlli uyni ishga tushirish - Projeto Final: 6 qadam

Video: Aqlli uyni ishga tushirish - Projeto Final: 6 qadam

Video: Aqlli uyni ishga tushirish - Projeto Final: 6 qadam
Video: Dugonalarim shokda 😂🤯 2024, Noyabr
Anonim
Aqlli uyni ishga tushirish - Projeto Final
Aqlli uyni ishga tushirish - Projeto Final

Aqlli uyning IoT dasturining yakuniy loyihasi taqdim etiladi

Aqlli uyning so'nggi versiyasini taqdim etadigan bo'lsak, u aqlli uyni, DrangonBoard + Linker -ni ulash uchun sensorli signallarni o'rnatadi, shuningdek, ular bir -biridan farq qilmaydi. AWS -da bulutli ma'lumotlarni saqlash "ma'lumot" ni saqlang. Bir vaqtning o'zida DragonBoard va IoT-ni o'rnatish, avtomatlashtirishning avtomatlashtirilgan tizimlari, sensorli sensorlar, sensorli qurilmalar, o'yin-uskunalar va asbob-uskunalar uchun shart-sharoitlar mavjud. -yaqin masofadan turib sensorlar o'rnatilishi mumkin, bu esa hech qanday ma'lumotni o'z ichiga olmaydi.

1 -qadam: Materias Naterários

Materias Naterários
Materias Naterários
Materias Naterários
Materias Naterários
  1. DragonBoard -ni joylashtiring.
  2. 96Boards Linker Mezzanine
  3. Sensor de Luminozidade (LDR) - bu bog'lovchi uyali aloqa operatori.
  4. Sensor - bu bog'lovchi uyali aloqa operatori.
  5. Bog'lanish uchun tarmoqqa tegib turing.
  6. Aloqa tarmoqlari bilan bog'laning, bu konditsionerlar yoki tizimlar uchun mo'ljallangan.
  7. LED ulanuvchi tarmoqqa ulangan, bu esa bir vaqtning o'zida bir nechta ma'lumotlarni o'z ichiga oladi.
  8. Bibliotecas citadas no passo 5 ni o'rnatish.

2 -qadam: Sensor, Atuadores E Conexões

Sensor, Atuadores va Conexões
Sensor, Atuadores va Conexões
Sensor, Atuadores va Conexões
Sensor, Atuadores va Conexões

1. Mezzanin bog'lovchi:

Ajdaho taxtasi va Mezzanine -ni o'rnatish kerak. Tafsilotlar, maslahatchi havolasi

2. Sensor luminosidad (LDR)

Sensorli komponentlar, shuningdek, ADC1 -ga ulangan Kit -Link -ni o'rnatish uchun mo'ljallangan. O'qish texnikasi:

3. Temperatura sensori

ADC2 -ga ulanish uchun siz Kit -Link -ni o'rnatishingiz mumkin. O'qish texnikasi:

4. Botão Touch

Sensorli komponentlar D1 bilan bog'laning. Bu sizning kompyuteringiz yoki tizimingiz bilan bog'liq. Yo'q, bir paytlar mahalliy. Bosh sahifa técnicosni ochadi: https://linksprite.com/wiki/index.php5? Title = Touch_ …

5. Rele

Kit Dvigatel bilan bog'laning, bu tarmoqqa ulanish uchun D2 bilan bog'laning. A/C. tizimidagi ma'lumotlarni o'chirib qo'yish kerak:

6. LED

U D4 bilan bog'laning, bu tarmoqqa ulanish uchun mo'ljallangan. Bu tizimning tashqi ko'rinishi va tashqi ko'rinishi, tashqi va tashqi ko'rinishdagi LED yoritgichlari. Agar siz qarshilik ko'rsatadigan bo'lsak, u 10 soniyagacha mavjud bo'lib, u tizimni o'chirib tashlaydi, bu sizning tajribangiz va tajribangizga mos keladi. Texnikani tozalash:

7. Sensor de contato magnético

Kit -Linker Mezzanine -ning asosiy qismi - bu sensorlar. Bu erda hech qanday ma'lumot yo'q, lekin bu hech qanday ma'lumotga ega emas. Ochish sensori 2 bosqichdan oshib ketadi (fotosurat qadam bosiladi), yoki u "sensor" ga mos keladi, bu sensori yoki sensori. Sensor noutbukni loyihalashtirishga imkon bermaydi (normal holat). Sensor yoki sensor haqida hisobot. Sensor yoki sensorli hisobotlar, bu sizning hisob -kitoblaringiz uchun.

3 -qadam: Remoto protokoli

Nazorat qilish uchun nazorat ilovasi
Nazorat qilish uchun nazorat ilovasi

Ionic Framework, https://ionicframework.com/ saytidan foydalanish mumkin. Yuklab olish va o'rnatishning oxirgi bosqichi zarur.

AWS (AWS IoT- https://aws.amazon.com/iot/) bulutli bulutli havola orqali, shuningdek, ajdaho taxtasi va uning holatini aniqlash uchun ham ishlaydi..

- Iluminação tizimlari va saytlari, shuningdek, saytlar va tizimlar. Aniq ma'lumotlarga ko'ra, u avtomatik ravishda sozlanishi mumkin. Ma'lumki, bu juda aniq.

- Konditsioner tizimning konditsioner tizimiga kirishi mumkin. Ma'lumki, temperatura har doim aniq. Havo harorati o'zgarganda, A/C yoki boshqa turdagi havo harorati har doim yaxshi bo'ladi. Misol uchun, har qanday harorat 23 -chi kunni hisobga olgan holda. Ichki makon 24 soat ichida, konditsioner va konditsionerlar bilan chegaralanib, harorat 20 darajaga ko'tariladi. Depois o ciclo se repetirá.

- Garajlar haqida ma'lumot, bu esa o'z navbatida.

- Ichki makonda harorat va harorat harorati.

- Luminosidade yoki luminosidade ma'lumotlari.

AWS va bulutli ilovalar bilan bir vaqtda, siz ularni uy yoki uydan ajratib olishingiz mumkin.

4 -qadam: Criando Uma "coisa" Na AWS IoT

Kriando Uma
Kriando Uma

AWS -da IoT -ni o'rnatish va o'rnatish jarayoni quyidagicha amalga oshiriladi:

1) AWS IoT -ga havola qilinmagan holda:

2) Clique "bir narsa yaratish" va "bitta narsani yaratish". Keyingisini loyihalashtirish kerak.

3) "Guvohnomasiz biror narsa yarating" deb nomlanadi. Ixtiyoriy sertifikatlar bilan bog'liq holda, hech qanday qo'llanma yo'q.

4) Nimani o'ylab ko'rsam, "coisa" ja estará criada. "Taqdimot" so'zi hech qachon o'chirib tashlanmagan. Bu muammoning echimini topa olmasligingiz uchun, biz har qanday muammoni hal qila olamiz. Python -da hech qanday ma'lumot yo'q, lekin bu hech qanday yordam bermaydi. AWS Cloud -da "soya" ni tanlashingiz mumkin, bu esa dragonboard -ni yangilashga imkon beradi.

5 -qadam: Python dasturi

Bibliotecas serão needárias dasturini bajarish uchun:

import spidevimport vaqt import jurnali import json import argparse

libsoc import gpio dan

vaqtni import qilish vaqtidan boshlab, gpio_96boards -dan datetime -ni GPIO -ni AWSIoTPythonSDK. MQTTLib -dan AWSIoTMQTTClient -ni AWSIoTPythonSDK. MQTTLib -dan import qilish.

Dasturni to'ldiring:

import spidevimport vaqt import jurnali import json import argparse

libsoc import gpio dan

vaqtni import qilish vaqtidan boshlab, vaqtini gpio_96boards -dan GPIO -ni AWSIoTPythonSDK. MQTTLib -dan AWSIoTMQTTClient -dan AWSIoTPythonSDK. MQTTLib -dan AWSIoTMQTTShadowClient -dan import qilish.

GPIO_CS = GPIO.gpio_id ('GPIO_CS') #Analog port

TUGMA = GPIO.gpio_id ('GPIO_A') RELE = GPIO.gpio_id ('GPIO_C') LED = GPIO.gpio_id ('GPIO_G')

pinlar = ((GPIO_CS, "tashqariga"), (TUGMA, "ichkariga"), (RELE, "tashqariga"), (LED, "tashqariga"),)

def setdevices (deltaMessagePython):

System_Status = deltaMessagePython ['SystemStatus'] Rele_Status = deltaMessagePython ['AC'] Led_Status = deltaMessagePython ['SisIlumi']

##### AC

agar Rele_Status == 1: gpio.digital_write (RELE, GPIO. HIGH)

agar Rele_Status == 0 bo'lsa:

gpio.digital_write (RELE, GPIO. LOW)

##### Iluminakao tizimi

agar Led_Status == 1: gpio.digital_write (LED, GPIO. HIGH), agar Led_Status == 0: gpio.digital_write (LED, GPIO. LOW)

def readadc (gpio):

gpio.digital_write (GPIO_CS, GPIO. HIGH)

time.sleep (0.0002) gpio.digital_write (GPIO_CS, GPIO. LOW) r = spi.xfer2 ([0x01, 0xA0, 0x00])#ADC2 - gpio.digital_write harorati (GPIO_CS, GPIO. HIGH) adcout = (r [1)] << 8) & 0b1100000000 adcout = adcout | (r [2] & 0xff) adc_temp = (adcout *5.0/1023-0.5) *100

gpio.digital_write (GPIO_CS, GPIO. HIGH)

time.sleep (0.0002) gpio.digital_write (GPIO_CS, GPIO. LOW) r = spi.xfer2 ([0x01, 0x80, 0x00])#ADC1 - Yorqinligi gpio.digital_write (GPIO_CS, GPIO. HIGH) adcoutldr = (r [1] << 8) & 0b1100000000 adcoutldr = adcoutldr | (r [2] & 0xff) adcoutldr = str (adcoutldr) now = datetime.utcnow () now_str = now.strftime ('%Y-%m-%dT%H:%M:%SZ') temperatura = "{:.2f} ". Format (adc_temp) payload_temp = '{" holati ": {" kerakli ": {" Luminosidade ":' + adcoutldr + '," Temperatura ":' + temperatura + '}}}' myMQTTClient.publish ("$ aws/things/DBpyAWS1116/shadow/update", payload_temp, 0) qaytish r

Def desliga ():

gpio.digital_write (RELE, GPIO. LOW) gpio.digital_write (LED, GPIO. LOW)

def run (gpio):

system_status = 1

rost bo'lsa:

time.sleep (2) button_value = gpio.digital_read (BUTTON) print ("----") time.sleep (0.25) if button_value == 1: if system_status == 0: system_status = 1 other: system_status = 0 desliga () agar system_status == 1: value = readadc (gpio) "SYSTEM_STATUS %d" %system_status time.sleep (3)

sinf shadowCallbackContainer:

def _init _ (self, deviceShadowInstance): self.deviceShadowInstance = deviceShadowInstance

# Maxsus Shadow qayta qo'ng'iroq

def customShadowCallback_Delta (o'z -o'zidan, yuk, javobStatus, token): chop etish ("Delta xabari olindi:") ### yukni yangilash skript payloadDict = json.loads (yuk) deltaMessage = json.dumps (payloadDict ["davlat"]) chop etish "DELTA MESSAGE %s" %deltaMessage ### Hisobot holatini yangilash so'rovi newPayload = '{"state": {"report":' + deltaMessage + '}}' deltaMessagePython = json.loads (deltaMessage) setdevices (deltaMessagePython)

spi = spidev. SpiDev ()

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

####### Narsaning ta'rifi

# AWS IoT sertifikatiga asoslangan ulanish

myMQTTClient = AWSIoTMQTTClient ("DBpyAWS1116") myMQTTClient.configureEndpoint ("a28rqf8gnpw7g.iot.us-west-2.amazonaws.com", 8883) myMQTTClient.configureCredentials/"-CA/Credentials/"-, "/home/linaro/shared/AWS/" SUA CHAVE "-private.pem.key", "/home/linaro/shared/AWS/" SEU CERTIFICADO "-certificate.pem.crt") myMQTTClient.configureOfflinePublishQueueing (- 1) # Cheksiz oflayn nashrlar navbatdagi navbatda turishi myMQTTClient.configureDrainingFrequency (2) # Drenaj: 2 Hz myMQTTClient.configureConnectDisconnectTimeout (10) # 10 sek myMQTTClient.configureMQTTOperationTimeout (5) # 5 sonliMenQabul qiling "Qabul qiling. coisajsb "," ulangan ", 0)

########################

####### Soya ta'rifi

# AWSIoTMQTTShadowClient -ni ishga tushiring

myAWSIoTMQTTShadowClient = Hech myAWSIoTMQTTShadowClient = AWSIoTMQTTShadowClient ("DBpyAWS1116") myAWSIoTMQTTShadowClient.configureEndpoint ("Seu END-POINT.us-west-2.amazonaws.com", 8883) myAWSIoTMQTTShadowClient.configureCredentials ("/ home / linaro / o'rtoqlashdi / AWS / root- CA.crt ","/home/linaro/shared/AWS/"SUA CHAVE"-private.pem.key ","/home/linaro/shared/AWS/"SEU CERTIFICADO-certificate.pem.crt")

# AWSIoTMQTTShadowClient configurationmyAWSIoTMQTTShadowClient.configureAutoReconnectBackoffTime (1, 32, 20) myAWSIoTMQTTShadowClient.configureConnectDisconnectTimeout (10)

# AWS IoT -ga ulanish

myAWSIoTMQTTShadowClient.connect ()

# Doimiy obuna bo'lgan qurilma soyasini yarating

deviceShadowHandler = myAWSIoTMQTTShadowClient.createShadowHandlerWithName ("DBpyAWS1116", To'g'ri) shadowCallbackContainer_Bot = shadowCallbackContainer (deviceShadowHandler)

# Deltalarni tinglang

qurilmaShadowHandler.shadowRegisterDeltaCallback (shadowCallbackContainer_Bot.customShadowCallback_Delta)

#########################

myMQTTClient.publish ("$ aws/things/DBpyAWS1116/shadow/update", '{"holati": {"kerakli": {"SystemStatus": 1, "SisIlumi": 0, "AC": 0, "Garagem"): "Fechada", "Temperatura": 25, "Luminosidade": 123}}} ', 0)

agar _ ism_ == "_main_" bo'lsa:

GPIO (pin) bilan gpio sifatida: ishga tushirish (gpio)

6 -qadam: Yakuniy bosqich

Yakunlash
Yakunlash

Icon, usando yoki comando Ionic xizmat ko'rsatadigan dasturlarni ishga tushirish uchun hech qanday ruxsat berilmagan bo'lsa, tizimni ishga tushiring.

Mumkin bo'lgan muammolarni bartaraf etish, MWTT mijozini AWS-ni tekshirish AWS-da, AWS Cloud-da, shuningdek, drayverlar panelida ham tekshirilishi mumkin: https://us-west-2.console.aws.amazon.com/iotv2/hom…

Tavsiya: