Cov txheej txheem:

NODEMCU LUA ESP8266 Txuas rau MySQL Database: 6 Kauj Ruam
NODEMCU LUA ESP8266 Txuas rau MySQL Database: 6 Kauj Ruam

Video: NODEMCU LUA ESP8266 Txuas rau MySQL Database: 6 Kauj Ruam

Video: NODEMCU LUA ESP8266 Txuas rau MySQL Database: 6 Kauj Ruam
Video: NodeMCU V3 ESP8266 - обзор, подключение и прошивка в Arduino IDE 2024, Kaum ib hlis
Anonim
NODEMCU LUA ESP8266 Txuas rau MySQL Database
NODEMCU LUA ESP8266 Txuas rau MySQL Database
NODEMCU LUA ESP8266 Txuas rau MySQL Database
NODEMCU LUA ESP8266 Txuas rau MySQL Database
NODEMCU LUA ESP8266 Txuas rau MySQL Database
NODEMCU LUA ESP8266 Txuas rau MySQL Database

Cov lus qhia no tsis yog rau cov neeg qaug zog vim nws siv XAMPP (Apache, MySQL & PHP), HTML thiab tau kawg LUA. Yog tias koj muaj kev ntseeg siab ntawm kev daws cov no, nyeem ntawm no!

Kuv siv XAMPP vim nws tuaj yeem teeb tsa ntawm tus cwj mem lossis koj lub hard drive thiab nws tau teeb tsa kom khiav tam sim. Muaj lwm qhov WAMP (rau Windows) thiab LAMP (rau Linux) cov servers tawm uas yuav ua haujlwm ib yam nkaus thiab yog tias koj muaj lub siab tawv tiag, koj tuaj yeem teeb tsa server los ntawm kos!

Koj tuaj yeem tau txais XAMPP ntawm no:

TSWV YIM: Hloov pauv index.php thiab index.html rau qee yam xws li index1.php thiab index1.html kom koj tau txais cov npe ntawm cov haujlwm hauv browser, ntau dua li nws dhia mus rau XAMPP pib qhov screen.

Kauj Ruam 1: Txhim Kho thiab Khiav XAMPP

Txhim Kho thiab Khiav XAMPP
Txhim Kho thiab Khiav XAMPP

Thaum koj tau rub tawm XAMPP, ua raws cov lus qhia ntawm kev teeb tsa thiab thaum koj ua tiav koj yuav tsum tau pib cov ntxaij vab tshaus zoo li cov saum toj no. Koj yuav tsum pib Apache thiab MySql rau LUA txoj haujlwm kom ua haujlwm.

L: / xampp / xampp-control.exe

Hloov daim ntawv tsav (L:) mus rau txhua qhov chaw koj tau teeb tsa XAMPP.

Kauj ruam 2: MySQL

MySQL
MySQL

Thaum koj muaj Apache & MySQL khiav pib cmd.exe thiab tom qab ntawd ntaus ntawv

L: thiab RETURN qhov tseem ceeb - lossis txhua qhov chaw koj tau teeb tsa XAMPP (L yog tsab ntawv tsav rau kuv tus cwj mem tsav koj li tej zaum yuav txawv)

ces

CD xampp / mysql / bin thiab RETURN qhov tseem ceeb.

Pib MySql los ntawm kev ntaus qhov no ntawm DOS tam sim (raws li saud).

mysql -u hauv paus -p

tom qab ntawv nyem RETURN thaum nug tus password.

Tom qab ntawd koj tuaj yeem siv cov ntawv sau hauv qab no thiab koj yuav tsum pom qee yam zoo li saum toj no.

USE xeem

QHIA TABLE YOG TUS NEEG YUAV TSUM sau; CREATE TABLE writeread (logdata datetime, teb varchar (20), tus nqi loj (20)); INSERT INTO sau ntawv (logdata, teb, tus nqi) VALUES ('2017-01-01 06:30:10', '24', '67'); SELECT * LOS NTAWM sau ntawv;

Kuv tau siv cov npe hauv paus yam tsis muaj tus password thiab cov ntaub ntawv ntsuas los tsim kuv lub rooj. Nov yog tus txheej txheem teeb tsa rau MySQL uas tsis muaj kev nyab xeeb ua haujlwm.

Kauj Ruam 3: Cov Ntaub Ntawv PHP

Cov ntaub ntawv PHP
Cov ntaub ntawv PHP
Cov ntaub ntawv PHP
Cov ntaub ntawv PHP

Muaj 2 cov ntaub ntawv suav nrog, 1 sau cov ntaub ntawv mus rau lub rooj database thiab 1 nyeem nws rov qab thiab tso tawm hauv qhov browser.

Vim muaj kev ruaj ntseg, PHP cov ntaub ntawv tsis raug tso rau hauv lub xaib no, yog li thaum koj rub tus nyeem ntawv.txt thiab tus kws sau ntawv.txt, hloov lawv mus rau tus nyeem ntawv.php thiab tus sau ntawv.php, thiab thauj lawv mus rau hauv htdocs nplaub tshev ntawm XAMPP.

Koj tuaj yeem sim yog tias writer.php ua haujlwm los ntawm kev ntaus ntawv

localhost/writer.php? teb = 7 & tus nqi = 3

lossis 127.0.0.1/writer.php?field=7&value=3

mus rau hauv qhov browser thiab yog tias txhua yam ua haujlwm koj yuav tsum tau txais kev nkag mus ntxiv hauv cov lus database.

Txoj haujlwm nyeem ntawv.php teev tawm txhua kab ntawm lub rooj rau hauv koj tus browser. Khiav qhov program no los ntawm ob npaug nyem nws hauv qhov browser lossis los ntawm kev ntaus ntawv

localhost/nyeem ntawv.php

lossis 127.0.0.1/reader.php

mus rau qhov chaw nyob bar ntawm qhov browser.

Kauj Ruam 4: LUA Cov Ntaub Ntawv

LUA File
LUA File
LUA File
LUA File

Cov ntaub ntawv jlwriter.lua yuav tsum yog ntawm ESP8266. Kuv siv nws ntawm WeMos version, tab sis tsis muaj laj thawj vim li cas nws yuav tsum tsis ua haujlwm ntawm ib qho ESP8266.

Yog tias koj tseem nrog kuv thiab txhua yam tau ua haujlwm, koj yuav tsum pom ib qho screen zoo li saum toj no.

TSWV YIM: Thaum siv MySQL nias F3 txuag koj ntaus hauv tag nrho tsab ntawv dua.

Hauv LUA qhov kev hloov pauv (kab 29) rau IP chaw nyob ntawm txhua yam koj lub PC siv los txuas rau koj lub router lossis modem.

conn: txuas (80, '192.168.0.10')

Ntaus ipconfig rau hauv Command prompt (cmd.exe) kom pom koj tus IP chaw nyob.

Kauj ruam 5: Kho kom raug Code

Kho kom raug Code
Kho kom raug Code

Kuv pom tus lej zoo editor yog Notepad ++ uas tuaj yeem rub tawm ntawm no

notepad-plus-plus.org/

Nws tuaj yeem siv nrog ntau yam lus sib txawv lossis cov ntawv sau thiab nws yog pub dawb.

Kuv tau suav nrog teeb tsa.txt los teeb tsa koj li MySQL cov lus yog tias koj xav siv PHP los ua nws tsis yog txoj hauv kev saum toj no.

Ib zaug ntxiv koj yuav tsum tau hloov lub npe cov ntaub ntawv rau setup.php, tom qab ntawv luam nws mus rau hauv htdocs nplaub tshev.

Ceev faj tias khiav cov ntaub ntawv no yuav tshem tawm cov lus yav dhau los thiab cov ntaub ntawv.

Kauj Ruam 6: Xaus

Qhov no tau qhia yooj yim dua, tab sis thaum kawg kuv tau ua kom nws ua haujlwm. Hauv lub vev xaib, muaj qee qhov haujlwm uas zoo ib yam rau qhov no, tab sis lawv tau sau rau DHT22 sensor. Tom qab sim cov phiaj xwm no nrog qhov ua tsis tiav, Kuv txiav txim siab sau txhua yam kuv tuaj yeem pom txog MySQL sau hauv LUA thiab pib los ntawm kos. Tom qab kev sim ntau thiab ua yuam kev, kuv tuaj nrog qhov no. Kuv tau siv Apache, MySQL, PHP thiab HTML yav dhau los, yog li muaj kev nkag siab txog tias sab ntawd ua haujlwm li cas.

Cov haujlwm no tsuas yog khawb qhov ntawm qhov koj tuaj yeem ua thaum txuas nrog MySQL database. Nws ua rau koj sau cov ntaub ntawv thiab khaws nws ntawm koj tus kheej lub PC ntau dua li qee tus neeg rau zaub mov tsis paub. Kuv vam tias muaj txaus nyob ntawm no los muab rau koj saj rau yam uas tuaj yeem ua tiav nrog cov kev ua haujlwm zoo no.

Pom zoo: