Cov txheej txheem:

Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield: 8 Cov Kauj Ruam
Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield: 8 Cov Kauj Ruam

Video: Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield: 8 Cov Kauj Ruam

Video: Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield: 8 Cov Kauj Ruam
Video: MSX-SM UNAPI Beta version presentation 2024, Hlis ntuj nqeg
Anonim
Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield
Serial UDP/IP Gateway rau Arduino Raws li ESP8266 Shield

Kuv twb tau tshaj tawm xyoo 2016 cov lus qhia no "Yuav ua li cas thiaj ua rau koj tus kheej lub qhov rooj Wifi txuas koj li Arduino rau IP Network". Txij li thaum kuv tau ua qee qhov kev txhim kho thiab kuv tseem siv qhov kev daws teeb meem no.

Txawm li cas los xij tam sim no muaj qee qhov ESP8266 cov ntaub thaiv npog uas tso cai ua zoo ib yam yam tsis muaj qhov txuas ntev li koj tsis tau siv Micro lossis Nano cov laug cam.

Cov lus qhia no yuav piav qhia yuav siv cov ntawv ESP82 li cas ua ntu zus UDP/IP rooj vag.

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

Xav paub ntau ntxiv txog daim ntaub thaiv nrog cov lus qhia no

Khoom siv

1 Arduino Mega (qhov zoo tshaj yog kom muaj tsawg kawg 1 Mega rau kev txhim kho thiab 1 Uno rau kev khiav theem)

1 Rokoo ESP8266 ESP-12E UART WIFI Hloov pauv

1 FTDI 3.3v

2 daim kab xev hluav taws xob

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.

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

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

Tab sis lub qhov rooj tseem tuaj yeem ua los ntawm nws tus kheej los ntawm kev xa cov ntaub ntawv sab hauv mus rau server thiab tau txais qee cov lus txib los ntawm server.

Arduino tuaj yeem xa thiab tau txais cov lus mus rau / los ntawm lub server txuas nrog Is Taws Nem tsuas yog luam tawm / nyeem kab ntawv txuas. Tsis muaj qhov xav tau rau Arduino tus tsim tawm los thab ntawm IP raws tu qauv.

Nyob rau sab saum toj ntawm qhov ntawd nws muab GPIO uas tuaj yeem siv los ntawm Arduino txhawm rau txheeb xyuas tias Lub Rooj vag raug txuas nrog WIFI thiab Lub Rooj vag tuaj yeem tuaj yeem siv tau nrog beetwen 2 SSID sib txawv thaum ua tsis tiav

Lub Rooj vag muaj 2 hom kev sib txawv uas tau xaiv los ntawm kev teeb tsa GPIO

Teeb GPIO rau hauv av thiab Lub Rooj vag nkag mus rau hauv kev teeb tsa hom.

Teeb GPIO pub dawb thiab Lub Rooj vag nkag mus rau hauv lub qhov rooj khiav hom.

Nyob rau sab saum toj ntawm lub Rooj vag UDP/IP teeb tsa tuaj yeem hloov kho nyob deb

Kauj Ruam 3: Tsim Cov Khoom

Tsim Cov Khoom
Tsim Cov Khoom

Tsawg tsawg yam uas yuav tsum tau ua

1 ESP8266 Shield - Kuv pom qhov UNO R3 ESP8266 Serial WiFi Shield Extend Board Module tsawg dua 9 €

1 UNO uas yog lub hom phiaj Arduino

1 Mega uas yog cov cuab yeej txhim kho arduino (koj tuaj yeem ua yam tsis muaj tab sis nws nyuaj heev rau debug)

1 FTDI 3.3/5v rau kev txhim kho

Qee cov xov hlau

Kauj Ruam 4: Rub lub Gateway Code

Download tau Gateway Code
Download tau Gateway Code

Hauv cov theem no Arduino tsuas yog siv rau lub zog (nrog USB lossis lwm lub zog siv) ntawm ESP8266 daim ntaub thaiv

Txuas ESP8266 GPIO4 rau hauv av (kom nkag mus rau hom teeb tsa)

Saib xyuas kom teeb tsa FTDI rau 3.3v raws li qhov xav tau los ntawm daim ntaub thaiv

Txuas FTDI rau daim thaiv (RX rau TX)

Teeb teeb thaiv kev hloov mus rau 1: tawm 2: tawm 3: rau 4: rau

Txuas lub USB sab ntawm FTDI rau koj lub computer

Pib dua daim thaiv npog nrog ESP-RST khawm khawm

Rub lub Gateway code rau ntawm GitHub

Qhib Arduino IDE

  • Xaiv FTDI saib chaw nres nkoj
  • Qhib IDE Serial Monitor - Teeb nrawm rau 38400
  • Xaiv Generic ES8266 module board
  • Txhim kho cov ntaub thaiv npog firmware nrog lub qhov rooj nkag

Teeb hloov 3: tawm 4: tawm

Qhib IDE Serial Monitor

Rov pib dua daim thaiv npog nrog ESP-RST khawm khawm

Koj yuav tsum pom cov lus ntawm tus saib pib nrog "EEPROM initialization" "Initialization tiav" ….

Nws yog lub sijhawm los ua qhov teeb tsa

Kauj Ruam 5: Cia Peb Ua Lub Rooj Vag Configuration

Thaum rub tawm txoj cai ntawm rooj vag thawj zaug, ESP8266 Eeprom yuav pib nrog qhov txiaj ntsig tsis raug. Koj yuav pom cov lus zoo li no "teeb tsa qhov ntsuas: x loj: yy"

Koj tuaj yeem pom cov txiaj ntsig no hauv kab lus txhais ntawm paramValue. Tau kawg koj tuaj yeem hloov cov txiaj ntsig no ua ntej rub tawm cov cai tab sis koj tseem tuaj yeem teeb tsa koj li kev teeb tsa los ntawm kev hais kom ua tom qab. Qhov no zoo dua yog tias koj npaj kom muaj ntau lub rooj vag nkag thiab khaws tsuas yog ib qho qauv ntawm cov cai.

Siv tus saib xyuas qhov chaw nres nkoj xa cov lus txib (teeb tsa rau NL thiab CR).

Raws li SSID tam sim no tsis tau hais tseg tos rau "Tsis tuaj yeem txuas rau koj qhov kev pabcuam thib ob: 5"

Tom qab ntawd kev tshuaj xyuas WIFI yuav pib ua haujlwm

Nws yog lub sijhawm los teeb tsa koj li SSID nrog cov lus txib hauv qab no:

  • SSID1 = yourchoice1
  • PSW1 = yourpsw1
  • SSID2 = yourchoice2
  • PSW2 = yourpsw2
  • SSID = 1 (xaiv qhov SSID yuav pib nrog)
  • RestartWifi

Tom qab ob peb feeb koj tuaj yeem tshawb xyuas qhov txuas nrog cov lus txib "ShowWifi". Koj yuav tsum pom tus IP chaw nyob lub rooj vag tau txais los ntawm koj tus DNS server. Yog tias yog qhov xwm txheej nws yog lub sijhawm mus ntxiv

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"

Los ntawm kev xa cov lus txib khoob koj yuav pom txhua cov lus txib txhawb nqa uas koj tuaj yeem siv tom qab kom haum rau koj cov kev xav tau. Txhua qhov ntsuas tsis tau raug khaws cia hauv Eeprom thiab xav tau rov pib dua kom coj mus rau hauv tus account.

Tshem cov xov hlau teeb tsa

Tam sim no daim ntaub thaiv tau khiav raws li lub qhov rooj

Kauj Ruam 6: Rub tawm Arduino Code Piv Txwv

Rub tawm Arduino Code Piv Txwv
Rub tawm Arduino Code Piv Txwv

Ua ntej rub tawm lub ntsiab Arduino code muaj ntawm GitHub

Tom qab ntawd rub tawm Arduino code cov lus txib no txhais thiab cov lej txuas txuas no rau hauv koj lub tsev qiv ntawv

Tom qab ntawd qhib lub ntsiab lus tseem ceeb nrog Arduino IDE tshiab

Teem daim thaiv Hloov 1 thiab 2 tawm dawb Arduino cov ntawv txuas 0 rau USB txuas

Pib dua daim ntaub thaiv

Txuas FTDI cov xov hlau mus rau Mega Serial 2 (TX FTDI rau RX Mega thiab ntxiv rau)

Pib tshiab Arduino IDE (lossis TTY cov cuab yeej), txuas FTDI Usb thiab pib saib xyuas qhov txuas txuas

Rub tawm Arduino code hauv Mega

Teem daim thaiv Hloov 1 thiab 2 txuas rau Arduino txuas txuas 0

Pib dua daim ntaub thaiv

Koj yuav tsum pom cov lus no "pib usb luam ntawv" ntawm tus saib

Kauj Ruam 7: Cia Peb Ua Server Sab

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

Tsuas yog khiav nws thiab saib ntawm Java console thiab saib FTDI saib

Koj yuav pom cov ntaub ntawv sib pauv ntawm server thiab Arduino

Kauj Ruam 8: Mus Ntxiv Ntxiv

Mus Ntxiv
Mus Ntxiv
Mus Ntxiv
Mus Ntxiv

Qhov piv txwv Arduino tus lej no yog ua raws lub hauv paus ib feem ntawm kuv lub tsev tsim kho vaj tsev.

Yog tias koj txaus siab rau cov txheej txheem no, qhia rau kuv paub. Kuv yuav tshaj tawm cov peev txheej.

Yog tias koj tsuas yog xav siv lub rooj vag koj tuaj yeem yooj yim Arduino code.

Tom qab tau txhim kho thiab sim koj cov cai ntawm Arduino Mega, koj tuaj yeem hloov nws yooj yim los ntawm Uno!

Nyob rau sab saum toj ntawm qhov ntawd koj tuaj yeem txuas xov tooj ntawm Arduino GPIO 7 thiab ESP8266 GPIO 5 yog tias koj xav kom koj Arduino tshuaj xyuas Wifi txuas

Pom zoo: