Try  HackMD Logo HackMD

Arduino X NodeMCU ESP 8266

<CDJH 606 14 王辰禎>

延伸閱讀: 自學ESP32-CAM X Line

一、所需設備及程式

1.裝置類

(1)開發版 NodeMCU V2

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

*對應開發版的擴充版

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(2)連接線(nodeMCU - Micro USB || Arduino - 較新式印表機連接線)

(3)電腦

(4)杜邦線

三種版本(公-公)(公-母)(母-母)

*建議購買(公-公) & (母-母)即可

2.軟體

(1)Arduino IDE(Free)


二、準備及設定

1.Check 裝置管理員-連接埠(COM 和 LPT)

*if ( 沒顯示出裝置 ) { 驅動程式未安裝 }

e.g. NodeMCU V3使用CH340G USB-to-UART橋接晶片組即需要驅動程式

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

2.在Arduino中選定開發版

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

3.選定連接埠(同裝置管理員之COM)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

4.開啟ArduBlock ESP - Experimental(以積木方式寫程式)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

三、實作

1.燈光閃爍(開發版內建的燈)

(1)匯入Demo並修改

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

*預設腳位為D4

*亮3000毫秒(=3秒) 、 暗1000毫秒(=1秒)

(2)上傳(讓積木自動轉換成程式)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(3)結果

2.超音波測距(1)-顯示距離

(1)匯入Demo並修改

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(2)接線並確認位置(開發版&超音波&程式)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

vcc-Vin(電) 、 gnd-gnd(接地) 、

(3)上傳(讓積木自動轉換成程式)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(4)結果

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

2.超音波測距(2)顯示距離&距離<15時亮燈

(1)匯入Demo並修改

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(2)上傳(讓積木自動轉換成程式)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

(3)結果

3.蜂鳴器(1)442Hz

(1)匯入Demo並修改

(2)接線並確認位置(開發版&超音波&程式)


(3)上傳(讓積木自動轉換成程式)

(4)結果(請開聲音)

3.蜂鳴器(1)440、1440Hz

(1)匯入Demo並修改

(2)接線並確認位置(開發版&超音波&程式)


(3)上傳(讓積木自動轉換成程式)

(4)結果(請開聲音)

4.溫溼度偵測

(1)匯入Demo並修改

(2)接線並確認位置(開發版&超音波&程式)



(3)上傳(讓積木自動轉換成程式)

(4)結果

5.超音波&動作偵測&燈光閃爍&溫溼度偵測

(1)匯入Demo並修改

(2)接線並確認位置(開發版&超音波&程式)

(3)上傳(讓積木自動轉換成程式)

(4)結果

結果 : 測距無法偵測、溫溼度正常(已確定接線、設定皆正確)

判斷失敗原因 : a.杜邦線損壞 b.部分腳位有所限制無法使用

*檢測a.杜邦線損壞用<三、實作 2.超音波測距(1)>判斷,四條線一組,輪流測試。

因皆正常,故排除a. ,暫定原因為b.