Cov txheej txheem:

Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811): 5 Kauj Ruam
Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811): 5 Kauj Ruam

Video: Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811): 5 Kauj Ruam

Video: Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811): 5 Kauj Ruam
Video: 6 Nqi Lus Qhia Kev Ua neej ( leej twg mloog lub neej yuav zoo tuaj) 2024, Hlis ntuj nqeg
Anonim
Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811)
Pom IoTea LoRa Tshuaj (Hloov Kho Xyoo 1811)

Internet+ yog lub tswv yim nrov tam sim no. Lub sijhawm no peb tau sim Internet ntxiv rau kev ua liaj ua teb kom ua kom cov tshuaj yej vaj loj hlob tuaj hauv Internet Tshuaj yej.

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

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

Cov cuab yeej kho vajtse ntawm qhov haujlwm no tuaj yeem faib ua 4 ntu: Lub Hwj Chim, Cov Kws Nyuaj Siab, Node thiab Gateway. Kab lus hauv qab no yuav qhia koj yuav ua li cas ua kom tiav nws ib qib zuj zus.

Fais Fab Tshooj

Lub Hwj Huam Feem ntau muaj Hnub Ci Vaj Huam Sib Luag thiab Roj Teeb Lithium, yog tias koj tsuas yog tsim txoj haujlwm no rau kev ua qauv qhia, koj tuaj yeem tsis quav ntsej lawv. Lossis koj tuaj yeem ua raws li kev qhia yav dhau los txhawm rau teeb tsa lub zog.

Sensors Tshooj

Hauv Sensors Ib feem, vim muaj ntau qhov kev ntsuas, peb tau siv lub chaw nres tsheb huab cua, thiab tseem tau ua lub ntsej muag Acrylic los teeb tsa lawv.

Duab
Duab

Raws li koj pom hauv daim duab saum toj no, Digital Light Sensor ib txwm nyob rau sab saum toj, yog li nws tuaj yeem sau cov ntaub ntawv teeb pom kev zoo. Cov ntsuas cua uas yuav ua kom sov tau teeb tsa nruab nrab ntawm Acrylic bracket, xws li O2 Sensor, Plua Plav Sensor thiab CO2 Sensor. Thaum kawg, Kub thiab Vaum Sensor nyob hauv qab ntawm Acrylic bracket.

Dhau li ntawd, Cov av Kub thiab Vaum Sensor tau teeb tsa ib leeg hauv av. Node Tshooj

Duab
Duab

Node Part yog Seeeduino LoRaWan uas tau teeb tsa hauv Lub Thawv Tsis Muaj Dej, nws txuas rau lub zog thiab lub ntsuas pa ntawm Dej Sib Koom. Ntawm lawv, Dust Sensor txuas rau LoRaWan tus lej digital D3, CO2 Sensor txuas rau tus pin D4 & D5, Av Sensor txuas rau tus pin D6 & D7, O2 Sensor txuas rau analog pin A1 thiab Lub Teeb Sensor & Barometer Sensor txuas rau I2C chaw nres nkoj.

NCO TSEG: Ib tus 10k Resistor yuav tsum tau ntxiv nruab nrab ntawm Cov Av Sensor Cov Xiav (Cov Ntaub Ntawv) cable thiab Liab (Vcc) cable.

Seeeduino LoRaWan sau cov khoom ntsuas tus nqi ib ntus, thiab xa lawv mus rau Rooj vag ntawm LoRa. Cov ntaub ntawv hom zoo li hauv qab no:

{

[0], /* Huab cua huab cua (℃)* /[1], /* Huab cua huab cua (%)* /[2], /* Qhov siab (m) siab byte* /[3], /* Qhov siab (m) tsawg byte */[4],/ * CO2 concentration (PPM) siab byte */[5],/ * CO2 concentration (PPM) qis byte */[6],/ * Cov hmoov av concentration (pcs/0.01cf) siab byte */[7],/ *Cov hmoov av ntau (pcs/0.01cf) qis byte */[8],/ *Lub teeb pom kev zoo (lux) siab byte */[9],/ *Lub teeb siv (lux) qis byte */ [10], /* O2 concentration (%)* /[11], /* Av kub (℃)* /[12], /* Av av noo (%)* /[13], /* Roj teeb voltage (V) */ [14]/ *Sensor yuam kev code */}

Txhua qhov me me hauv Sensor Error Code byte muaj lub ntsiab lus sib txawv, ib yam li hauv qab no:

{

nqi 0: 1;. / * Barometer Sensor Error */ ntsis1: 1; / * CO2 Sensor yuam kev */ ntsis2: 1; / * Dust Sensor Error */ ntsis3: 1; / * Lub teeb Sensor yuam kev */ ntsis4: 1; / * O2 Sensor yuam kev */ ntsis5: 1; / * Av Sensor Error */ tseg tseg: 2; / * Tshwj tseg */}

Rooj vag Tshooj

Duab
Duab

Rooj vag Ib feem yog Raspberry Pi uas txuas rau Gateway module RHF0M301-868 thiab PRI 2 Choj RHF4T002, nws tau teeb tsa hauv Lub Thawv Tsis Muaj Dej thiab txuas rau lub zog & USB Lub Koob Yees Duab ntawm Dej Sib Koom. Vim tias nws siv cov software tshwj xeeb, thov ua raws Seeed Wiki txhawm rau teeb tsa nws.

Kauj ruam 4: Software Programming

Raws li Khoos Phis Tawj Kev Sib Txuas, Software Programming kuj tseem tuaj yeem sib cais, nws tuaj yeem faib ua 3 ntu: Node, Gateway thiab Website.

Node Tshooj

Feem ntau ntawm cov tsav tsheb uas Node Part xav tau twb muaj nyob hauv daim ntawv keeb kwm_driver. Cov tsev qiv ntawv hauv qab no yuav tsum tau teeb tsa manually:

Adafruit_ASFcore

Vim tias txoj haujlwm nyuaj, peb pom zoo kom koj siv Microsoft Visual Studio hloov chaw ntawm Arduino IDE. Ib lub plugin hu ua Visual Micro tuaj yeem pab koj ua qhov project Arduino los ntawm kev siv Visual Studio, nyem qhov no kom paub ntau ntxiv.

Rau kev nyeem tau zoo dua thiab tswj tau zoo, peb siv Lub Hom Phiaj-Oriented Programming lub sijhawm no. Cov duab hauv chav kawm ntawm txoj haujlwm no zoo li hauv qab no:

Duab
Duab

Rau cov ntsuas no twb muaj OOP tus tsav tsheb, peb rov muab nws hloov kho txoj haujlwm no, rau lwm tus, peb rov sau lawv cov tsav tsheb los ntawm kev siv OOP. Cov chav kawm Sensor hauv qib nruab nrab yog siv los koom ua ke cuam tshuam ntawm cov cuab yeej tiag tiag, piv txwv li, ntsuas lub ntsuas cua tuaj yeem khaws qhov ntsuas kub, av noo thiab qhov siab nyob rau tib lub sijhawm, yog li nws muaj 3 qhov cuam tshuam kom tau txais qhov kub, av noo thiab qhov siab. Tab sis lawv muaj qhov sib txawv lub npe, uas yuav ua rau txoj haujlwm tau txais cov txiaj ntsig txiaj ntsig nyuaj dua, ib yam li qhov no:

ntsuas ntsuas-> getTemperature ();

barometer-> getHumidity (); barometer-> tauAltitude (); //… another_sensor-> getSomeValue (); //…

Tab sis siv OOP, nws zoo li qhov no:

rau (pib kuv = 0; kuv getValue ();

}

Peb kuj tau ntim Daim Ntawv Thov hauv chav kawm, nws siv IApplication interface, teeb tsa () thiab voj () txoj hauv kev IoTea.ino tuaj yeem hu teeb tsa () thiab voj () txoj hauv kev thov khoom.

NCO TSEG: USB Serial siv los debug XWB. Tom qab kev debugging, thov tawm tswv yim nws yog pib ua cov cai hauv teeb () txoj hauv kev.

Rooj vag Tshooj

Gateway Part's Python program hauv tsev yog siv los thaij duab thiab xa lawv mus rau Amazon S3 Server txhua teev. Ua ntej koj siv nws, nco ntsoov fswebcam twb tau teeb tsa hauv koj li Raspberry Pi:

sudo apt-tau hloov tshiab && sudo apt-tau nruab fswebcam

Yog tias koj xav xa cov duab, teeb tsa koj AWS raws li hauv qab no. Ua ntej, teeb tsa AWS SDK thiab AWS CLI rau koj li Raspberry Pi los ntawm kev siv cov lus txib no:

sudo pip nruab boto3

sudo pip nruab awscli

thiab tom qab ntawd, khiav AWS CLI:

sudo aws configure

Configure your AWS Access Key ID, AWS Secret Access ID and Default region name.

Yog tias koj tsis nyiam upload koj cov duab, koj tuaj yeem hla AWS cov txheej txheem teeb tsa thiab tawm tswv yim tus lej hais txog kev rub tawm hauv photo.py. Txhawm rau khiav qhov haujlwm no tom qab pib Raspberry Pi txhua lub sijhawm, koj tuaj yeem tsim daim ntawv npe duab hauv /etc/init.d, thiab sau cov cai hauv qab no rau nws.

#!/bin/tsoo

# /etc/init.d/photo ### BEGIN INIT INFO # Muab: seeed_photo # Yuav tsum-Pib: $ remote_fs $ syslog # Yuav tsum-Nres: $ remote_fs $ syslog # Default-Pib: 2 3 4 5 # Default-Stop: 0 1 6 # Nqe lus piav qhia luv luv: thaij duab initscript # Nqe lus piav qhia: Qhov kev pabcuam no yog siv los tswj kev yees duab ### Xaus INIT INFO rooj plaub "$ 1" thaum pib) ncha "Pib thaij duab" /home/rxhf/photo.py &;; nres) ncha "Nres duab" tua $ (ps aux | grep -m 1 'python3 /home/rxhf/photo.py' | awk '{print $ 2}');; *) ncha "Siv: kev pabcuam yees duab pib | nres" tawm 1; esac Exit 0

teem kev tso cai

sudo chmod 777 /etc/init.d/photo

sudo chmod 777 /home/rxhf/photo.py

thiab sim nws

sudo /etc/init.d/photo pib

Yog tias tsis muaj teeb meem, nres nws thiab ntxiv rau qhov pib thov

sudo /etc/init.d/photo nres

sudo hloov tshiab-rc.d daim duab tsis raug

NCO TSEG: Yog tias koj xav pib lub qhov rooj tom qab Raspberry Pi booting, ntxiv lub qhov rooj pib cov lej hauv Pom Wiki rau /etc/rc.local, cia nws zoo li:

#!/bin/sh -e

# # rc.local # # Tsab ntawv no tau ua tiav ntawm qhov kawg ntawm txhua qhov kev ua haujlwm ntau ntau # Nco ntsoov tias tsab ntawv yuav "tawm 0" ntawm kev ua tiav lossis lwm yam # tus nqi ntawm kev ua yuam kev. # # Txhawm rau pab lossis lov tes taw tsab ntawv no tsuas yog hloov qhov ua tiav # khoom. # # Los ntawm lub neej ntawd tsab ntawv no tsis ua dab tsi. # Luam tus IP chaw nyob _IP = $ (hostname -I) || muaj tseeb yog tias ["$ _IP"]; ces printf "Kuv tus IP chaw nyob yog %s / n" "$ _IP" fi cd /home/rxhf/loriot/1.0.2 sudo systemctl nres pktfwd sudo gwrst wget https://cn1.loriot.io/home/gwsw/loriot -risinghf-r… -O loriot-gw.bin chmod +x loriot-gw.bin./loriot-gw.bin -f -s cn1.loriot.io tawm 0

Lub Vev Xaib

Peb tau siv lub vev xaib ntawm CentOS 7. Cov hauv qab no yuav qhia koj yuav siv li cas.

Kauj Ruam 1. Nruab Python3

sudo yum -y nruab epel -tso tawm

sudo yum -y nruab python36

Kauj Ruam 2. Nruab Python pip thiab virtual enviroment

wget

sudo python36 get-pip.py sudo pip nruab virtualenv

Setp 3. Clone peb lub vev xaib los ntawm GitHub

sudo yum -y nruab git

git clone

Kauj Ruam 4. Tsim thiab qhib qhov chaw ib puag ncig virtual

virtualenv -p python36 iotea -hb

cd iotea-hb source bin/qhib

Kauj Ruam 5. Txhim kho cov tsev qiv ntawv

pip nruab pymysql

pip nruab dbutils pip nruab flask pip nruab websocket-client pip nruab cofigparser

Kauj Ruam 6. Tsim database

sudo yum -y nruab mariadb mariabd -server

sudo systemctl pab mariadb sudo systemctl pib mariadb mysql -uroot -p

thiab tom qab ntawd siv iotea_hb.sql los tsim lub rooj.

Kauj Ruam 7. Tsim db.ini, thiab sau cov lej no rau nws

[db] Cov

db_port = 3306 db_user = hauv paus db_host = localhost db_pass = db_name = iotea

hloov db.ini txoj hauv db.py

# hauv db.py

#cf.read ("/data/www/python3_iotea_hb/iotea/conf/db.ini") cf.read ("/home // iotea-hb/db.ini")

Kauj Ruam 8. Hloov chaw nres nkoj hauv app.py thiab pib lub vev xaib:

# hauv app.py

#app.run (debug = Tseeb, chaw nres nkoj = 6000) app.run (debug = Tseeb, chaw nres nkoj = 8080)

# hauv davhlau ya nyob twg

pip nruab gunicorn gunicorn -w 5 -b 0.0.0.0:8080 app: app

tam sim no mus ntsib 127.0.0.1:8080 hauv koj lub vev xaib, koj tuaj yeem pom lub vev xaib, tab sis cov ntaub ntawv ntawm lub sijhawm tiag tiag tsis tshwm.

Kauj ruam 9. Tau txais cov ntaub ntawv loriot

Qhib lwm lub davhlau ya nyob twg, rov nkag rau ib puag ncig virtual thiab pib loriot app:

cd io-hb

qhov chaw rau hauv/qhib cov phom tua phom loriot: app

Tos ib pliag, koj yuav pom cov ntaub ntawv tso tawm hauv lub vev xaib, lossis koj tuaj yeem hloov wss hauv loriot.py:

# hauv loriot.py

#ws = create_connection ("wss: //cn1.loriot.io/app? token = vnwEuwAAAA1jbjEubG9yaW90LmlvRpscoh9Uq1L7K1zbrcBz6w ==")

ws = create_connection ()

Kauj ruam 5: Kev ua haujlwm

Koj tuaj yeem mus ntsib peb lub vev xaib los saib cov ntaub ntawv ntawm lub sijhawm tiag:

  • Hauv Ya'an
  • Rau Kev Ua Phem

Pom zoo: