Cov txheej txheem:

Kev Ntsuas Kub thiab Vaum: 6 Kauj Ruam (nrog Duab)
Kev Ntsuas Kub thiab Vaum: 6 Kauj Ruam (nrog Duab)

Video: Kev Ntsuas Kub thiab Vaum: 6 Kauj Ruam (nrog Duab)

Video: Kev Ntsuas Kub thiab Vaum: 6 Kauj Ruam (nrog Duab)
Video: Tseem Ev Lub Kawm - Koos Loos 2024, Hlis ntuj nqeg
Anonim
Kub thiab Vaum Xyuas
Kub thiab Vaum Xyuas
Kub thiab Vaum Xyuas
Kub thiab Vaum Xyuas

Hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas thiaj ua rau koj tus kheej ntsuas kub thiab av noo rau koj chav nyob. Cov cuab yeej tseem muaj peev xwm WiFi, rau lub hom phiaj ntawm kev txiav cov ntaub ntawv ntawm cov neeg rau zaub mov nyob deb (piv txwv li Raspberry Pi) thiab nkag mus rau nws tom qab los ntawm lub vev xaib yooj yim.

Qhov tseem ceeb ntawm lub cuab yeej yog ESP8266 microcontroller, DHT11 ntsuas kub thiab av noo thiab 16x4 cim LCD. Txoj haujlwm tau qhib tag nrho, yog li xav kom rub tawm cov txheej txheem, txheej txheem pawg thawj coj thiab tsim cov ntaub ntawv rau lub thawv ntawv thiab hloov pauv yam koj nyiam.

Kauj Ruam 1: Cov Cuab Yeej thiab Qhov Chaw

Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw
Cov Cuab Yeej thiab Qhov Chaw

Txhawm rau tsim lub monitor koj yuav xav tau cov hauv qab no:

1 x ESP-12F [2 €]-Raws li kuv paub ESP-12E thiab ESP-12F yeej zoo ib yam, nrog qhov sib txawv uas ESP-12F muaj lub kav hlau txais xov zoo dua.

1 x DHT11 Kub thiab Vaum Sensor [0.80 €] - DHT22 kuj tseem yuav ua haujlwm tab sis qee qhov kev hloov pauv yuav tsum tau ua ntawm 3D qauv ntawm lub thawv, DHT22 kuj tseem kim dua me ntsis.

1 x 16x4 Cim LCD 5V [3.30 €] - Yog lawm, koj yuav xav tau 5V ib qho raws li PCB tau tsim los kom lub LCD yuav raug ncaj qha los ntawm 5V ntau dua li qhov ntsuas hluav taws xob. Qhov no tau ua tiav txhawm rau txo qis kev thauj khoom ntawm qhov ntsuas hluav taws xob tab sis kuj vim tias 5V cov lus qhia zoo li pheej yig dua. Tab sis tsis txhob txhawj xeeb, txawm tias ESP8266 ua haujlwm ntawm 3.3V nws tseem yuav ua haujlwm zoo xwb.

1 x LD1117V33 SMD Voltage Regulator, tseem hu ua LD33 (SOT223 pob) [0.80 €]

1 x 100nF Ceramic SMD Capacitor (0603 pob)

1 x 10uF Tantalum SMD Capacitor (3528 pob)

1 x 10K SMD Resistor (0805 pob)

1 x 10K Trimmer Pot (Los ntawm lub qhov)

1 x 47Ω SMD Resistor (0805 pob) - Qhov no tsuas yog txwv qhov tam sim no uas mus rau lub teeb pom kev ntawm LCD. Xav tias yuav sim nrog qhov sib txawv tiv thaiv qhov tseem ceeb thiab xaiv qhov kev siv uas koj nyiam.

1 x SMD Momentary Hloov [0.80 €] - Qhov tshwj xeeb kuv siv yog qhov no, tab sis koj tuaj yeem siv txhua qhov hloov pauv ib ntus koj xav tau nrog tib lub hneev taw. Kuv kuj tseem tuaj yeem pom qhov hloov pauv tib yam ntawm eBay tsawg dua los ntawm kev tau txais ntau dua ib qho.

1 x 5.5x2.1mm DC Jack (Vaj Huam Sib Luag mount) [0.50 €] - Qhov kuv tau siv muaj 8mm vaj huam sib luag txiav tawm txoj kab uas hla thiab ntev 9mm. Nws tuaj yeem nrhiav tau yooj yim ntawm eBay los ntawm kev tshawb nrhiav "Vaj Huam Sib Luag Mount DC Jack" (saib daim duab txuas).

1 x 2.54mm (100mil) 40-pin Txiv neej Pin Header (Los ntawm qhov)

1 x 2.54mm (100mil) 40-pin Machined Female Pin Header (Los ntawm qhov)

1 x 2.54mm (100mil) Jumper - Nws zoo ib yam li cov uas siv hauv computer motherboards.

4 x M3 8mm Bolts

4 x M3 4x4mm Threaded Inserts - Lawv tuaj yeem nrhiav tau yooj yim los ntawm kev tshawb nrhiav "M3 Xovxwm -Hauv Tooj Tooj Tooj Tooj" ntawm eBay (saib daim duab txuas).

4 x M2 12mm Bolts

4x M2 Noob

1 x USB Hom A mus rau 5.5x2.1mm DC Plug Cable [1.5 €] - Qhov no yuav tso cai rau koj lub cuab yeej siv los ntawm tus qauv them lub xov tooj lossis zoo nkauj npaum li lub khoos phis tawj nrog USB chaw nres nkoj. Cov cuab yeej tsuas yog kos 300mA qhov phem tshaj thiab 250mA ntawm qhov nruab nrab, yog li txawm tias USB 2.0 chaw nres nkoj yuav ua.

1 x PCB - Lub rooj tsav xwm tuab tsis tseem ceeb, yog li tsuas yog mus rau 1.6mm uas feem ntau yog qhov kev xaiv pheej yig tshaj nrog cov tuam txhab PCB feem ntau.

3 x Daim Ntawv Ntawm Cov Hlau (li 60mm txhua)

3 x Daim Heatshrink Tubing (li 10 hli txhua)

Thiab cov cuab yeej hauv qab no:

Soldering Hlau

USB rau Serial Converter - Koj yuav xav tau qhov no rau kev ua haujlwm ESP8266 ntawm lub rooj tsavxwm.

Phillips Screwdriver thiab/lossis Hex Key - Nyob ntawm hom ntsia hlau koj yuav siv.

3D Tshuab Luam Ntawv - Yog tias koj tsis muaj lub tshuab luam ntawv 3D, koj ib txwm tuaj yeem siv lub thawv yas ua haujlwm zoo ib yam thiab txiav tawm koj tus kheej nrog Dremel. Qhov ntev sab hauv yam tsawg kawg nkaus rau lub thawv ntawv yuav tsum yog 24mm qhov siab, 94mm ntev thiab 66mm dav. Koj kuj tseem yuav tsum tau siv 8mm M2 sawv ntsug rau kev teeb tsa lub LCD.

Dremel - Tsuas yog xav tau yog tias koj tsis mus rau 3D luam ntawv thaiv.

Kauj Ruam 2: Ua PCB

Ua PCB
Ua PCB
Ua PCB
Ua PCB
Ua PCB
Ua PCB

Thawj kauj ruam yog ua kom PCB. Koj tuaj yeem ua li ntawd los ntawm kev kos nws koj tus kheej, lossis tsuas yog mus rau lub vev xaib ntawm koj lub chaw tsim khoom PCB nyiam thiab tso xaj. Yog tias koj tsis npaj yuav hloov pauv rau pawg thawj coj saib, koj tuaj yeem yooj yim lob ZIP cov ntaub ntawv uas muaj cov ntaub ntawv gerber txuas rau ntawm cov kauj ruam no thiab xa ncaj qha mus rau cov khw. Yog tias koj xav hloov pauv txawm li cas los xij, KiCAD cov txheej txheem thiab cov phiaj xwm txheej txheem cov ntaub ntawv tuaj yeem pom ntawm no.

Tom qab tau txais koj txhais tes ntawm cov laug cam nws yog lub sijhawm los muab cov khoom sib dhos tso rau hauv. Qhov no yuav tsum yooj yim dua, tab sis muaj qee yam uas yuav tsum tau sau tseg. Ua ntej, tsis txhob txuas cov PCB rau ntawm LCD lub taub hau tseem tsis tau, qhov no yuav tsum tau ua thaum lub rooj sib dhos zaum kawg vim yog txoj kev tsim lub thawv ntawv. Yog tias koj tab tom ua koj tus kheej lub tsev thaiv txawm tias koj xav tsis quav ntsej cov lus qhia ntawd.

U3 txuas yog qhov uas DHT11 lub cim xeeb yuav txuas nrog. Qhov zoo tshaj, koj yuav tsum siv 90 ° lub kaum ntse ntse machined poj niam tus pin header rau lub hom phiaj ntawd. Tab sis yog tias koj nyiam kuv tsis tuaj yeem nrhiav ib qho, tsuas yog tau txais ib qho ncaj thiab khoov koj tus kheej. Yog tias koj ua tom qab, cov coj ntawm DHT11 kuj tseem yuav luv me ntsis, yog li koj yuav tsum tau siv qee qhov txuas ntxiv. Qhov kev ncua deb nruab nrab ntawm tus pin header thiab lub sensor ib zaug txuas nrog yuav tsum yog kwv yees li 5mm.

Qhov laj thawj yog vim li cas koj thiaj xav siv lub tshuab taub hau ua haujlwm, vim tias lub qhov me me piv rau tus poj niam tus lej tus pin. Yog li, cov coj ntawm lub sensor tuaj yeem zaum qhov ntawd nruj tsim kom muaj kev sib txuas ruaj khov. Tab sis koj tseem tuaj yeem sim siv lub DHT11 ntawm ib qho ntawm tus txiv neej tus pin header thiab txuas nws txoj hauv kev ntawd mus rau ib tus poj niam tus pin tus pin header, uas yuav tsum ua haujlwm ib yam nkaus.

Kauj Ruam 3: Ua Daim Ntawv Thov

Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw
Ua daim ntawv kaw

Tam sim no tias PCB tau muag nws nws yog lub sijhawm los ua lub thaiv. Muaj ob qhov sib txawv uas yuav tsum tau luam tawm, lub cev tseem ceeb ntawm lub thawv ntawv thiab lub hau. Lub hau tseem muaj qhov txuas rau txuas rau ntawm koj phab ntsa.

Ob qhov tuaj yeem luam tawm nrog tus qauv 0.4mm lub taub hau ntawm 0.2 hli txheej siab, rau kuv cov ntaub ntawv luam tawm lub sijhawm kwv yees li 4 teev rau ob ntu ua ke. Lub hau tsis xav tau kev txhawb nqa ib feem tseem ceeb ntawm lub thawv ntim khoom txawm li cas los xij, feem ntau yog rau ib feem hauv qab cov ntsia hlau ntsaws. Tom qab luam ntawv ceev faj heev nrog tshem tawm cov kev txhawb nqa, Kuv tau tswj kom tawg ib qho ntawm qhov sawv ntsug rau LCD thaum ua qhov ntawd thiab yuav tsum tau lo nws rov qab nrog superglue.

Lub thawv ntawv tau tsim los ntawm FreeCAD, yog li yog tias koj xav hloov pauv nws yuav tsum yog qhov yooj yim dua. Cov ntaub ntawv STL rau luam tawm lub thawv ntawv nrog rau FreeCAD cov ntaub ntawv tsim muaj nyob ntawm Thingiverse.

Kauj Ruam 4: Sib dhos Tus Saib Xyuas

Nrog lub thawv ntawv luam tawm, lub sijhawm tso txhua yam ua ke. Ua ntej, tso lub LCD sab hauv rooj plaub thiab xaub nws mus rau sab laug, yog li yuav muaj qhov sib txawv nruab nrab ntawm nws thiab lub qhov rau lub ntsuas cua.

Duab
Duab

Tom ntej no, tso PCB rau sab saum toj ntawm nws, nrog lub sensor twb tau txuas rau ntawm tus pin header.

Duab
Duab

Tom qab ntawd, thawb lub sensor mus rau hauv lub qhov, xaub lub LCD rov qab mus rau txoj haujlwm thiab ntxig PCB rau ntawm tus pin header. Tam sim no kho lub LCD nyob hauv qhov chaw siv M2 txiv ntoo thiab ntsia liaj qhov rooj, thiab muab PCB txuas rau ntawm tus pin taub hau.

Duab
Duab

Tom ntej no, muab lub hwj chim tso rau hauv qhov chaw, txuas qee cov xov hlau rau nws thiab txuas lawv lwm qhov kawg rau PCB. Kev siv qee qhov heatshrink tubing ntawm no kuj yuav yog lub tswv yim zoo.

Duab
Duab

Kauj ruam kawg yog txhawm rau txhim kho cov hlau xov txuas kom lub hau tuaj yeem ntsia tau rau hauv qhov chaw nrog M3 ntsia liaj qhov rooj. Rau lub hom phiaj ntawd koj yuav tsum tau siv koj cov hlau txuas kom sov lawv, yog li lawv tuaj yeem raug thawb rau hauv lub qhov. Koj tuaj yeem saib ntawm cov lus qhia no yog tias koj xav tau cov ntaub ntawv ntau ntxiv txog kev ntxiv cov xov hlau rau koj li 3D luam tawm.

Duab
Duab

Kauj Ruam 5: Teeb Tus Server

Teeb Tus Neeg rau zaub mov
Teeb Tus Neeg rau zaub mov

Ua ntej rub tawm lub khoos phis tawj mus rau ESP8266 muaj ib qho ntxiv uas yuav tsum tau ua, uas yog teeb tsa tus neeg rau zaub mov rau txiav cov ntaub ntawv tau txais los ntawm lub cuab yeej. Rau lub hom phiaj ntawd koj tuaj yeem siv zoo nkauj ntau lub tshuab Linux uas koj xav tau, los ntawm Raspberry Pi ntawm koj tus kheej lub network mus rau DigitalOcean droplet. Kuv tau mus nrog tom qab, tab sis cov txheej txheem zoo ib yam nkaus li tsis muaj teeb meem dab tsi koj xaiv.

Txhim kho Apache, MySQL (MariaDB) thiab PHP

Ua ntej peb yuav tsum teeb tsa LAMP, lossis ua lwm yam lus nruab Apache, MySQL (MariaDB) thiab PHP ntawm tus neeg rau zaub mov. Txog qhov uas koj yuav tsum tau siv tus tswj hwm pob ntawm koj qhov kev cuam tshuam, rau qhov ua piv txwv kuv yuav siv apt uas yog tus thawj tswj hwm pob siv los ntawm ntau yam Debian raws li kev cuam tshuam, suav nrog Raspbian.

sudo apt hloov tshiab

sudo apt nruab apache2 mysql-server mysql-client php libapache2-mod-php php-mysql

Tom qab ua tiav, yog tias koj tso tus IP chaw nyob ntawm koj lub server rau hauv qhov chaw nyob ntawm koj tus browser koj yuav tsum muaj peev xwm pom nplooj ntawv tsis raug ntawm Apache.

Teeb lub database

Tam sim no peb xav tau cov ntaub ntawv khaws cia cov ntaub ntawv. Ua ntej, txuas rau MySQL li hauv paus los ntawm kev khiav, sudo siv mysql

Thiab tsim cov ntaub ntawv thiab tus neeg siv nkag mus rau nws raws li hauv qab no, Tsim DATABASE 'sensors'

Siv 'sensors'; CREATE TABLE `temperature` (` id `bigint (20) NOT NULL AUTO_INCREMENT,` client_id `smallint (6) NOT NULL,` value` smallint (6) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY id`)) ENGINE = InnoDB; CAB NTUJ TABLE `av noo '(` id' bigint (20) TSIS NULL AUTO_INCREMENT, `client_id` smallint (6) TSIS NULL, `value` smallint (6) NOT NULL,` created_at` timestamp TSIS NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY id`)) ENGINE = InnoDB; CREATE USER '[username]'@'localhost' IDENTIFIED BY '[password]'; ZOO TSHAJ PLAWS RAU 'sensor'.* TO 'sensors'@'localhost'; Tawm mus

Nco ntsoov hloov [username] thiab [password] nrog lub npe siv tiag tiag thiab tus password rau MySQL tus neeg siv uas koj nyiam. Tsis tas li, khaws cov ntawv ntawm lawv vim tias koj xav tau lawv rau qib tom ntej.

Kev teeb tsa cov ntawv txiav thiab lub vev xaib sib cuam tshuam

Hloov mus rau/var/www/html phau ntawv teev npe uas yog cov ntaub ntawv keeb kwm ntawm lub neej ntawd virtual host ntawm Apache, rho tawm cov ntawv HTML uas muaj lub vev xaib tsis raug thiab rub tawm cov ntawv nkag thiab web interface cov ntawv sau hauv nws.

cd/var/www/html

sudo rm index.html sudo wget https://raw.githubusercontent.com/magkopian/esp-arduino-temp-monitor/master/server/log.php sudo wget https://raw.githubusercontent.com/magkopian/esp- arduino-temp-monitor/master/server/index.php

Tam sim no hloov kho cov ntawv sau siv nano, sudo nano log.php

Koj yuav tsum tau hloov tus [username] thiab [password] nrog lub npe siv thiab tus lej siv rau MySQL tus neeg siv uas koj tau tsim hauv cov kauj ruam dhau los. Tsis tas li, hloov [tus yuam sij tus neeg siv khoom] nrog txoj hlua tshwj xeeb thiab sau nws. Qhov no yuav raug siv los ua tus password kom tus saib xyuas tuaj yeem txheeb xyuas nws tus kheej rau tus neeg rau zaub mov.

Thaum kawg, kho qhov index.php nrog nano, sudo nano index.php

thiab hloov [tus username] thiab [password] nrog lub npe siv thiab tus password rau MySQL tus neeg siv zoo li koj tau ua nrog cov ntawv sau.

Teeb HTTPS (Tsis teb los tau)

Qhov no yuav yog qhov xav tau, tab sis yog tias kev sib txuas ntawm ESP8266 thiab server tau hla Is Taws Nem nws tau pom zoo kom siv qee qhov encryption.

Hmoov tsis zoo, koj tsis tuaj yeem mus tom ntej thiab siv qee yam zoo li Let's Encrypt kom tau txais daim ntawv pov thawj. Qhov ntawd yog vim tsawg kawg ntawm lub sijhawm sau ntawv, HTTP cov tsev qiv ntawv rau ESP8266 tseem xav tau cov ntiv tes ntawm daim ntawv pov thawj kom muab ua qhov kev sib cav zaum ob thaum hu rau http.begin (). Qhov no txhais tau tias yog koj siv qee yam zoo li Let's Encrypt, koj yuav tsum rov ua dua lub firmware rau lub nti txhua 3 lub hlis txhawm rau hloov daim ntawv pov thawj ntiv tes tom qab rov ua dua tshiab.

Ib txoj hauv kev ib puag ncig ntawd, yuav yog los tsim daim ntawv pov thawj tus kheej uas tas sijhawm tom qab lub sijhawm ntev (piv txwv li 10 xyoo) thiab khaws cov ntawv sau ntawm nws tus kheej virtual host nrog nws tus kheej subdomain. Txoj kev ntawd, koj tuaj yeem muaj lub vev xaib cuam tshuam rau kev nkag mus rau cov ntaub ntawv ntawm tus kheej subdomain, uas yuav siv daim ntawv pov thawj tsim nyog los ntawm kev ntseeg siab. Kev siv daim ntawv pov thawj tus kheej hauv qhov xwm txheej no tsis yog teeb meem kev nyab xeeb, raws li cov ntiv tes ntawm daim ntawv pov thawj uas qhia tus kheej nws yuav nyuaj rau hauv lub firmware thiab daim ntawv pov thawj tsuas yog siv los ntawm ESP8266.

Ua ntej peb pib, Kuv yuav xav tias koj twb muaj tus tswv lub npe thiab koj muaj peev xwm los tsim subdomains ntawm nws. Yog li, txhawm rau tsim daim ntawv pov thawj uas tas sijhawm tom qab 10 xyoo khiav cov lus txib hauv qab no thiab teb cov lus nug.

sudo openssl req -x509 -nodes -days 3650 -newkey rsa: 2048 -keyout /etc/ssl/private/sensors.key -out /etc/ssl/certs/sensors.crt

Raws li qhov no yog daim ntawv pov thawj tus kheej uas koj teb rau feem ntau cov lus nug tsis muaj teeb meem ntau, tsuas yog rau lo lus nug uas nug txog Lub Npe Lub Npe. Nov yog qhov uas koj yuav tsum tau muab tag nrho cov subdomain uas yuav siv rau tus tswv tsev virtual no. Cov subdomain koj yuav muab ntawm no yuav tsum zoo ib yam nrog ServerName uas koj yuav teeb tsa tom qab hauv koj li kev teeb tsa tus tswv tsev virtual.

Tom ntej no tsim tus txheej txheem host tshiab tshiab, sudo nano /etc/apache2/sites-available/sensors-ssl.conf

nrog cov ntsiab lus hauv qab no, ServerName [subdomain] DocumentRoot/var/www/sensors SSLEngine ON SSLCertificateKeyFile /etc/ssl/private/sensors.key SSLCertificateFile /etc/ssl/certs/sensors.crt Options +FollowSymlinks -Indexes AllowOverride All ErrorLog $ {APACHE_LOG- sensors error-ssl.log CustomLog $ {APACHE_LOG_DIR} /sensors-access-ssl.log ua ke

Ib zaug ntxiv, nco ntsoov hloov [subdomain] nrog tib subdomain uas koj tau siv nrog daim ntawv pov thawj. Txij ntawm no mus koj yuav tsum tau lov tes taw lub neej ntawd virtual host ntawm Apache, sudo a2dissite 000-default

hloov lub npe ntawm cov ntawv teev npe hauv paus, sudo mv/var/www/html/var/www/sensors

thiab thaum kawg ua kom muaj tus tswv tsev tshiab tshiab thiab rov pib dua Apache, sudo a2ensite sensors-ssl

sudo systemctl rov pib dua apache2

Qhov kawg uas yuav tsum tau ua yog kom tau txais cov ntiv tes ntawm daim ntawv pov thawj, vim tias koj yuav tsum tau siv nws hauv cov lej firmware.

openssl x509 -noout -fingerprint -sha1 -inform pem -in /etc/ssl/certs/sensors.crt

Http.begin () cia siab tias tus delimiters nruab nrab ntawm bytes ntawm cov ntiv tes kom yog qhov chaw, yog li koj yuav tsum tau hloov cov colons nrog qhov chaw ua ntej siv nws hauv koj cov cai.

Tam sim no, yog tias koj tsis xav siv daim ntawv pov thawj tus kheej rau lub vev xaib cuam tshuam teeb tsa lub subdomain tshiab thiab tsim kev teeb tsa tus tswv tshiab tshiab, sudo nano /etc/apache2/sites-available/sensors-web-ssl.conf

nrog cov ntsiab lus hauv qab no, ServerName [subdomain] DocumentRoot/var/www/sensors #SSLEngine ON #SSLCertificateFile /etc/letsencrypt/live/[subdomain]/cert.pem #SSLCertificateKeyFile /etc/letsencrypt/live/[subdomain]/privkey.pem #SSLCertificateChain /letsencrypt/live/[subdomainownload/chain.pem Options +FollowSymlinks -Indexes AllowOverride Txhua ErrorLog $ {APACHE_LOG_DIR} /sensors-web-error-ssl.log CustomLog $ {APACHE_LOG_DIR} /sensors-web-access-ss.lib

Nco ntsoov hloov [subdomain] nrog subdomain uas koj tau teeb tsa rau lub vev xaib interface. Tom ntej no qhib tus tswv tsev tshiab, rov pib dua Apache, teeb tsa certbot thiab tau txais daim ntawv pov thawj rau tus subdomain tshiab los ntawm Let's Encrypt, sudo a2ensite sensors-web-ssl

sudo systemctl rov pib dua apache2 sudo apt hloov tshiab sudo apt nruab certbot sudo certbot certonly --apache -d [subdomain]

Tom qab tau txais daim ntawv pov thawj hloov kho tus tswv tsev teeb tsa dua kom tsis suav nrog SSLEngine, SSLCertificateFile, SSLCertificateKeyFile thiab SSLCertificateChainFile kab, thiab rov pib dua Apache.

Thiab tam sim no koj tuaj yeem siv thawj subdomain uas siv daim ntawv pov thawj tus kheej rau xa cov ntaub ntawv los ntawm ESP8266 mus rau tus neeg rau zaub mov, thaum siv qhov thib ob rau kev nkag mus rau lub vev xaib interface los ntawm koj tus browser. Certbot tseem yuav saib xyuas qhov txuas txuas txuas ntxiv koj Let's Encrypt daim ntawv pov thawj txhua 3 lub hlis, siv lub systemd timer uas yuav tsum tau qhib los ntawm lub neej ntawd.

Kauj Ruam 6: Programming ESP8266

Kev ua haujlwm ESP8266
Kev ua haujlwm ESP8266

Thaum kawg, tsuas yog sab laug ua yog txhawm rau thauj lub firmware ntawm lub microcontroller. Txhawm rau ua li ntawd, rub tawm qhov chaws rau lub khoos phis tawm los ntawm no thiab qhib nws siv Arduino IDE. Koj yuav tsum tau hloov [SSID] thiab [Password] nrog SSID tiag tiag thiab tus lej zais ntawm koj lub network WiFi. Koj kuj tseem yuav tsum tau hloov [Client ID] thiab [Client Key] ntawm kev ua haujlwm sprintf hu nrog cov uas koj siv ntawm PHP tsab ntawv ntawm tus neeg rau zaub mov. Thaum kawg, koj yuav tau hloov tus [Tus tswv] nrog lub npe lossis tus IP chaw nyob ntawm tus neeg rau zaub mov. Yog tias koj siv HTTPS koj tseem yuav xav muab cov ntiv tes ntawm koj daim ntawv pov thawj raws li kev sib cav zaum ob ntawm kev ua haujlwm ntawm http.begin (). Kuv tau piav qhia yuav ua li cas thiaj li tau txais cov ntiv tes ntawm daim ntawv pov thawj ntawm ntu "Teeb Up HTTPS" ntawm cov kauj ruam dhau los.

Tom ntej no, yog tias koj tseem tsis tau nyob ntawd koj yuav tsum tau teeb tsa ESP8266 Lub zej zog cov pob khoom siv Tus Thawj Saib Xyuas Haujlwm ntawm Arduino IDE. Thaum qhov no ua tiav, xaiv NodeMCU 1.0 (ESP-12E Module) los ntawm cov laug cam. Tom ntej no, koj yuav tsum teeb tsa lub tsev qiv ntawv SimpleDHT siv Tus Thawj Saib Xyuas Tsev Qiv Ntawv. Thaum kawg, ntaus lub pob Txheeb Xyuas ntawm lub kaum sab saud sab saud ntawm koj lub qhov rai IDE kom paub tseeb tias cov cai sau ua ke yam tsis muaj qhov yuam kev.

Thiab tam sim no, nws yog lub sijhawm kawg los hlawv cov firmware rau lub microcontroller. Txhawm rau ua li ntawd txav lub jumper JP1 ntawm sab xis, yog li GPIO0 ntawm ESP8266 yuav txuas nrog hauv av uas yuav ua rau lub hom phiaj ua haujlwm. Tom qab ntawd, txuas koj lub USB rau kev hloov pauv txuas uas siv cov xov hluav taws xob txuas mus rau lub npe kab ntawv uas tau sau ua P1. Tus pin 1 ntawm lub cajmeem lub npe yog hauv av, tus pin 2 yog tus tau txais tus pin ntawm ESP8266 thiab tus pin 3 tus xa tawm. Koj xav tau qhov tau txais ESP8266 mus rau qhov xa tawm ntawm koj lub USB mus rau cov hloov pauv, xa mus rau qhov tau txais thiab ntawm chav kawm rau hauv av.

Thaum kawg, siv lub cuab yeej nrog 5V siv koj lub USB rau DC txuas cable thiab txuas USB rau hloov pauv mus rau koj lub khoos phis tawj. Tam sim no koj yuav tsum tuaj yeem pom qhov chaw nres nkoj virtual uas ESP8266 txuas nrog, sai li sai tau thaum koj qhib cov cuab yeej ntawv qhia zaub mov ntawm koj li IDE. Tam sim no, tsuas yog nyem lub pob Upload thiab qhov ntawd yog nws! Yog tias txhua yam mus raws li qhov xav tau koj yuav tsum tuaj yeem pom qhov ntsuas kub thiab av noo ntawm LCD ntawm lub cuab yeej. Tom qab ESP8266 txuas rau koj lub network thiab pib sib txuas lus nrog tus neeg rau zaub mov, hnub tim thiab sijhawm tam sim no yuav tsum tshwm ntawm lub vijtsam.

Tom qab ob peb teev thaum tus neeg rau zaub mov yuav tau khaws cov ntaub ntawv zoo koj yuav tsum tuaj yeem pom qhov ntsuas kub thiab av noo los ntawm kev mus ntsib http (s): // [host] /index.php?client_id= [tus lej ID]. Qhov twg [tus tswv] yog tus IP chaw nyob ntawm koj tus neeg rau zaub mov lossis cov subdomain koj tab tom siv rau lub vev xaib, thiab [tus neeg siv khoom] tus neeg siv tus lej ntawm lub cuab yeej uas yog tias koj tso nws rau nws qhov txiaj ntsig nws yuav tsum yog 1.

Pom zoo: