Cov txheej txheem:

Ultra-low Power WiFi Tsev Automation System: 6 Cov Kauj Ruam (nrog Duab)
Ultra-low Power WiFi Tsev Automation System: 6 Cov Kauj Ruam (nrog Duab)

Video: Ultra-low Power WiFi Tsev Automation System: 6 Cov Kauj Ruam (nrog Duab)

Video: Ultra-low Power WiFi Tsev Automation System: 6 Cov Kauj Ruam (nrog Duab)
Video: Muaj tsis ntshai tuag 7/1/2018 2024, Hlis ntuj nqeg
Anonim
Ultra-low Power WiFi Tsev Automation System
Ultra-low Power WiFi Tsev Automation System
Ultra-low Power WiFi Tsev Automation System
Ultra-low Power WiFi Tsev Automation System

Hauv qhov haujlwm no peb qhia yuav ua li cas koj tuaj yeem tsim lub hauv paus tsev hauv tsev siv tshuab hauv ob peb kauj ruam. Peb yuav siv Raspberry Pi uas yuav ua lub hauv paus WiFi cov cuab yeej. Whereas rau qhov kawg peb yuav siv IOT Cricket los ua lub roj teeb siv WiFi cov cuab yeej xws li ntsuas kub thiab txuas nws mus rau RPi yam tsis tau sau ib kab nkaus xwb.

Peb cov txheej txheem yuav ua raws MQTT cov txheej txheem kev sib txuas lus, uas tau txais kev pom zoo hauv ntau lub tsev siv tshuab hauv tsev. Txhawm rau teeb tsa nws peb xaiv Mosquitto MQTT broker (server) thiab teeb nws ntawm Raspberry Pi (peb lub hauv paus nruab nrab).

IOT Cricket kuj los nrog HTTP (S) thiab MQTT cov kev cai txhawb nqa. Peb teeb tsa nws los siv MQTT los sib tham ncaj qha rau peb RPi MQTT broker.

Txoj haujlwm no tuaj yeem paub los ntawm cov neeg tsim khoom ntawm txhua qib txuj ci. Nws yuav xav tau qee qhov yooj yim soldering txawm li cas los nws tsis xav tau ib qho coding lossis programming. Thaum kawg ntawm txoj haujlwm no koj yuav tau txais lub tswv yim zoo li cas koj tuaj yeem yooj yim tsim koj tus kheej li cas thiab txuas ntxiv sai sai los ntawm kev ntxiv koj tus kheej IOT kawg nodes rau hauv kab ke.

Khoom siv:

  • Raspberry Pi (peb siv ver. 3 rau txoj haujlwm no)
  • IOT Cricket WiFi module
  • 2xAAA roj teeb tuav
  • 2xAAA roj teeb

Kauj Ruam 1: MQTT yog dab tsi?

MQTT raws tu qauv muab txoj hauv kev yooj yim ntawm kev xa xov siv cov ntawv tshaj tawm/sau npe ua qauv. Qhov no ua rau nws haum rau Internet ntawm Yam Kev xa xov xws li lub zog ntsuas hluav taws xob qis lossis cov khoom siv mobile xws li xov tooj, kos lub computer lossis microcontrollers. (qhov chaw: mosquitto.org)

Peb tuaj yeem siv ntau yam khoom siv raws li peb xav sau npe rau cov ncauj lus thiab mloog cov lus kom tuaj txog. Yog tias qee lub cuab yeej (s) tshaj tawm cov lus ntawm cov ncauj lus ntawd tag nrho cov cuab yeej, uas tau sau npe rau lub ncauj lus, tau txais cov lus ntawd tam sim ntawd. Cov ncauj lus tuaj yeem yog ib txoj hlua uas tsis xav tau feem ntau sib txuas nrog / cov cim kom tso cai tsim cov ncauj lus hierarchical. Kev siv feem ntau ntawm MQTT yog kom muaj ib lub server nruab nrab uas cov khoom siv tuaj yeem sau npe thiab tshaj tawm cov lus. Nws ua kom yooj yim txhua qhov kev sib txuas lus ntawm cov khoom siv txuas nrog lub server ntawd. Hauv qhov haujlwm no peb yuav siv RPi los ua peb lub hauv paus MQTT tus tswv lag luam thiab txhua lwm yam khoom siv yuav xa xov ntawm tus broker no. Txoj hauv kev zoo tshaj los kawm txog nws, yog qhov tseeb los ntawm kev ua nws tus kheej. Muaj ntau cov peev txheej muaj hauv internet ntawm MQTT. Txawm li cas los xij, rau txoj haujlwm no koj yuav tsum ua tiav nrog cov lus qhia yooj yim, uas peb tau muab rau saum toj no.

Kauj Ruam 2: Txhim Kho MQTT Broker ntawm Raspberry Pi

Txog qhov haujlwm no peb siv qhib qhov chaw Mosquitto MQTT broker. Nws yog lub teeb yuag thiab haum rau kev siv ntawm txhua lub cuab yeej los ntawm lub zog hluav taws xob tib lub tshuab computer rau tag nrho cov servers.

Ua ntej peb pib txhim kho, nws yog ib qho kev coj ua zoo los hloov kho cov txheej txheem ua ntej:

$ sudo apt-tau hloov tshiab $ sudo apt-tau upgrade

Nruab Mosquitto broker. Qhib lub davhlau ya nyob twg thiab ntaus cov lus txib hauv qab no:

$ sudo apt -tau nruab mosquitto -y

Configure Mosquitto broker. Kho cov ntaub ntawv teeb tsa:

$ sudo vi /etc/mosquitto/mosquitto.conf

thiab ntxiv cov kab hauv qab no rau saum:

chaw nres nkoj 1883allow_anonymous tseeb

Rov pib dua RPi los thov hloov pauv:

$ sudo rov pib dua

Qhov ntawd yog nws! Peb tus broker MQTT tau nce thiab ua haujlwm tam sim no!

NCO TSEG: rau qhov yooj yim ntawm txoj haujlwm no peb tsis tsim cov nyiaj. Yog li txhua tus neeg hauv peb lub network tuaj yeem txuas rau MQTT tus broker yam tsis muaj daim ntawv pov thawj. Yog tias koj xav ntxiv cov neeg siv pov thawj thiab ua kom nws muaj kev nyab xeeb ntxiv, muaj ntau cov lus qhia hauv internet yuav ua li cas.

Tam sim no, peb tsuas yog xav kom tau txais tus IP chaw nyob yog li peb tuaj yeem xa xov mus rau peb tus Mosquitto broker los ntawm lwm cov khoom siv hauv network:

Tau txais IP chaw nyob:

$ hostname -I

your_RPi_IP_address (piv txwv li 192.168.1.10)

Kauj Ruam 3: Txuas IOT Cricket rau RaspberryPi hla MQTT

Txuas IOT Cricket rau RaspberryPi hla MQTT
Txuas IOT Cricket rau RaspberryPi hla MQTT
Txuas IOT Cricket rau RaspberryPi hla MQTT
Txuas IOT Cricket rau RaspberryPi hla MQTT

Hauv txoj haujlwm no peb siv IOT Cricket WiFi module rau lub ntsuas cua yooj yim los tshaj tawm qhov ntsuas kub txhua 30 vib nas this rau peb qhov system. Nws yuav siv roj teeb yog li peb tuaj yeem lo nws nyob txhua qhov chaw hauv tsev lossis hauv vaj. Tom qab ntawd koj tuaj yeem siv IOT Cricket los tsim ntau yam roj teeb siv lub zog ntsuas, lub tswb, khawm, hloov thiab txuas lawv ib yam rau peb RPi MQTT tus tswv lag luam tawm ntawm lub thawv.

Hauv thawj kauj ruam txuas cov roj teeb rau Cricket.

Kab civliv los nrog lub ntsuas kub hauv tsev. Peb tsuas yog yuav tsum teeb tsa nws kom xa tus nqi kub rau peb MQTT tus neeg nqa khoom los ntawm teeb tsa RPi IP chaw Nyob. Txhawm rau ua qhov qhib Cricket lub teeb vaj huam sib luag (saib cov kauj ruam ntawm no) thiab siv cov teeb tsa hauv qab no (raws li qhia hauv daim duab hauv qab no, thov kho IP chaw nyob hauv "url" lub thawv rau koj RPi)

Tam sim no peb tuaj yeem tawm ntawm hom teeb tsa. Qhov cuab yeej npaj tau! Kab civliv twb tau xa cov ntaub ntawv rau peb MQTT broker txhua 30 vib nas this.

Kauj Ruam 4: Tshawb xyuas MQTT Cov Lus

Tshawb xyuas MQTT Cov Lus
Tshawb xyuas MQTT Cov Lus

Txhawm rau saib / tau txais cov lus xa mus rau peb tus broker MQTT peb tuaj yeem siv ntau yam cuab yeej.

Qhov yooj yim tshaj plaws yuav yog kab hais kom ua cuab yeej mosquitto_sub. Peb tuaj yeem teeb tsa nws ntawm txhua lub khoos phis tawj hauv peb lub network lossis ntawm peb RPi nrog cov lus txib no:

$ sudo apt-tau nruab mosquitto-cov neeg siv -y

Tam sim no peb tuaj yeem ua raws cov lus txib hauv qab no los mloog TXHUA cov ncauj lus thiab cov lus xa los ntawm peb MQTT broker:

$ mosquitto_sub -v -h your_RPi_IP_address -p 1883 -t '#'

…/59A98F494C/device_name MyTemperatureDev/59A98F494C/device_sn 59A98F494C/59A98F494C/hwc_wake_up 3794/59A98F494C/hwc_wifi_enabled 3763/59A98F494C/hwc_message_sent4

Qhov saum toj no yog qhov piv txwv tso tawm ntawm qhov IOT Cricket xa mus rau peb tus broker. Ntawm lwm cov ntaub ntawv peb tuaj yeem pom muaj qhov kub thiab txias:

/59A98F494C/temp 26.0

Kev zoo nkauj ntawm MQTT yog qhov nws tso cai rau peb sau npe rau tsuas yog cov ncauj lus uas peb txaus siab rau. Yog tias peb xav tau txais qhov ntsuas kub xwb, peb tuaj yeem sau npe rau /59A98F494C /temp ntsiab lus los ntawm kev siv cov lus txib hauv qab no:

$ mosquitto_sub -h koj_RPi_IP_address -t '/59A98F494C/temp'

…26.126.527.227.6…

Kauj ruam 5: Cov ntsiab lus

Ntsiab lus
Ntsiab lus

Peb tau qhia hauv qhov haujlwm no ib qho tseem ceeb kho vajtse thiab software los pib tsim lub zog qis, lub zog muaj txiaj ntsig, kev siv tshuab hauv tsev raws li WiFi. MQTT yog lub hauv paus tsim los rau cov txheej txheem ntau dua.

Cov kab ke software thiab cov kev pabcuam uas tuaj yeem koom ua ke nrog MQTT yog qhov loj heev! Muaj ntau txoj hauv kev zoo xws li Tsev Pabcuam, Node RED, Grafana, thiab lwm yam kom cia koj los nrog kev paub zoo ntawm cov neeg siv ntawm koj tus kheej. Tsis tsuas yog peb tuaj yeem ua cov ntawv luam tawm yooj yim ntawm qhov kub thiab txias, tab sis peb tuaj yeem muaj cov dashboards zoo pom cov ntaub ntawv thiab tswj hwm koj li khoom siv.

Tam sim no raws li peb muaj cov txheej txheem txheej txheem yooj yim hauv qhov chaw, lub ntuj yog peb qhov txwv ntawm lwm yam khoom siv WiFi peb tuaj yeem tsim siv IOT Cricket modules thiab ntxiv rau peb lub tshuab ua haujlwm hauv tsev.

Ua tsaug rau koj tuaj txog ntawm no. Peb vam tias koj nyiam qhov kev qhia no!

Tej Yam Ntawm Edge pab pawg

Kauj Ruam 6: Txog Peb

Yam Ntawm Ntug yog lub tuam txhab raws li hauv Cambridge, UK. Peb tsim cov roj teeb uas siv hluav taws xob qis tshaj plaws Cricket Wi-Fi module kom koj txuas tau ntau yam khoom siv hluav taws xob rau hauv xov tooj cua lossis lwm yam kev pabcuam hauv Is Taws Nem hauv feeb. Nws tsis xav tau ib lub programming thiab coding. Nws tso cai rau koj los ua ke koj cov khoom siv rau IOT cov kev pabcuam loj hauv MQTT thiab HTTP apis.

Pom zoo: