Cov txheej txheem:

Ntse Chaw Haujlwm Ruaj Ntseg: 4 Kauj Ruam
Ntse Chaw Haujlwm Ruaj Ntseg: 4 Kauj Ruam

Video: Ntse Chaw Haujlwm Ruaj Ntseg: 4 Kauj Ruam

Video: Ntse Chaw Haujlwm Ruaj Ntseg: 4 Kauj Ruam
Video: Zoo Siab Nrog Koj - Paj Tsua Thoj [ Official MV ] Nkauj Tawm Tshiab 2022 2024, Kaum ib hlis
Anonim
Ntse Chaw Haujlwm Ruaj Ntseg
Ntse Chaw Haujlwm Ruaj Ntseg

Hauv txoj haujlwm no, peb lub hom phiaj kawm paub yuav siv AWS thiab MQTT rau hauv peb li kev teeb tsa IoT li cas.

Nrog kev hem thawj ntawm kev tawm tsam sab hauv, daim ntawv thov no tsom mus rau saib xyuas lub chaw haujlwm ntawm cov neeg siv muaj cai. Thaum tus neeg siv nyob deb ntawm chaw ua haujlwm, daim ntawv thov no yuav tshuaj xyuas lub chaw haujlwm.

  • Nws taug qab ob qhov kub thiab txias qhov tseem ceeb thiab tso tawm nws ntawm daim ntawv thov web
  • Nws tso cai rau cov neeg siv qhib thiab tua LED
  • 2 hom tswb hom

    • Tswb Tswb - Thaum lub tswb qhib, kev ntsuas qhov ntsuas kub thiab av noo yuav nres, thaum lub suab ntsuas yuav qhib. Yog tias muaj kev txav chaw hauv chaw ua haujlwm, lub suab nrov yuav nrov thiab yuav yees duab thiab cov neeg siv tuaj yeem pom dab tsi tau kuaj pom thaum lawv nyob deb ntawm lawv lub chaw haujlwm
    • Tswb Tawm - Thaum lub tswb raug kaw, yuav muaj kev tshuaj xyuas qhov kub thiab txias thiab qhov txiaj ntsig yuav tshwm rau ntawm lub vev xaib thov thaum lub suab txav thiab lub koob yees duab yuav raug xiam
    • Hauv ob qho tib si, cov neeg siv tseem tuaj yeem tswj lub teeb ci LED.
  • Kev siv AWS DynamoDB, peb muaj peev xwm khaws cov duab kab kom cov neeg siv tuaj yeem pom cov duab coj
  • Tsis tas li, siv AWS, peb muaj peev xwm xa email rau cov neeg siv thaum muaj cov lus pom thaum lub sijhawm lawv nyob thaum lawv tsis nyob ntawm lawv lub chaw haujlwm.

Tam sim no, cia nrhiav seb peb tswj hwm los siv cov txheej txheem zoo li cas!

Kauj Ruam 1: Kauj Ruam 1: Teeb Kho Vajtse

Kauj ruam 1: Teeb Kho Vajtse
Kauj ruam 1: Teeb Kho Vajtse
Kauj ruam 1: Teeb Kho Vajtse
Kauj ruam 1: Teeb Kho Vajtse

Koj xav tau dab tsi:

  1. 2x Raspberry Pi 3
  2. 2 x T-Cobbler Kit
  3. 1 x Breadboard
  4. Assorted Jumper Cables
  5. Ntau yam Resistors
  6. 1 x LED
  7. 1x DHT11 Kub thiab Vaum Sensors
  8. 1 x PIR Motion Sensor
  9. 1 x Buzzer

Peb teeb tsa muaj LED txuas nrog GPIO 18 kom tus neeg siv tuaj yeem tswj lub teeb pom kev zoo hauv lawv lub chaw haujlwm. Txog kev sau cia ntawm qhov kub thiab txias, peb yuav siv DHT sensor txuas nrog GPIO4. Ua raws los ntawm peb PIR Tsab Ntawv Pom Zoo Sensor txuas nrog GPIO 26 txhawm rau txheeb xyuas cov neeg nkag mus hauv chav haujlwm thaum tus neeg siv tsis nyob. Thaum kawg, lub tswb nrov kom nrov lub tswb thaum lub tswb qhib thiab pom qee yam.

Kauj Ruam 2: Kauj Ruam 2: Txhim Kho thiab Ua Ntej Ua Ntej Ua Ntej

AWS

Thawj zaug nkag mus rau

1. Tom qab nkag mus, nyem rau ntawm phau ntawv teev npe ntawm sab laug pane thiab tom qab ntawd nyem rau ntawm AWS Kawm Qhia Pib Nyiaj Txiag 75

2. Luam qhov Access Key ID thiab Secret Access Key rau kev teeb tsa hauv raspberry pi tom qab.

3. Nyem rau ntawm Open Console

Sau npe rau koj raspberry pi ua ib yam

1. Search AWS IOT

2. Nyem rau ntawm Manage ntawm sab laug pane thiab tom qab ntawd nyem rau Yam

3. Nyem tsim ntawm kaum sab xis

4. Select Sau npe ib qho AWS IOT yam

5. Txhua koj lub npe thiab nyem tom ntej

6. Nyem tsim daim ntawv pov thawj thiab txuag 4 yam khoom tsim tawm

7. Activate lub hauv paus CA

8. Tsim txoj cai thiab muab nws tso rau hauv koj li khoom

-Muab nws lub npe -Action: iot.* -Resource ARN:* -Check qhov tso cai Dynamodb

Ua ntej txhua yam, khiav aws teeb tsa Siv Tus ID nkag mus thiab tus yuam sij nkag tau yooj yim los ntawm ua ntej

Tom ntej no, 1. Tsim cov ntaub ntawv npe iot-role-trust.json nrog cov hauv qab no

iot-role-trust.json

2. Khiav cov lus txib hauv qab no: aws iam create-role --role-name my-iot-role --assume-role-policy-document file: //iot-role-trust.json

3. Tsim cov ntaub ntawv npe iot-policy.json nrog cov hauv qab no

iot-policy.jason

4. Run the command: aws iam put-role-policy --role-name my-iot-role --policy-name iot-policy --policy-document file: //iot-policy.json

DynamoDB

1. Create ntxhuav hauv Dynamodb rau cov lus tsa suab sensor thiab kub/av noo -For cov lus tsa suab teeb thawj qhov tseem ceeb rau sensor -For kub thiab av noo siv timestamp ua tus yuam sij tseem ceeb

2. Kev tsim txoj cai rau kev nrhiav kom pom

Tus cwj pwm:* lub ntsiab lus lim: ntsuas/txav

3. Action: xaiv cov lus sib faib rau ntau kab ntawm cov database

Lambda

1. Tsim cov haujlwm Lambda nrog cov ntsiab lus hauv qab no

Lambda muaj nuj nqi

2. Tsim txoj cai rau lambda

-Txoj cai:*

-topic lim: sensors/tag nrho

3. Kev xaiv xaiv ua rau Lambda ua haujlwm dhau cov lus

4. Lambda yuav ua tus so rau koj

SNS

1. Tsim lub ncauj lus SNS

2. Nkag mus rau lub ncauj lus thiab tso saib lub npe

3. Kho cov ntsiab lus txoj cai kom tso cai rau txhua tus tshaj tawm thiab sau npe ua cov ncauj lus

4. Sau npe yuav cov ncauj lus nrog email

5. Rov qab mus rau txoj cai tshawb nrhiav qhov txav

6. Ntxiv lwm qhov kev txiav txim rau txoj cai no hu ua amessage raws li SNS thawb ceeb toom

7. SNS lub hom phiaj yuav yog lub ntsiab lus uas koj tau tsim cov ntawv xov xwm RAW

S3

1. Mus rau S3 thiab tsim lub thoob rau upload cov duab

Yam tseem ceeb rau nruab rau ntawm Pis

Flask - sudo pip install flask

Boto - sudo pip nruab boto

Boto3 - sudo pip nruab boto3

AWSIoTPythonSDK - sudo pip nruab AWSIoTPythonSDK

awscli - sudo pip nruab awscli

paho - sudo pip nruab paho

mqtt - sudo pip nruab mqtt

Kauj Ruam 3: Kauj Ruam 3: Chaw Ua Haujlwm Ruaj Ntseg - Sau

Hauv tus neeg siv pi, peb muaj 1 tsab ntawv

client.py - Tsab ntawv no yuav sau npe mus rau ntau yam ncauj lus xws li lub ntsuas/ntsuas kub thiab lub ntsuas cua/av noo kom tau txais qhov ntsuas kub thiab av noo uas yuav tshwm rau ntawm daim ntawv thov web. Nws kuj tseem xa cov xwm txheej ntawm LED kom cov xwm txheej LED tuaj yeem hloov pauv ntawm sab server

neeg.py

Hauv server pi, peb muaj 1 tsab ntawv

server.py - Tsab ntawv no yuav sau npe rau lub teeb pom kev zoo lub npe kom lub teeb LED tuaj yeem qhib thiab tua tau. Nyob rau tib lub sijhawm, nws yuav tau txais qhov ntsuas kub thiab av noo los ntawm daim ntawv qhia zaub mov thiab tshaj tawm nws mus rau lub ncauj lus hu ua sensors/tag nrho thiab hauv lambda ua haujlwm qhov txiaj ntsig yuav raug tshaj tawm rau 2 lub ncauj lus sib txawv, ntsuas/ntsuas kub thiab ntsuas/ntsuas av noo

neeg rau zaub mov.py

Kauj Ruam 4: Kauj Ruam 4: Kev Kawm Paub

Kauj Ruam 4: Kev Kawm Paub
Kauj Ruam 4: Kev Kawm Paub

Hauv txoj haujlwm no, peb tau ntsib ntau yam kev cov nyom vim tias tus qauv no tseem tshiab rau peb. Txawm li cas los xij, los ntawm txoj haujlwm no, peb tau kawm ntau yam. Ua nws yog IOT ntawm AWS, peb txaus siab hais tias peb paub yuav ua li cas koom ua ke AWS rau hauv peb cov khoom siv IoT tseem ceeb thiab ua rau nws muaj ntau qhov ua ntej.

Pom zoo: