Cov txheej txheem:

Pom LoRa IoTea Tshuaj: 5 Kauj Ruam
Pom LoRa IoTea Tshuaj: 5 Kauj Ruam

Video: Pom LoRa IoTea Tshuaj: 5 Kauj Ruam

Video: Pom LoRa IoTea Tshuaj: 5 Kauj Ruam
Video: HLUB KOJ IB LEEG TSIS MUAJ NQIS By Maiv Xis Xyooj Nkauj Tawm Tshiab Official 2022 2024, Kaum ib hlis
Anonim
Saib LoRa IoTea Tshuaj
Saib LoRa IoTea Tshuaj

Cov txheej txheem sau cov ntaub ntawv tsis siv neeg tau thov rau cog tshuaj yej. Nws yog ib feem ntawm cov ntaub ntawv ua liaj ua teb ntse.

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

Kauj ruam 2: Zaj dab neeg

Kev ua liaj ua teb ntse yog siv Internet Cov Khoom Siv thev naus laus zis rau kev ua liaj ua teb ib txwm muaj, siv cov cuab yeej ntsuas thiab software los tswj kev ua liaj ua teb los ntawm lub xov tooj ntawm tes lossis khoos phis tawj, ua rau kev ua liaj ua teb ib txwm muaj "ntse".

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 toj siab. 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 toj siab feem ntau yog sau me me thiab lawv qhov txiaj ntsig tsis tau xav txog ntawm kev ua lag luam. " Rau ob xyoos dhau los, Deng tau sim ua kom cov neeg siv khoom paub txog cov tshuaj yej saum toj roob hauv pes los txhawb lawv cov txiaj ntsig. 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. Kev Pom Kev IoTea lub hom phiaj los pab cov neeg ua teb tshuaj yej zoo tswj kev cog ntoo yam tsis hloov pauv kev coj noj coj ua ntawm cov tshuaj yej cog, thiab nthuav qhia cov ntaub ntawv ib puag ncig ib puag ncig los ntawm kev cog ntoo qhib lub platform.

Suav nrog cov ntsuas, ntsuas, thiab lub qhov rooj, IoTea sau cov ntaub ntawv lub sijhawm tiag ntawm yam uas tuaj yeem cuam tshuam qhov zoo ntawm tshuaj yej thaum cog thiab cov txheej txheem tsim khoom, suav nrog kub thiab av noo, CO2, O2, PM, thiab pom lub teeb. Cov ntaub ntawv tau khaws los ntawm cov ntsuas hluav taws xob, xa los ntawm cov nodes mus rau lub qhov rooj thiab thaum kawg mus rau huab, thiab tau ua kom yooj yim rau cov neeg siv kawg ntawm lub vev xaib.

Kauj Ruam 3: Kev Kho Vajtse Txuas

Kauj ruam 1: Rooj vag Kev Sib Txuas

Lub qhov rooj raug teeb tsa cais hauv ib lub thawv. Xav txog qhov teeb meem tshav kub, peb ntxiv 2 tus kiv cua. Ib qho yog rau Raspberry Pi cov cua sov ua kom sov, lwm qhov yog rau huab cua sab hauv thiab sab nraud. Lub thawv rooj nkag tau muab tso rau hauv tus neeg ua liaj ua teb lub tsev, yog li peb tsis tas yuav xav txog nws lub zog teeb meem.

Duab
Duab

Kauj ruam 2: Node Kev Sib Txuas

Lub node yog lub davhlau ya nyob twg ntawm cov ntaub ntawv, thiab tag nrho cov ntaub ntawv qub tau txais los ntawm no. Muaj 6 lub cim ntsuas txuas nrog rau ntawm qhov ntxiv rau hauv av noo & ntsuas kub, peb tso lwm lub ntsuas pa sab hauv lub thawv ntim.

Duab
Duab
Duab
Duab

Node tau muab tso rau hauv lub thawv tsis muaj dej. Txhawm rau kom muaj kev sib txuas zoo dua ntawm lub node, peb ua lub rooj tsav xwm adapter. Thaum kawg, peb yuav muab lub rooj tsav xwm no cov txheej txheem rub tawm txuas. Raws li qhia hauv qab no, cov kab hluav taws xob ntawm lub ntsuas hluav taws xob tau ntsaws rau hauv pawg thawj coj saib los ntawm cov dav hlau thaiv. Peb siv 3 lub raj MOS (SI2301) los tsim cov hloov hluav taws xob los tswj qhov qhib thiab kaw ntawm lub ntsuas cua thiab kiv cua. Ntxuam yog siv kom txias. Peb muaj lub ntsuas kub (DS18B20) teeb tsa ntawm lub rooj tsavxwm. Nws tuaj yeem qhia peb qhov ntsuas kub sab hauv ntawm lub thawv, thiab tom qab ntawd microcontroller txiav txim siab seb puas yuav qhib lub kiv cua. Peb siv ob peb resistors los ua hluav taws xob faib hluav taws xob los ntsuas cov roj teeb-kua qaub roj teeb. Thaum kawg, peb khaws 3 IIC cuam tshuam thiab chaw nres nkoj txuas ntawm lub rooj tsav xwm rau tom qab nthuav dav thiab debugging.

Duab
Duab

Cia peb tham txog qhov teeb meem ntawm lub zog siv hluav taws xob. Lub hauv paus tau muab tso rau hauv cov tshuaj yej cog tsis zoo, yog li cov txheej txheem kev siv fais fab tsis siv tau lawm. Siv lub hnub ci daws teeb meem yog lub tswv yim zoo. Muaj ntau qhov kev daws teeb meem muab rau ntawm kev ua lag luam tam sim no. Peb tuaj yeem xaiv ib qho ntawm lawv uas ua tau raws li peb xav tau. Muaj 3 ntu hauv qhov kev daws teeb meem peb tau xaiv: hnub ci vaj huam sib luag, tswj lub hnub ci thiab cov roj teeb kua qaub. Txhawm rau txhawm rau ntes lub hnub ci zog zoo dua, peb muab lub hnub ci vaj huam sib luag nyob rau sab saum toj ntawm lub bracket thiab kho nws lub kaum sab xis kom ntseeg tau tias nws tau ntsib lub hnub. Peb tso lub hnub ci tus tswj hwm rau hauv tib lub npov nrog rau ntawm. Vim tias tsis muaj chaw seem ntxiv hauv lub thawv, peb yuav tsum nrhiav lub thawv dej tshiab los tso cov roj teeb kua qaub.

Duab
Duab
Duab
Duab
Duab
Duab

Kauj ruam 4: Khoos phis tawj software

Ntawm

Hauv ntu no, peb yuav qhia qhov feem ntau software teeb tsa ntawm ntawm.

DataFormat

Cov ntaub ntawv xa los ntawm lub node rau lub qhov rooj:

unsigned char Lora_data [15] = {0, 1, 2, 3,, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};

Lub ntsiab lus ntawm txhua cov ntaub ntawv me ntsis:

Lora_data [0] : Cua kub, ℃

Lora_data [1] : Cov av noo, %

Lora_data [2] : Qhov siab siab yim, m

Lora_data [3] : Qhov siab qis qis yim

Lora_data [4] : CO2 concentration siab yim, ppm

Lora_data [5] : CO2 concentration qis yim

Lora_data [6] : Plua plav siab siab yim, pcs/0.01cf

Lora_data [7] : Plua plav concentration qis yim

Lora_data [8] : Lub teeb ci siab yim, lux

Lora_data [9] : Lub teeb siv qis yim

Lora_data [10] : O2 concentration, % (cov ntaub ntawv nyoos faib los ntawm 1000)

Lora_data [11] : Cov av kub, ℃

Lora_data [12] humidity Av av noo, %

Lora_data [13] : Roj teeb hluav taws xob, v

Lora_data [14] : Sensors yuam kev code

Yuam kev code:

Lora_data [14] = [bit7, bit6, bit5, bit4, bit3, bit2, bit1, bit0]

Lub ntsiab lus ntawm txhua qhov me ntsis:

me ntsis 0: 1 ---- Temp & Humi & Barometer Sensor (BME280) yuam kev

ntsis 1: 1 ---- Carbon Dioxide Sensor (MH-Z16) yuam kev

ntsis 2: 1 ---- Dust Sensor (PPD42NS) yuam kev

ntsis 3: 1 ---- Digital Light Sensor yuam kev

ntsis 4: 1 ---- Oxygen Sensor (ME2-O2-Ф20) yuam kev

me ntsis 5: 1 ---- Av noo & Kub Sensor yuam kev

ntsis 6: Reserved

ntsis 7: Reserved

Peb tau ua Error_code_transform.exe, qhib nws thiab cov lej yuam kev yuam kev hauv hexadecimal, koj yuav sai sai paub qhov twg yog qhov yuam kev. Qhov txuas txuas yog qhov kawg ntawm kab lus no.

Parameter hloov: a) Cov ntaub ntawv xa mus

// seeedtea.ino

#defineinterval_time 600 // thib ob

Qhov ntsuas no tuaj yeem hloov pauv hloov cov ntaub ntawv xa mus. Hauv txhua lub voj voog, kev nrhiav cov ntaub ntawv yuav siv sijhawm li 1 feeb. Yog li, nws tsis pom zoo kom hloov tus nqi no tsawg dua 60 vib nas this.

b) Lub sijhawm ua kom sov plua plav sensor

//seeedtea.ino

#definePreheat_time 30000 // DustSensor lub sijhawm sov, milliseond //Dust_other.cpp #definesampletime_ms 30000 // samplingtime30s

c) Voltage coefficient

// POWER_Ctrl.cpp

#defineBattery_coefficient 0.159864 // ADC tus nqi × Battery_coefficient = battery_voltage #defineSolar_coefficient 0.22559 // ADC tus nqi × Solar_coefficient = solar_voltage

Ob qhov ntsuas no tau suav los ntawm qhov faib hluav taws xob faib hluav taws xob.

d) Ntxuam qhib qhov kub thiab txias

// POWER_Ctrl.cpp

#defineFan_start_temp 45 // temperaturethreshold #defineFan_start_light 500 // teeb pom kev zoo

Thaum qhov kub tiag tiag tshaj qhov pib, kiv cua yuav pib txias.

e) O2 sensor pib qhov ntsuas ntsuas

//Oxygen.cpp

#defineO2_percentage 208.00 // 20.8%

f) Macro hloov

//seeedtea.ino

#defineLORA_RUN // Tom qab cov lus tawm tswv yim, Lora kev pib ua thiab cov ntaub ntawv xa mus yuav nres #defineSENSOR_RUN // Tom qab kev tawm lus, cov neeg sab nrauv yuav tsum tsis ua haujlwm //POWER_Ctrl.cpp #defineFAN_ON // Ua haujlwm tau zoo xwb, Cov ntawv thov yuav tsum tau tawm tswv yim tawm /**** *** DS18B20 tswj hom **********************/ #defineSlower_Mode // Hom qeeb kom pom qhov kub thiab txias. Tawm tawm yog hom nrawm

g) Pin qhia

D2: LED qhia thiab rov pib dua microcontrollerIIC: SCL thiab SDA

// Dust_ lwm.h

#defineDust_pin 3 // Dust sensor //CO2.cpp #defineCO2_serial Serial1 // siv hardwareserial chaw nres nkoj (D0 & D1) //seeedtea.ino #definedataPin 6 // Cov ntaub ntawv hauv av pin #defineclockPin 7 // Cov xuab moos moos // POWER_Ctrl. h #defineDS18B20_pin 8 // DS18B20 #defineFan_pin 9 // Ntxuam #defineAir_CtrlPin 10 // Tswj tus pin rau lub ntsuas hluav taws xob tso rau hauv louverbox #defineSoil_CtrlPin 11 // Av noo noo & Kub Sensor hloov tus pin #defineBattery_pin A2 // Ntsuas roj teeb voltage #defineSolar /Ntsuas hnub ci vaj huam sib luag voltage //Oxygen.h #defineO2_pin A1 // O2 sensor

h) Watchdog timer

Tus saib xyuas lub sijhawm tau siv los tshuaj xyuas qhov xwm txheej ua haujlwm. Thaum cov kab ke ua haujlwm tsis raug, lub node yuav rov pib dua, yog li nws tuaj yeem ua haujlwm tsis tu ncua ntev.

Lub tsev qiv ntawv yuav tsum tau hais txog:

  • Adafruit_SleepyDog.h tau ntxiv rau txoj haujlwm
  • Adafruit_ASFcore-master.zip tau ntim rau hauv cov ntawv tais ceev tseg thiab yuav tsum tau muab ntxiv rau tus kheej rau Arduino IDE.

Lwm yam haujlwm:

Pab kom saib xyuas

int WatchdogSAMD:: pab kom (int maxPeriodMS, bool isForSleep)

Cov tswv yim tsis:

Int maxPeriodMS: Tos sijhawm hauv milliseconds. Qhov siab tshaj tso cai yog 16000 milliseconds.

rov qab tus nqi:

Int hom, xa lub sijhawm tos tiag

Pib dua watchdog

void WatchdogSAMD:: pib dua ()

Hu rau txoj haujlwm no kom rov pib lub sijhawm saib xyuas, hu ua "pub dev." Tshaj qhov tos lub sijhawm yam tsis tau rov pib dua yuav ua rau kom rov pib dua.

Nres saib xyuas

void WatchdogSAMD:: lov tes taw ()

Rooj vag

Hauv ntu no peb yuav qhia yuav ua li cas txuas rau Loriot server.

Kauj Ruam 1: Loriot Server Gateway Registration

a) Tus neeg siv tshiab xav tau sau npe tus lej ua ntej, nyem qhov chaw nyob rau npe. Sau rau hauv UserName, Password thiab email chaw nyob txhawm rau sau npe, tom qab sau npe email yuav xa tuaj rau koj, thov ua raws cov lus qhia hauv email kom qhib.

b) Tom qab ua tiav kev ua tiav, nyem rau qhov no txhawm rau nkag mus. Lub hauv paus pib yog "Community Network", nws txhawb 1 Gateway (RHF2S001) thiab 10 nodes.

c) Nkag mus rau Dashboard -> Rooj vag, nyem Ntxiv Gateway pib ntxiv Gateway.

d) Xaiv Raspberry Pi 3

e) Teeb raws li hauv qab no:

  • Xov tooj cua pem hauv ntej -> RHF2S001 868/915 MHz (SX1257)
  • BUS -> SPI

f) Sau MAC chaw nyob ntawm koj RHF2S001, yuav tsum yog hom b8: 27: eb: xx: xx: xx. Thiab tseem nkag mus rau Rooj vag Qhov Chaw cov ntaub ntawv.

g) Nyem rau "Sau npe Raspberry Pi lub qhov rooj" kom tiav rau npe.

Duab
Duab

h) Nyem rau lub qhov rooj nkag mus nkag rau nplooj ntawv teeb tsa, hloov "Kev Npaj Zaus" tus kheej, koj lub phiaj xwm ntawm no tau txiav txim siab los ntawm koj hom RHF2S001 hom, muaj phiaj xwm yog CN470 , CN473 , CN434 , CN780 , EU868, tom qab xaiv thov rov kho nplooj ntawv kom tau txais cov channel tseeb. Hauv wiki no peb xaiv EU868.

i) Khiav cov lus txib hauv lub dav hlau putty :

cd /home/rxhf/loriot/1.0.2

sudo systemctl nres pktfwd sudo gwrst wget > -O loriot-gw.bin chmod +x loriot-gw.bin./loriot-gw.bin -f -s cn1.loriot.io

j) Finish gateway registration. You will see the gateway is Connected now. Next is to register node.

Duab
Duab

Kauj Ruam 2: Loriot Server Txuas Node ntaus ntawv

a) Tau txais cov rooj vag uas muaj

Cov rooj vag tam sim no tuaj yeem tau txais los ntawm Dashboard -> Gateway -> Koj Lub Rooj vag, koj tuaj yeem pom cov channel muaj raws li daim duab hauv qab no.

Duab
Duab

b) Saibeduino LoRAWAN GPS (RHF3M076) Kev teeb tsa

Qhib cov ntawv saib xyuas ntawm ArduinoIDE, coj mus rhaub cov lus txib hauv qab no.

ua+ch

Txhawm rau lees paub qhov tsis raug ntawm koj li Seeeduino_LoRAWAN GPS, koj yuav tau txais 3 txoj hauv kev. Yog tias tsis muaj cov channel, koj tuaj yeem hloov pauv raws ntawm Seeeduino_LoRAWAN los ntawm cov lus txib hauv qab no.

ntawm+ch = 0, 868.1

ntawm+ch = 1, 868.3 ntawm+ch = 2, 868.5

Tom qab ntawd koj tuaj yeem siv ntawm+ch dua los tshuaj xyuas.

c) Ntxiv Seeeduino_LoRAWAN GPS ua ABP NodeLog hauv Loriot server, Nyem Dash Board -> Applications -> SimpleApp. Nyem Ntshuam ABP , cov lus nkag hauv qab cov khoom

  • DevAddr: Seeeduino_LoRAWAN GPS tau txais los ntawm "AT+ID" hais kom ua (Nco tseg: Loriot tsis txhawb nqa txoj hnyuv loj, xav tau tshem tawm tus kheej)
  • FCntUp : Setto 1
  • FCntDn : Setto 1
  • NWKSKEY : Defaultvalue 2B7E151628AED2A6ABF7158809CF4F3C
  • APPSKEY : Defaultvalue 2B7E151628AED2A6ABF7158809CF4F3C
  • EUI : DEVEUI, Seeeduino_LoRAWAN GPS tau txais los ntawm "AT+ID" hais kom ua
Duab
Duab

Nyem Ntshuam Ntaus khawm kom ua tiav cov cuab yeej ntshuam. Tam sim no xaiv Dashboard-> Cov Ntawv Thov -> SampleApp, koj yuav pom ABP Node tshiab uas koj nyuam qhuav tau ntxiv.

Duab
Duab

d) Xa cov ntaub ntawv los ntawm Seeeduino_LoRAWAN

ZOO SIAB! Qhov no tsuas yog kev sim.

Rov qab mus rau tus saib xyuas ntawm ArduinoIDE, xa cov lus txib:

AT+CMSGHEX = "0a 0b 0c 0d 0e"

Tom qab ntawd mus rau Dashboard -> Applications -> SampleApp -> Device, nyem rau ntawm Node Device EUI lossis DevAddr, koj yuav pom cov ntaub ntawv koj nyuam qhuav xa tuaj ntawm no.

Duab
Duab

Yog xav paub ntxiv, thov mus saib hauv wiki no.

Kauj Ruam 5: Kev Tsim Kho Lub Vev Xaib

Lwm yam cuab yeej

  • virtualenv
  • Nab hab sej 3
  • Gunicorn
  • Tus saib xyuas
  • Nginx
  • MySQL

Peb siv CentOS7 ua qhov chaw sim xa mus

virtualenv

Siv virtualenv los tsim ib leeg ib leeg ua nab kuab ib puag ncig ntau lawm

a) nruab

pip nruab virtualenv

b) tsim ib puag ncig nab nab 3

virtualenv -p python3 iotea

c) pib ib puag ncig virtual thiab nkag mus rau iotea phau ntawv teev npe

qhov chaw hauv/qhib

d) muaj ib puag ncig

deactivate

Nab hab sej 3

a) nruab

yum nruab epel-tso tawm

yum nruab python36

b) teeb tsa lub tsev qiv ntawv nyob sib ze PyMySQL, DBUtils, Flask, websocket-client, configparser

pip nruab pymysql

pip nruab dbutils pip nruab flask pip nruab websocket-client pip nruab configparser

Gunicorn

a) teeb tsa (hauv Python3 ib puag ncig)

pip nruab gunicorn

b) khiav dej num project (hauv qab iotea project directory)

gunicorn -w 5 -b 0.0.0.0:5000 app: app

c) khiav websocket-clint kom tau txais cov ntaub ntawv loriot

gunicorn loriot: app

d) saib Gunicorn txheej txheem ntoo

pstree -ap | grep gunicorn

Tus saib xyuas

a) nruab (tus neeg siv hauv paus)

pip nruab tus saib xyuas

b) tsim cov ntaub ntawv teeb tsa

echo_supervisord_conf> /etc/supervisord.conf

c) tsim cov npe thiab qhia cov npe teeb tsa

mkdir -p /etc/supervisor/conf.d

Kho /etc/supervisord.conf thiab hloov kho cov ntaub ntawv hauv qab [suav nrog] thaum kawg ntawm cov ntawv.

Nco ntsoov tias koj yuav tsum tshem qhov ';' nyob rau hauv pem hauv ntej ntawm ob kab no, uas yog cov lus pom.

[suav nrog]

Cov ntaub ntawv = /etc/supervisor/conf.d/*.conf

Txhais tau tias yuav qhia /etc/supervisor/conf.d/. Cov ntaub ntawv teeb tsa hauv qab no yog siv los ua cov txheej txheem teeb tsa (saib xyuas los ntawm tus thawj saib xyuas).

d) cov khoom teeb tsa (hauv qab iotea phau ntawv teev npe)

cp iotea.conf /etc/supervisor/conf.d/

cp loriot.conf /etc/supervisor/conf.d/

e) qhib kev pabcuam iotea

superviosrctl reload #reload cov ntaub ntawv teeb tsa

superviosrctl pib loriot #open loriot cov ntaub ntawv txais tos superviosrctl pib iotea #qhib daim ntawv thov iotea hwj

f) lwm txoj haujlwm

supervisorctl rov pib dua # rov ua cov ntaub ntawv teeb tsa

supervisorctl hloov tshiab supervisorctl pib xxx supervisorctl nres xxx supervisorctl xwm txheej xxx supervisorctl pab # saib cov lus txib ntxiv

Nginx

a) nruab

yum nruab -y nginx

b) teeb tsa

cp NginxIotea.conf /etc/nginx/conf.d/

c) pib Nginx

systemctl pib nginx.service

MySQL

a) tsis muaj feem cuam tshuam

user = 'hauv paus'

passwd = '1234' db = 'iotea' chaw nres nkoj = 3306

b) ntawv

iotea_iotea.sql

c) configuration ntaub ntawv

db.ini ib

Pom zoo: