Cov txheej txheem:

Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812): 5 Cov Kauj Ruam
Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812): 5 Cov Kauj Ruam

Video: Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812): 5 Cov Kauj Ruam

Video: Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812): 5 Cov Kauj Ruam
Video: Tswv Yexus lub neej thaum pib txug thaum xaus 2024, Kaum ib hlis
Anonim
Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812)
Pom IoTea LoRa Tshuaj (nrog Azure, Hloov Kho 1812)

Microsoft Azure yog kev pabcuam huab uas muab lub zog muaj zog thiab ruaj khov dua. Lub sijhawm no peb tau sim xa peb cov ntaub ntawv IoTea rau nws.

Kauj Ruam 1: Yam Khoom Siv Hauv Txoj Haujlwm no

Cov khoom siv kho vajtse

  • Grove - Cov pa roj carbon dioxide (MH -Z16)
  • Grove - Digital Lub Teeb Sensor
  • Grove - Plua Plav Sensor (PPD42NS)
  • Grove-Pa Pa Sensor (ME2-O2-Ф20)
  • Av noo & Kub Sensor
  • LoRa LoRaWAN Gateway - 868MHz Cov Khoom Siv nrog Raspberry Pi 3
  • Grove - Temp & Humi & Barometer Sensor (BME280)

Software apps thiab cov kev pabcuam online

  • Microsoft Visual Studio 2015
  • Microsoft Azure

Kauj ruam 2: Zaj dab neeg

Ntawm Mengding Roob sab qaum teb sab hnub tuaj ntawm Ya'an, Sichuan, lub roob toj siab khiav sab hnub poob mus rau sab hnub tuaj hauv hiav txwv ntsuab. Qhov no yog qhov pom tshaj plaws rau Deng uas muaj hnub nyoog 36 xyoos, yog ib tus neeg ua haujlwm Mengding tshuaj yej tsawg heev ntawm nws tiam, nrog rau kev cog 50mu (= 3.3 hectares) nyob ntawm 1100m saum hiav txwv. Deng los ntawm tsev neeg ua cov tshuaj yej, tab sis nqa hauv tsev neeg cov keeb kwm tsis yog ib txoj haujlwm yooj yim. "Peb cov tshuaj yej tau loj hlob ntawm qhov siab nyob hauv ib puag ncig cov organic kom ntseeg tau tias nws muaj txiaj ntsig zoo. Tab sis nyob rau tib lub sijhawm, kev loj hlob ntom ntom yog qis, tus nqi siab thiab tawg paj tsis sib xws, ua tshuaj yej nyuaj rau sau. Tias yog vim li cas cov tshuaj yej saum toj roob hauv pes feem ntau yog sau me me thiab lawv qhov txiaj ntsig tsis tau xav txog ntawm kev ua lag luam. "Tau ob xyoos dhau los, Deng tau sim ua kom cov neeg siv khoom paub txog cov tshuaj yej toj siab los txhawb lawv tus nqi. Thiab thaum nws ntsib Fan, uas tab tom nrhiav kev cog ntoo los siv Seeed's IoTea thev naus laus zis, kev sib tw zoo tshaj plaws rau kev daws teeb meem tau ua.

Kauj Ruam 3: Kev Kho Vajtse Txuas

Thov ua raws Tutorial Yav dhau los txhawm rau txuas koj lub cuab yeej.

Kauj ruam 4: Huab Configure

Kauj Ruam 1. Tsim Pab Pawg

Nyem rau qhov no txhawm rau nkag mus rau Microsoft Azure. Thiab tom qab ntawd, nkag mus rau Pab Pawg Pabcuam hauv cov npe ntawm sab laug ntawm lub dashboard, nyem Ntxiv rau ntxiv Pawg Pab Pawg.

Duab
Duab

Pawg Pab Pawg tau siv los tswj hwm tag nrho cov peev txheej hauv txoj haujlwm, tom qab siv cov peev txheej huab, tshem tawm pab pawg pab pawg kom tshem tawm tag nrho cov peev txheej kom tsis txhob raug nqi. Hauv nplooj ntawv qhib, sau Cov Pab Pawg Npe lub npe (xws li iotea), xaiv Kev Sau Npe thiab Pab Pawg Pab Pawg qhov chaw yog xav tau, nyem Tsim los tsim Pawg Pab Pawg.

Kauj Ruam 2. Tsim Iot Hub

Tam sim no koj tuaj yeem tsim cov peev txheej huab, nyem Tsim qhov rov ua dua ntawm sab laug, xaiv Internet ntawm Yam - Iot Hub, nws yuav qhib nplooj ntawv tshiab.

Hauv Bas tab, xaiv Pawg Pabcuam uas koj nyuam qhuav tsim, thiab sau Iot Hub Lub Npe (xws li iotea), xaiv Kev Sau Npe thiab Cheeb Tsam yog xav tau, thiab tom qab ntawd tig mus rau Loj thiab scle tab.

Duab
Duab

Hauv Qhov Loj thiab ntsuas tab, xaiv F1: Qib dawb lossis B1: Qib theem pib hauv Tus Nqi thiab ntsuas qib sib xyaw, Qib Qib yuav siv 10.00 USD hauv ib hlis. Thaum kawg, tig mus Txheeb Xyuas + tsim tab txheeb xyuas koj cov tswv yim thiab nyem Tsim los tsim Iot Hub.

Duab
Duab

Kauj Ruam 3. Kho LORIOT

Nkag mus rau Iot Hub koj nyuam qhuav tsim, nyem Sib koom kev cai - ntaus ntawv, luam thawj qhov tseem ceeb hauv nplooj ntawv ntawm sab xis.

Duab
Duab

Qhib lub qhov rai tshiab tshiab (lossis tab), nkag mus rau koj LORIOT Tswj Vaj Huam Sib Luag, tig rau Daim Ntawv Thov - SampleApp, nyem cov ntaub ntawv tso tawm hauv Pawg tswj hwm - Hloov. Hauv Hloov pauv hom pawg, xaiv Azure Iot Hub, sau koj Iot Hub Lub Npe thiab tus lej tseem ceeb, thiab nyem lees paub hloov pauv khawm hauv qab.

Duab
Duab

Kauj Ruam 4. Ntxiv Iot ntaus ntawv

Nyem Devices hauv cov npe ntawm sab laug hauv LORIOT, theej koj li Device EUI.

Duab
Duab

Rov qab mus rau Azure Iot Hub, nyem Iot cov cuab yeej hauv cov npe ntawm sab laug ntawm Iot Hub. Nyem Ntxiv, sau Ntaus EUI rau Ntaus Tus ID hauv nplooj ntawv qhib.

TSEEM CEEB: Rho tawm txhua tus neeg tsim khoom hauv DEVICE EUI, cia nws zoo li 1122334455557777.

Duab
Duab

Nyem Txuag, txhua yam ua tiav.

Kauj Ruam 5. Txais D2C (Device to Cloud) Messages

Koj tuaj yeem ua raws Microsoft Docs los nyeem D2C Cov Lus.

Kauj ruam 5: Software Programming

Software Programming tau muab faib ua 3 ntu: Node, Gateway thiab Website, thov ua raws Tutorial yav dhau los rau program Node Part thiab Gateway Part. Kauj Ruam 1 txog 8 ntawm Lub Vev Xaib Tshooj kuj zoo ib yam li Tutorial Yav dhau los.

Yog tias koj twb tau teeb tsa Microsoft Azure, qhib lub davhlau ya nyob twg, nkag mus rau koj lub vev xaib lub hauv paus nplaub tshev, qhib qhov chaw virtual:

cd ~/iotea-hb

qhov chaw hauv/qhib

nruab Azure Event Hub module ntawm pip, thiab tsim cov ntawv tshiab.py (xws li iothub_recv.py):

pip nruab azure-eventhub

kov iothub_recv.py

thiab tom qab ntawd sau cov lej hauv qab no rau nws:

# --------------------------------------------------------------------------------------------

# Cai (c) Microsoft Corporation. Txhua txoj cai qhaib. # Muaj ntawv tso cai raws li MIT Daim Ntawv Tso Cai. Saib License.txt hauv txoj haujlwm hauv paus rau cov ntaub ntawv tso cai. # ------------------------------------------------------- ------------------------------------------- los ntawm azure ntshuam eventhub los ntawm azure. eventhub ntshuam EventData, EventHubClient, Offset import logging logger = logging.getLogger ('azure.eventhub') ntshuam db, json, sijhawm, datetime def get_time (): cntime = datetime.datetime.now () + datetime.timedelta (teev = +8) hnub tim = cntime.strftime ('%Y-{}-{}'). Hom ntawv (cntime.strftime ('%m'). Zfill (2), cntime.strftime ('%d'). Zfill (2)) teev = cntime.strftime ('%H'). Zfill (2) feeb = cntime.strftime ('%M'). Zfill (2) thib ob = cntime.strftime ('%S'). Zfill (2)) rov qab [hnub, teev, feeb, thib ob] def get_iothub_data (): daim ntawv = ['0'] * 11 tus neeg siv = EventHubClient.from_iothub_connection_string ('', debug = True) tus txais = client.add_receiver ("$ default", " 3 ", kev ua haujlwm = '/lus/xwm txheej', offset = Offset (datetime.datetime.utcnow ())) sim: client.run () eh_info = client.get_eventhub_info () print (eh_info) tau txais = receiver.receive (sijhawm tas = 5) luam tawm (tau txais) rau cov khoom hauv tau txais: kuv ssage = json.loads (str (item.message)) print (message) yog 'data' hauv xov: data = message ['data'] air_temp = str (int (data [0: 2], 16)) air_hum = str (int (cov ntaub ntawv [2: 4], 16)) siab = str (int ((cov ntaub ntawv [4: 8]), 16)) co2 = str (int (cov ntaub ntawv [8:12], 16)) hmoov av = str (int (cov ntaub ntawv [12:16], 16)) illumination = str (int (cov ntaub ntawv [16:20], 16)) o2 = str (puag ncig (int (cov ntaub ntawv [20:22], 16) / 10, 1)) av_temp = str (int (cov ntaub ntawv [22:24], 16)) av_hum = str (int (cov ntaub ntawv [24:26], 16)) voltage = str (puag ncig (int (cov ntaub ntawv [26:28]), 16) / int ('ff', 16) * 5, 1)) error = str (int (data [28:], 16)) list = [air_temp, air_hum, siab, co2, hmoov av, teeb pom kev zoo, o2, av_temp, av_hum, qhov hluav taws xob, yuam kev] thaum kawg: tus neeg siv khoom.stop () rov qab cov npe thaum Muaj tseeb: daim ntawv = tau txais sijhawm () + tau_iothub_data () db.insert (daim ntawv) luam tawm (npe)

Ua ntej koj pib qhov program, hloov koj txoj hlua txuas hauv

tus neeg siv = EventHubClient.from_iothub_connection_string ('', debug = Tseeb)

koj tuaj yeem tau txais koj txoj hlua sib txuas los ntawm kev nyem Sib koom kev cai - iotowner hauv Iot Hub, Kev sib txuas txoj hlua -tus lej tseem ceeb hauv nplooj ntawv qhib yog txoj hlua sib txuas.

Duab
Duab

Tom qab ntawd, koj tuaj yeem pib qhov program:

gunicorn iothub_recv: app

Pom zoo: