Cov txheej txheem:

Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Qhov Rooj Kom Txuas Koj Arduino rau IP Network?: 11 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Qhov Rooj Kom Txuas Koj Arduino rau IP Network?: 11 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Qhov Rooj Kom Txuas Koj Arduino rau IP Network?: 11 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Qhov Rooj Kom Txuas Koj Arduino rau IP Network?: 11 Kauj Ruam (nrog Duab)
Video: Computer Vision with Python! Resizing Images 2024, Hlis ntuj nqeg
Anonim
Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Gateway los Txuas Koj Arduino rau IP Network?
Yuav Ua Li Cas Rau Koj Tus Kheej WIFI Gateway los Txuas Koj Arduino rau IP Network?

Raws li muaj coob tus neeg koj xav tias Arduino yog ib qho kev daws teeb meem zoo los ua tsev automationand neeg hlau

Tab sis nyob rau lub sijhawm ntawm kev sib txuas lus Arduinos tsuas yog tuaj nrog cov ntawv txuas.

Kuv tab tom ua haujlwm ntawm tus neeg hlau uas yuav tsum tau txuas nrog mus tas li nrog lub server uas siv cov txuj ci txawj ntse. Kuv sim siv RF network li kuv tau siv los ua rau neeg txawv tebchaws tab sis nws tsis muaj txiaj ntsig txaus. Raws li tus neeg hlau txav kuv tsis tuaj yeem siv Ethernet Arduino Shield. Arduino Wifi Shield yog kim thiab zoo li kuv yog tus tsim qub.

Kuv xav tau qee yam uas tuaj yeem sib pauv cov ntaub ntawv hauv txoj hauv kev yooj yim heev thiab muaj txiaj ntsig zoo nrog lub server.

Tias yog vim li cas kuv thiaj txiav txim siab tsim Lub Rooj vag raws qhov pheej yig heev thiab lub zog txuag ESP8266 microcontroller

Ntawm no koj tuaj yeem pom yuav ua li cas tsim cov khoom siv hluav taws xob thiab rub tawm software.

Kuv siv lub rooj vag no rau Tsev automation thiab rau Robotic.

Qhov no siv ib feem ntawm kev tsim kho vaj tsev hauv tsev thoob ntiaj teb koj tuaj yeem saib ntawm no

Kuv tau ua lwm cov lus qhia uas siv ESP8266 daim ntaub thaiv thiab zam kev siv tshuaj yaj yeeb

Khoom siv

Kuv tau sau lwm cov lus qhia ntawm lub ncauj lus no

Kauj Ruam 1: Nws Ua Haujlwm Li Cas?

Nws Ua Haujlwm Li Cas?
Nws Ua Haujlwm Li Cas?

Lub Rooj Vag yog ua raws tus qauv ESP8266

Cov qauv no txuas nrog los ntawm ib sab nrog txuas txuas los ntawm lwm sab mus rau IP network nrog Wifi.

Nws ua raws li lub thawv dub. Cov ntaub ntawv ntim los ntawm kab ntawv txuas tau xa mus rau IP/Udp chaw nres nkoj thiab vis et versa.

Koj tsuas yog yuav tsum teeb tsa koj tus kheej teeb tsa (IP, WIFI…) ib zaug thawj zaug koj yuav ua lub zog ntawm Lub Rooj vag.

Nws tuaj yeem hloov cov ntaub ntawv raw ASCII thiab cov ntaub ntawv binary (tsis muaj HTTP, JSON …)

Nws yog tsim los txuas cov khoom nrog cov neeg siv khoom hauv tsev ua cov software uas xav tau nrawm thiab nquag hloov pauv ntawm cov ntawv luv luv.

Nws yog qhov yooj yim siv nrog Arduino Mega uas muaj ntau dua ib qho UART (Arduino Mega piv txwv) tab sis tuaj yeem ua haujlwm nrog UNO.

Kauj Ruam 2: Lub luag haujlwm tseem ceeb yog dab tsi?

Feem ntau nws yog lub thawv dub uas hloov pauv thiab xa cov ntaub ntawv xa mus rau UDP pob ntawv hauv ob txoj hauv kev.

Nws muaj 3 LED uas qhia txog xwm txheej thiab kev mus los ntawm Lub Rooj vag.

Nws muab GPIO uas tuaj yeem siv los ntawm Arduino tos rau Lub Rooj vag kom ua WIFI thiab IP txuas nrog.

Nws khiav hauv 3 hom sib txawv uas tau teeb tsa nrog kev hloov pauv:

  • Rooj vag hom uas yog hom qub
  • Kev teeb tsa hom siv los teeb tsa qhov ntsuas
  • Debug hom uas yog rau hom debuging

Feem ntau ntawm qhov tsis tuaj yeem hloov kho kom haum rau koj cov kev xav tau.

Kauj Ruam 3: Tsim Cov Khoom

Tsim Cov Khoom
Tsim Cov Khoom

Nyob saum koj Arduino koj yuav xav tau

  • 1 x ESP8266 module-Kuv xaiv MOD-WIFI-ESP8266-DEV los ntawm Olimex uas raug nqi ib puag ncig 5 euros uas yooj yim siv.
  • 1x5v zog
  • 1 x 3.3v lub zog tswj hwm - Kuv siv LM1086
  • 1 x 100 microfarad capacitor
  • 1 x ULN2803 APG module (tuaj yeem hloov los ntawm 3 x transistors)
  • 8 x resistors (3 x 1K, 1 x 2K, 1 x 2.7k, 1x 3.3K, 1x 27K, 1x 33k)
  • 3 x LED (liab, ntsuab, xiav)
  • 1 x Breadboard PCB
  • qee cov xov hlau thiab cov txuas

Thaum lub sij hawm tsim tsev xwb, koj yuav tsum tau

  • 1 x FTDI 3.3v rau kev teeb tsa
  • Soldering hlau thiab tin

Ua ntej yuav tshuaj nws yog ib qho tseem ceeb kom teeb tsa txhua yam khoom siv ntawm lub khob cij thiab xyuas txhua yam yog ua tau.

Kauj Ruam 4: Cia Pib Nrog Cov Hluav Taws Xob ntawm Breadboard

Cia Peb Pib Nrog Cov Hluav Taws Xob ntawm Breadboard!
Cia Peb Pib Nrog Cov Hluav Taws Xob ntawm Breadboard!

Cov txheej txheem hluav taws xob muaj nyob hauv Fritzing hom

Koj tuaj yeem rub nws ntawm no cov kauj ruam 1:

github.com/cuillerj/Esp8266IPSerialGateway/blob/master/GatewayElectronicStep1.fzz

Tsuas yog ua raws li schema los ntawm kev saib xyuas rau qhov hluav taws xob.

Nco ntsoov tias ESP8266 tsis txhawb qhov siab dua 3.3v. FTDI yuav tsum tau teeb tsa rau 3.3v.

Kauj Ruam 5: Cia Peb Mus Rau Software

Cia peb mus rau Software!
Cia peb mus rau Software!

Cia peb pib nrog Rooj vag sab

Kuv tau sau cov cai nrog Arduino IDE. Yog li koj xav tau ESP8266 kom paub tias yog pawg thawj coj los ntawm IDE. Xaiv lub rooj tsav xwm tsim nyog nrog Cov Cuab Yeej / cov ntawv qhia zaub mov.

Yog tias koj tsis pom ib qho ESP266 hauv cov npe uas txhais tau tias koj yuav tsum tau teeb tsa ESP8266 Arduino Addon (koj tuaj yeem pom ntawm no tus txheej txheem).

Txhua tus lej koj xav tau muaj nyob ntawm GitHub. Nws yog lub sijhawm los rub nws!

Txoj cai tseem ceeb ntawm Lub Rooj vag nyob ntawd:

Nyob rau sab saum toj ntawm tus qauv Arduino thiab ESP8266 suav nrog cov cai tseem ceeb xav tau 2 qhov no suav nrog: LookFoString uas yog siv los tswj cov hlua thiab nyob ntawd:

ManageParamEeprom uas tau siv los nyeem thiab khaws cov khoom hauv Eeprom ans nyob ntawd:

Thaum koj tau txais tag nrho cov cai nws yog lub sijhawm rub nws mus rau hauv ESP8266. Ua ntej tshaj txuas FTDI mus rau USB chaw nres nkoj ntawm koj lub computer.

