Cov txheej txheem:

Nano 33 IoT + EC/pH/ORP + WebAPK: 8 Kauj Ruam
Nano 33 IoT + EC/pH/ORP + WebAPK: 8 Kauj Ruam

Video: Nano 33 IoT + EC/pH/ORP + WebAPK: 8 Kauj Ruam

Video: Nano 33 IoT + EC/pH/ORP + WebAPK: 8 Kauj Ruam
Video: Gab’s Haven - Hydroponics pH and PPM/EC Automation 2024, Kaum ib hlis
Anonim
Nano 33 IoT + EC/pH/ORP + WebAPK
Nano 33 IoT + EC/pH/ORP + WebAPK

Los ntawm ufireFollow Ntau los ntawm tus sau:

Khaws thiab Duab EC/pH/ORP Cov Ntaub Ntawv nrog TICK Stack thiab NoCAN Platform
Khaws thiab Duab EC/pH/ORP Cov Ntaub Ntawv nrog TICK Stack thiab NoCAN Platform
Khaws thiab Duab EC/pH/ORP Cov Ntaub Ntawv nrog TICK Stack thiab NoCAN Platform
Khaws thiab Duab EC/pH/ORP Cov Ntaub Ntawv nrog TICK Stack thiab NoCAN Platform
IoT Pool Monitoring Nrog ThingsBoard
IoT Pool Monitoring Nrog ThingsBoard
IoT Pool Monitoring Nrog ThingsBoard
IoT Pool Monitoring Nrog ThingsBoard
IoT Hydroponics - Siv IBM's Watson rau ntsuas PH thiab EC
IoT Hydroponics - Siv IBM's Watson rau ntsuas PH thiab EC
IoT Hydroponics - Siv IBM's Watson rau ntsuas PH thiab EC
IoT Hydroponics - Siv IBM's Watson rau ntsuas PH thiab EC

Txog: Ntxiv lub peev xwm los ntsuas pH, ORP, EC lossis qab ntsev rau koj li Arduino lossis Raspberry Pi project. Xav paub ntau ntxiv txog ufire »

Ib lub cuab yeej los ntsuas EC, pH, ORP, thiab ntsuas kub. Nws tuaj yeem siv los tshuaj xyuas lub pas dej lossis teeb tsa hydroponic. Nws yuav sib txuas lus los ntawm Bluetooth Tsawg Zog thiab tso tawm cov ntaub ntawv ntawm lub vev xaib siv Web Bluetooth. Thiab kom muaj kev lom zem, peb yuav hloov qhov no mus rau hauv Progressive Web App uas koj tuaj yeem teeb tsa los ntawm lub vev xaib.

Kauj Ruam 1: Txhua Yam Lus No Yog Dab Tsi?

EC/pH/ORP/kub yog qee qhov ntsuas dej zoo tshaj plaws. Kev siv hluav taws xob (EC) tau siv hauv hydroponics txhawm rau ntsuas cov khoom noj muaj txiaj ntsig, pH seb cov dej acidic/theem pib yog li cas, thiab ORP tau siv los pab txiav txim siab lub peev xwm ntawm cov dej los tua nws tus kheej

  • Bluetooth Tsawg Zog yog lub wireless txheej txheem kom yooj yim xa thiab txais cov ntaub ntawv. Pawg Arduino siv hauv txoj haujlwm no yog Nano 33 IoT thiab los nrog WiFi thiab BLE cuam tshuam.
  • Web Bluetooth yog txheej APIs siv hauv Google Chrome browser (thiab Opera) uas tso cai rau lub vev xaib kom sib txuas lus ncaj qha nrog BLE lub cuab yeej.
  • Progressive Web Apps yog cov nplooj ntawv webpages uas ua haujlwm zoo li cov apps ib txwm muaj. Android thiab iPhone's tswj lawv sib txawv, thiab lawv sib txawv ntawm lub desktop, yog li koj yuav tsum tau nyeem me ntsis rau qhov tshwj xeeb.

Kauj ruam 2: Kho vajtse

Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse

Ua ntej peb tuaj yeem sib sau ua ke kho vajtse, muaj ib yam yuav tsum hais. UFire ISE sensor cov cuab yeej tuaj nrog tib I2C chaw nyob thiab peb siv ob, yog li ib qho yuav tsum tau hloov pauv. Txog qhov haujlwm no, peb yuav xaiv ib qho ntawm ISE cov laug cam thiab siv nws los ntsuas ORP. Ua raws cov theem ntawm no, hloov chaw nyob mus rau 0x3e.

Tam sim no qhov chaw nyob tau hloov pauv, muab kho vajtse ua ke tau yooj yim. Txhua lub cuab yeej ntsuas siv Qwiic txuas qhov txuas yog li tsuas yog txuas txhua yam ua ke hauv cov saw hlau. Koj yuav xav tau ib Qwiic rau Txiv neej xaim los txuas ib qho ntawm lub ntsuas hluav taws xob mus rau Nano 33. Cov xov hlau zoo ib yam thiab xim xim. Txuas dub rau Nano's GND, liab rau ib qho +3.3V lossis +5V tus pin, xiav rau SDA tus pin uas yog A4, thiab daj rau SCL tus pin ntawm A5.

Txog qhov haujlwm no, nws yuav cia siab tias cov ntaub ntawv ntsuas kub los ntawm EC sensor, yog li nco ntsoov xa lub ntsuas kub mus rau EC board. Txhua lub rooj tsavxwm muaj peev xwm ntsuas qhov kub thiab txias txawm hais tias. Tsis txhob hnov qab xa EC, pH thiab ORP sojntsuam mus rau qhov ntsuas tsim nyog. Lawv tau yooj yim txuas nrog BNC txuas.

Yog tias koj muaj lub thaiv, muab txhua yam tso rau hauv no yuav yog lub tswv yim zoo, tshwj xeeb tshaj yog xav tias dej yuav koom nrog.

Kauj ruam 3: Software

Cov software ib feem ntawm qhov no tau muab faib ua ob ntu tseem ceeb: firmware ntawm Nano 33, thiab lub vev xaib.

Qhov yooj yim ntws yog qhov no:

  • Lub vev xaib txuas rau Nano los ntawm BLE
  • Lub vev xaib xa cov lus txib raws li nug cov ntaub ntawv lossis nqis tes ua
  • Nano mloog cov lus txib ntawd, ua tiav lawv, thiab xa cov ntaub ntawv rov qab
  • Lub vev xaib tau txais cov lus teb thiab hloov kho UI raws li

Qhov teeb tsa no tso cai rau lub vev xaib ua txhua txoj haujlwm uas koj xav tau, xws li ntsuas lossis ntsuas ntsuas ntsuas.

Kauj Ruam 4: BLE Cov Kev Pabcuam thiab Tus Cwj Pwm

Ib qho ntawm thawj yam uas yuav tsum kawm yog lub hauv paus ntawm BLE ua haujlwm li cas.

Muaj ntau qhov sib piv, yog li cia khaws phau ntawv. Kev pabcuam yuav yog phau ntawv, thiab tus yam ntxwv yuav yog nplooj ntawv. Hauv "BLE phau ntawv" no, nplooj ntawv muaj ob peb yam tsis yog phau ntawv zoo li tuaj yeem hloov pauv qhov nplooj ntawv hais thiab tau txais kev ceeb toom thaum nws tshwm sim.

Ib lub cuab yeej BLE tuaj yeem tsim kev pabcuam ntau npaum li nws xav tau. Qee qhov tau txiav txim siab ua ntej thiab ua raws li txoj hauv kev rau kev siv cov ntaub ntawv nquag siv xws li Tx Hwj chim lossis poob kev sib txuas, rau ntau yam tshwj xeeb xws li Insulin lossis Pulse Oximetry. Koj tseem tuaj yeem ua ib qho thiab ua txhua yam koj xav tau nrog nws. Lawv tau piav qhia hauv software thiab tau txheeb xyuas nrog UUID. Koj tuaj yeem ua UUIDs ntawm no.

Hauv firmware rau lub cuab yeej no, muaj ib qho kev pabcuam, txhais raws li:

BLEService uFire_Service ("4805d2d0-af9f-42c1-b950-eae78304c408");

thiab ob yam ntxwv:

BLEStringCharacteristic tx_Characteristic ("50fa7d80-440a-44d2-967a-ec7731ec736a", BLENotify, 20);

BLEStringCharacteristic rx_Characteristic ("50fa7d80-440b-44d2-967b-ec7731ec736b", BLEWrite, 20);

Tx_Characteristic yuav yog qhov uas cov cuab yeej xa tawm cov ntaub ntawv, zoo li EC ntsuas, rau lub vev xaib kom pom. Rx_Characteristic yog qhov uas nws yuav tau txais lus txib los ntawm lub vev xaib kom ua tiav.

Txoj haujlwm no siv ArduinoBLE lub tsev qiv ntawv. Yog tias koj saib, koj yuav pom muaj ob peb qhov sib txawv tau tshaj tawm tus yam ntxwv. Txoj haujlwm no siv BLEStringCharacteristic vim tias peb yuav cuam tshuam nrog String type thiab nws yooj yim dua, tab sis koj kuj tseem tuaj yeem xaiv BLECharCharacteristic lossis BLEByteCharacteristic los ntawm ib nrab ntawm lwm tus.

Ib qho ntxiv, muaj qee yam khoom koj tuaj yeem muab tus yam ntxwv. tx_Characteristic muaj BLENotify ua qhov kev xaiv. Qhov ntawd txhais tau tias peb lub vev xaib yuav tau txais kev ceeb toom thaum tus nqi ntawm nws hloov pauv. rx_Characteristic muaj BLEWrite uas yuav tso cai rau peb lub vev xaib hloov kho nws. Muaj lwm tus.

Tom qab ntawd muaj me ntsis ntawm txoj cai-kua nplaum los khi txhua yam khoom no ua ke:

BLE.setLocalName ("uFire BLE");

BLE.setAdvertisedService (uFire_Service); uFire_Service.addCharacteristic (tx_Characteristic); uFire_Service.addCharacteristic (rx_Characteristic); BLE.addService (uFire_Service); rx_Characteristic.setEventHandler (BLEWritten, rxCallback); BLE.advertise ();

Nws yog ntau lossis tsawg tus piav qhia tus kheej, tab sis cia li kov ntawm ob peb lub ntsiab lus.

rx_Characteristic.setEventHandler (BLEWritten, rxCallback);

Puas yog qhov uas koj ua kom zoo ntawm kev ceeb toom ntawm tus nqi raug hloov. Kab ntawv qhia rau chav kawm kom ua haujlwm rxCallback thaum tus nqi raug hloov pauv.

BLE.advertise ();

yog dab tsi pib txhua yam mus. Ib lub cuab yeej BLE yuav xa tawm ib pob ntawv me me ntawm cov ntaub ntawv tshaj tawm tias nws nyob ntawd thiab muaj los txuas rau. Yog tsis muaj nws, nws yuav tsis pom.

Kauj ruam 5: Text Commands

Raws li tau hais ua ntej, lub cuab yeej no yuav tham nrog lub vev xaib los ntawm cov lus txib yooj yim. Txhua yam yog yooj yim los siv vim tias kev ua haujlwm nyuaj twb tau ua tiav lawm. UFire sensors tuaj nrog JSON thiab MsgPack raws lub tsev qiv ntawv rau xa thiab txais cov lus txib. Koj tuaj yeem nyeem ntxiv txog EC thiab ISE cov lus txib ntawm lawv nplooj ntawv cov ntaub ntawv.

Txoj haujlwm no yuav siv JSON vim tias nws yooj yim me ntsis los ua haujlwm nrog thiab nyeem tau, tsis zoo li MsgPack hom ntawv uas yog binary.

Nov yog qhov piv txwv ntawm yuav ua li cas nws txhua tus sib koom ua ke:

  • Lub vev xaib nug lub cuab yeej rau ntsuas EC los ntawm kev xa ec (lossis tshwj xeeb tshaj yog sau ec rau rx_Characteristic characteristic)
  • Lub cuab yeej tau txais cov lus txib thiab ua nws. Nws tom qab ntawd xa rov qab JSON kev teeb tsa cov lus teb ntawm {"ec": 1.24} los ntawm kev sau ntawv rau tx_Characteristic yam ntxwv.
  • Lub vev xaib tau txais cov ntaub ntawv thiab qhia nws

Kauj Ruam 6: Lub Vev Xaib

Lub vev xaib rau qhov haujlwm no yuav siv Vue.js rau pem hauv ntej-kawg. Tsis xav tau backend. Ib qho ntxiv, txhawm rau ua kom yooj yim me ntsis, tsis muaj kev tsim qauv siv. Nws tau faib ua cov ntawv ib txwm, js rau javascript, css rau CSS, cov cuab tam rau cov cim. Qhov html feem ntawm nws tsis muaj dab tsi tshwj xeeb. Nws siv bulma.io rau styling thiab tsim cov neeg siv interface. Koj yuav pom ntau hauv seem. Nws tau ntxiv txhua tus css thiab cov cim, tab sis kuj ntxiv ib kab tshwj xeeb.

Qhov ntawd yog thauj peb cov ntaub ntawv manifest.json uas yog dab tsi ua rau txhua yam khoom PWA tshwm sim. Nws tshaj tawm qee cov ntaub ntawv uas qhia rau peb lub xov tooj lub vev xaib no tuaj yeem hloov mus ua ib qho app.

Javascript yog qhov uas feem ntau ntawm yam txaus siab tshwm sim. Nws tau tawg mus rau hauv cov ntaub ntawv, app.js muaj cov hauv paus ntawm kev tau txais Vue lub vev xaib mus nrog txhua qhov cuam tshuam cuam tshuam nrog UI thiab ob peb yam ntxiv. ble.js muaj cov khoom siv bluetooth.

Kauj Ruam 7: Javascript thiab Web Bluetooth

Ua ntej, qhov no tsuas yog ua haujlwm ntawm Chrome thiab Opera. Kuv vam tias lwm qhov browser yuav txhawb nqa qhov no, tab sis vim li cas los xij, lawv tsis ua. Saib ntawm app.js thiab koj yuav pom cov tib UUIDs uas peb tau siv hauv peb cov firmware. Ib qho rau uFire Service, thiab ib qho rau tx thiab rx yam ntxwv.

Tam sim no yog tias koj saib hauv ble.js, koj yuav pom qhov txuas () thiab txiav tawm () ua haujlwm.

Kev sib txuas () ua haujlwm muaj qee qhov laj thawj los ua kom UI sib luag, tab sis nws feem ntau teeb tsa cov khoom kom xa thiab tau txais cov ntaub ntawv ntawm tus yam ntxwv.

Muaj qee qhov txawv txav thaum cuam tshuam nrog Web Bluetooth. Kev sib txuas yuav tsum tau pib los ntawm qee yam ntawm kev siv lub cev sib cuam tshuam, zoo li tapping lub pob. Koj tsis tuaj yeem txuas qhov program thaum lub vev xaib raug thauj khoom, piv txwv.

Txoj cai kom pib kev sib txuas zoo li no:

this.device = tos navigator.bluetooth.requestDevice ({

lim dej: [{namePrefix: "uFire"}], yeem siv tau: [this.serviceUuid]});

Cov ntxaij lim dej: thiab xaiv Cov kev pabcuam ntu xav tau kom tsis txhob pom txhua txhua BLE cov cuab yeej tawm sab nraud. Koj yuav xav tias tsuas yog ntu lim yuav zoo, tab sis koj kuj xav tau cov kev pabcuam tshwj xeeb ib yam nkaus.

Cov cai saum toj no yuav qhia txog kev sib tham sib tham. Nws yog ib feem ntawm Chrome interface thiab tsis tuaj yeem hloov pauv. Tus neeg siv yuav xaiv los ntawm daim ntawv teev npe. Txawm hais tias tsuas muaj ib lub cuab yeej app yuav txuas rau, tus neeg siv tseem xav tau los ntawm qhov kev sib tham xaiv no, vim muaj kev txhawj xeeb txog kev nyab xeeb.

Tus so ntawm txoj cai tau teeb tsa cov kev pabcuam thiab cov yam ntxwv. Nco ntsoov tias peb teeb tsa kev hu xov tooj ib txwm muaj, zoo ib yam li firmware tau ceeb toom hu rov qab:

kev pabcuam = tos server.getPrimaryService (this.serviceUuid);

tus yam ntxwv = tos kev pabcuam.getCharacteristic (this.txUuid); tos tus yam ntxwv.startNotifications (); characteristic.addEventListener ("yam ntxwv hloov pauv", this.value_update);

this.value_update tam sim no yuav raug hu ua txhua lub sijhawm muaj cov ntaub ntawv tshiab ntawm tus yam ntxwv tx.

Ib qho kawg uas nws ua yog teeb tsa lub sijhawm hloov kho cov ntaub ntawv txhua 5 vib nas this.

value_update () tsuas yog ua haujlwm ntev uas tos rau cov ntaub ntawv JSON tshiab los rau hauv thiab hloov kho UI nrog nws.

ec.js, ph.js, thiab orp.js muaj ntau txoj haujlwm me me uas xa tawm cov lus txib kom khaws cov ntaub ntawv thiab ntsuas cov cuab yeej.

Txhawm rau sim qhov no, koj yuav tsum nco ntsoov tias siv Web Bluetooth, nws yuav tsum tau ua haujlwm dhau HTTPS. Ib qho ntawm ntau txoj kev xaiv rau HTTPS tus neeg rau zaub mov hauv zos yog pabcuam-https. Nrog lub firmware tau tshaj tawm, txhua yam txuas nrog, thiab lub vev xaib tau txais kev pabcuam, koj yuav tsum muaj peev xwm pom txhua yam ua haujlwm.

Kauj Ruam 8: PWA Tshooj

PWA Part
PWA Part

Muaj ob peb kauj ruam tig lub vev xaib mus rau hauv qhov app tiag. Progressive Web Apps tuaj yeem ua ntau ntau dua li qhov haujlwm no siv rau.

  • Kev teeb tsa lub vev xaib
  • Thaum teeb tsa, nkag tau offline tuaj yeem ua tau
  • Pib thiab ua haujlwm raws li ib txwm app nrog ib txwm saib app icon

Txhawm rau pib, peb yuav tsum tsim cov pawg ntawm cov ntawv. Thawj yog cov ntaub ntawv manifest.json. Muaj ntau qhov chaw uas yuav ua qhov no rau koj, App Manifest Generator, yog ib tus ntawm lawv.

Ob peb yam kom nkag siab:

  • Daim ntawv thov yog qhov tseem ceeb. Kuv muab lub vev xaib no ntawm ufire.co/uFire-BLE/. Qhov ntawd txhais tau tias kuv daim ntawv thov yog /uFire-BLE /.
  • Pib URL tseem ceeb heev. Nws yog txoj hauv kev rau koj lub vev xaib tshwj xeeb nrog lub hauv paus sau twb tau xav lawm. Yog li vim tias kuv tso qhov no ntawm ufire.co/uFire-BLE/, qhov pib URL yog/uFire-BLE/ib yam nkaus.
  • Cov Zaub Hom yuav txiav txim siab li cas lub app zoo li, Kev tso tus kheej yuav ua rau nws zoo li yog ib txwm app yam tsis muaj Chrome khawm lossis interface.

Koj yuav xaus nrog cov ntaub ntawv json. Nws yuav tsum tau muab tso rau ntawm lub hauv paus ntawm lub vev xaib, nrog rau index.html.

Yam tom ntej koj yuav xav tau yog Tus Ua Haujlwm Pabcuam. Ib zaug ntxiv, lawv tuaj yeem ua tau ntau yam, tab sis txoj haujlwm no tsuas yog siv cov caching kom cia lub app no nkag mus tau offline. Kev ua haujlwm ntawm cov neeg ua haujlwm pabcuam feem ntau yog cov kav dej. Txoj haujlwm no tau siv Google piv txwv thiab hloov cov npe ntawm cov ntaub ntawv los khaws cia. Koj tsis tuaj yeem khaws cov ntaub ntawv sab nraum koj li.

Lub taub hau dhau mus rau FavIcon Generator thiab ua qee lub cim.

Qhov kawg yog ntxiv qee qhov chaws hauv Vue mounted () muaj nuj nqi.

mounted: muaj nuj nqi () {yog ('serviceWorker' hauv navigator) {navigator.serviceWorker.register ('service-worker.js'); }}

Qhov no yuav sau npe tus neeg ua haujlwm nrog qhov browser.

Koj tuaj yeem tshawb xyuas tias txhua yam ua haujlwm, thiab yog tias tsis yog, tej zaum xam pom vim li cas siv Lighthouse, nws yuav tshuaj xyuas qhov chaw thiab qhia koj txhua yam.

Yog tias txhua yam ua haujlwm, thaum koj mus rau lub vev xaib, Chrome yuav nug yog tias koj xav teeb tsa nws nrog lub chij popup. Koj tuaj yeem pom nws hauv kev ua ntawm ufire.co/uFire-BLE/ yog tias koj nyob ntawm Chrome mobile. Yog tias koj nyob ntawm lub desktop, koj tuaj yeem pom cov ntawv qhia zaub mov rau nruab nws.