Kuv xav kom koj txheeb xyuas qhov kev sib txuas ua ntej sim rub tawm.

  • Teem Arduino cov saib txuas mus rau qhov chaw nres nkoj USB tshiab.
  • Teem qhov nrawm rau 115200 ob qho tib si cr nl (tiv thaiv ceev rau Olimex)
  • Lub zog ntawm lub khob cij (ESP8266 los nrog software uas cuam tshuam nrog AT cov lus txib)
  • Xa "AT" nrog cov cuab yeej txuas.
  • Koj yuav tsum tau txais "OK" rov qab.

Yog tias tsis txheeb xyuas koj qhov kev sib txuas thiab saib koj li ESP8266 cov lus qhia tshwj xeeb.

Yog tias koj tau txais "OK" koj tau npaj txhij xa cov cai

  • Hwj chim tawm ntawm lub khob cij, tos ob peb feeb,
  • nias rau ntawm micro-swith dub ntawm ESP8266. Nws yog qhov ib txwm tau txais qee cov thoob khib nyiab ntawm cov saib.
  • Nias ntawm qhov upload IDE raws li rau Arduino.
  • Tom qab rub tawm tiav teeb tsa qhov nrawm rau 38400.

Koj yuav pom qee yam zoo li hauv daim duab.

Nrog koj zoo siab ua tiav upload cov cai!

Kauj Ruam 6: Cia Peb Ua Tus Txheej Txheem

Cia Peb Ua Tus Txheej Txheem!
Cia Peb Ua Tus Txheej Txheem!

ConfigGPIO yuav tsum tau teeb tsa rau 1 rau nkag mus rau hauv kev teeb tsa hom

Thaum xub luam WIFI los ntawm kev nkag mus rau qhov hais kom ua: ScanWifi. Koj yuav pom cov npe ntawm lub network pom.

  • Tom qab ntawd teeb tsa koj tus SSID los ntawm kev nkag mus "SSID1 = yournetwork"
  • Tom qab ntawv teeb koj tus password los ntawm kev nkag "PSW1 = yourpassword"
  • Tom qab ntawd nkag mus "SSID = 1" txhawm rau txheeb xyuas lub network tam sim no
  • Nkag mus "Rov pib dua" txhawm rau txuas Lub Rooj vag rau koj WIFI.
  • Koj tuaj yeem txheeb xyuas koj tau txais tus IP los ntawm kev nkag mus "ShowWifi".
  • Lub xiav LED yuav nyob thiab lub LED liab ntsais muag.

Nws yog lub sijhawm los txheeb xyuas koj tus IP chaw nyob server los ntawm kev nkag mus rau 4 subaddresses (server uas yuav khiav Java txoj cai xeem). Piv txwv li:

  • "IP1 = 192"
  • "IP2 = 168"
  • "IP3 = 1"
  • "IP4 = 10"

Kauj ruam kawg uas yuav tsum tau ua yog teeb tsa UDP server mloog chaw nres nkoj los ntawm kev nkag mus "listenPort = xxxx".

Nkag mus rau "ShowEeprom" txhawm rau txheeb xyuas qhov koj nyuam qhuav khaws cia hauv Eeprom

Tam sim no ntsaws GPIO2 rau hauv av kom tawm ntawm kev teeb tsa hom

Koj Lub Rooj Vag yog npaj ua haujlwm

Muaj qee qhov lwm cov lus txib koj tuaj yeem pom hauv cov ntaub ntawv.

Kauj Ruam 7: Cia Ua Sab Arduino

Cia Ua Sab Arduino!
Cia Ua Sab Arduino!
Cia Ua Sab Arduino!
Cia Ua Sab Arduino!

Ua ntej tshaj txuas Arduino

Yog tias koj muaj Mega nws yuav yooj yim rau pib nrog. Txawm li cas los xij koj tuaj yeem siv Uno.

Txhawm rau txheeb xyuas koj txoj haujlwm zoo tshaj plaws yog siv tus piv txwv.

Koj tuaj yeem rub tawm nws muaj:

Nws suav nrog SerialNetwork code uas nyob ntawm no:

Tsuas yog xa cov cai hauv koj Arduino.

Cov ntsuab LED yog ntsais muag txhua lub sijhawm Arduino xa cov ntaub ntawv.

Kauj Ruam 8: Cia Peb Ua Server Sab

Cia Peb Ua Server Sab!
Cia Peb Ua Server Sab!
Cia Peb Ua Server Sab!
Cia Peb Ua Server Sab!

Qhov piv txwv ntawm server yog Java program uas koj tuaj yeem rub tawm ntawm no:

Cia li khiav nws

Saib ntawm Java console.

Saib ntawm Arduino saib.

Arduino xa 2 pob ntawv sib txawv.

  • Thawj qhov muaj cov koob digital 2 txog 6 xwm txheej.
  • Qhov thib ob muaj 2 qhov tseem ceeb tsis sib xws, qib voltage ntawm A0 hauv mV thiab suav ntxiv.

Java program

  • luam cov ntaub ntawv tau txais hauv hom hexadecimal
  • teb rau thawj cov ntaub ntawv nrog kev xaiv tsis raug rau teeb tsa/tawm ntawm Arduino LED
  • teb rau hom ntaub ntawv thib ob nrog cov suav tau txais thiab tus lej tsis raug.

Kauj Ruam 9: Nws yog Lub Sijhawm Los Ua Ib Leeg

Nws yog Lub Sijhawm Los Ua Ib Leeg!
Nws yog Lub Sijhawm Los Ua Ib Leeg!
Nws yog Lub Sijhawm Los Ua Ib Leeg!
Nws yog Lub Sijhawm Los Ua Ib Leeg!
Nws yog Lub Sijhawm Los Ua Ib Leeg!
Nws yog Lub Sijhawm Los Ua Ib Leeg!

Nws ua haujlwm ntawm daim ntawv qhia zaub mov!

Nws yog lub sijhawm los ua kom nws muaj zog dua los ntawm kev siv cov khoom seem ntawm PCB

Nyob rau sab saum toj ntawm yam koj tau ua nrog lub thawv ntawv, koj yuav tsum ntxiv 3 txuas.

  • C1 1 x tus pin ib qho uas yuav siv rau nkag mus rau hauv hom kab hauv network.
  • C2 3 x pins ib qho uas yuav siv los hloov ntawm kev khiav thiab teeb tsa hom.
  • C3 6 x pins ib qho uas yuav siv los txuas Lub Rooj vag mus rau Arduino lossis FTDI.

C1 txuas nrog GPIO2 yuav tsum tau ua haujlwm hauv av yog tias koj xav qhib lub network taug qab.

C2 txuas nrog GPIO 4 tuaj yeem teeb tsa hauv 2 txoj haujlwm sib txawv. Ib qho uas tau teeb tsa rau hauv av rau hom kev ua haujlwm ib txwm thiab ib qho teeb tsa rau 3.3v rau nkag mus rau hauv kev teeb tsa hom.

Teem tag nrho cov khoom siv ntawm PCB raws li daim duab thiab tom qab ntawd pib ua haujlwm kom tau txais cov khoom kawg!

Kauj Ruam 10: Cia Ua Qhov Xeem Kawg

Image
Image

Pib qhov kev xeem Java.

Txuas Arduino.

Fais fab ntawm Rooj vag.

Thiab saib ntawm Java console, Arduino saib, Arduino LED thiab Gateway LEDs.

Kauj Ruam 11: Koj tuaj yeem Hloov Kho Tus Qauv no Rau Koj Tus Kheej

Hais txog kho vajtse

  • Yog tias koj xaiv lwm qhov ESP8266 koj yuav tsum tau kho raws qhov tshwj xeeb.
  • Yog tias koj xaiv lwm 3.3v tus tswj hwm nws yuav tsum xa ntau dua 500mA thiab koj yuav tsum hloov kho lub capacitor.
  • Koj tuaj yeem hloov kho cov LED resistors los kho qhov ci ci.
  • Koj tuaj yeem tshem tawm tag nrho cov LED tab sis kuv pom zoo kom khaws tsawg kawg liab rau.
  • Koj tuaj yeem hloov ULN2803 los ntawm 3 lub transistors (lossis tsawg dua kuv koj xaiv tsis khaws 3 LED).
  • Kuv tau sim tab sis nyob ntawd nws yuav tsum ua haujlwm nrog 3.3v Arduino cov laug cam. Tsuas yog txuas Tx Rx rau 3.3v txuas.

Hais txog kev teeb tsa

  • Koj tuaj yeem khaws 2 qhov sib txawv SSID thiab hloov pauv
  • Koj tuaj yeem hloov kho GPIO siv

Hais txog software

Pom zoo: