Showing posts with label Arduino IDE. Show all posts
Showing posts with label Arduino IDE. Show all posts

2017/11/12

Getting Started with EPS8266-12E Wi-Fi | ESP8266-12E 筆記本



I wanted to test out ESP8266 for a long time. However, I never got it to work until today. There are many tutorials and articles detailed how to make ESP8266 work, but even I followed many of those tutorials step by step mine ESP8266 just didn't work.  It was very frustrating not able to figure out what went wrong.  Anyway, I got it worked today, so it's better for me to write the steps down, not just for blog visitor like you, but also for myself as a good reference later on.

Previous three failed attempts... 😒


Different Version of ESP8266

There are many ESP8266 variations, the one I used for this tutorial is ESP8266-12E. Please refer to this page[2] to get more information for ESP8266 variations.

ESP8266 Pin Assignment

Most of the people probably will solder ESP8266 with metal covers facing up, so I placed a reversed pin assignment on the right side for easier pin reference.

Material Needed:
  • ESP8266-12E * 1
  • Perfboard * 1 
  • Breadboard * 1 
  • Wires - as many as needed
  • Resistors 1K * 4 
  • CP2102 USB-Serial Converter * 1
Tools Needed:
  • Power supply (3.3V)
  • Soldering iron 
  • Solder Tin
  • Plier-wire cutter
  • Plier

Step One: 

ESP8266 has 2mm pin pitch instead of 2.54mm standard pitch. So we have to place it on a prefboard to make connections easier. 

Place ESP8266 on a prefboard and draw its relative size that's larger to accommodate pins along both sides for easier connections with DuPoint wires. Cut down the piece of prefboard with a plier. 

[Important: I later found out from the ESP8266 datasheet recommended to place Wi-Fi antenna outside of prefboard to get better signal reception & transmission.] 😄

Step Two:

Solder wires on each ESP8266 pin to the prefboard as shown below. I found out that after stripped skin of the wires, soldering job just got a little bit easier.

Note: My previous attempt was to solder wires without strip the wire skin and it was more difficult to solder; harder to bend the wires. Be careful, do not short these wires! :) 

Step Three:

Solder 8 pin headers on each side of ESP8266 as shown below.

Step Four: 

Time to connect all wires together. Check out the schematic diagram below for all the connections needed.

Schematic Diagram




ESP8266 Connection:

  1. VCC -> 3.3V power source
  2. EN-CHPD -> 1K resistor -> 3.3V
  3. Reset -> 1K resistor -> 3.3V
  4. TX -> USB/UART RX
  5. RX -> USB/UART TX
  6. GPIO0 -> do not connect anything for this AT command tutorial
  7. GPIO15 -> 1K resistor -> GND
  8. GND -> GND
CP2012 USB/UART Connection
  1. RX -> ESP8266 TX
  2. TX -> ESP8266 RX
  3. GND -> GND (command ground with ESP8266)
NOTE:
  • Supply 3.3V to EPS8266! 5V will burn ESP8266!
  • GPIO-0 is connected to GND: upload Arduino programming code. 
  • GPIO-0 is not connected: Enter AT Command.


Step Five:

Here, I used a red breadboard for wire connections with resistors and the power supply. As long as you follow the schematic diagram above and wiring tips for the connection, it shouldn't be too difficult. (I only use two transistors to share with common pins to VCC and GND.  Not sure if this is a good practice?)


I have purchased an inexpensive power supply as the 3.3V power source. It displayed the how much the current is using, in this case "068mA",  allowing me to see what power was consumed at the particular point of time, which it's very convenient!  I checked ESP8266 datasheet "68mA ~ 71mA" means it's working probably.


Step Six:

Test AT Command. I think this is a quick method to check whether the ESP8266 is working or not. 
  • Connect CP2012 to a Mac USB port
  • Power on power supply with 3.3V 

Arduino IDE Operations:

  • First, let's load ESP8266 Library into Arduino IDE
  • Copy this string "http://arduino.esp8266.com/stable/package_esp8266com_index.json" into Arduino IDE preference -> Settings -> Additional Board Manager URLs. See below in yellow highlighted strings.



  • Select correct Arduino board type. Select "ESPino (ESP-12 module)" If you don't see this option, please restart Arduino IDE to ensure the library is properly loaded.


  • Select Port from port list. My serial port is /dev/cu.SLAB_USBtoUART


    • Click [Tools] - [Serial Monitor] from Arduino IDE to open the serial monitor.
    • Select baud rate from the baud rate list below. Select [115200 baud].  Your ESP8266 might have default baud rate of 9600 or 38400. If 15200 doesn't work, please try all other baud rate values.

    Start AT Command

    • AT:  You should be able to see the terminal replied "AT   OK" back. Congratulation, your ESP8266 is working!

    • AT+GMR: Display ESP8266 firmware version. My ESP8266 is V1.2.0.0 Date: Dec 2, 2016.  
    • AT+CWJAP="Wi-Fi_SSID","Password": Connect to the particular Wi-Fi Access point with the password designated.  As you can see, the WiFi got connected immediately. 
          

    • AT+CWMODE?[1]: Setup ESP8266 working mode. Let's setup ESP8266 to mode 3 both STA and AP. This allows ESP8266 connecting to your Wi-Fi router/Access point as a client also works as a router/Access point allowing other Wi-Fi client connect to it.
      • AT+CWMODE=1: STA (Become a Wi-Fi client to connect to AP)
      • AT+CWMODE=2: AP (Become an Assess point, so other clients can connect to this AP)
      • AT+CWMODE=3: BOTH = STA + AP (As an access point and a Wi-Fi client)

    • AT+CIFSR: Get IP Address. Since we setup CWMODE=3 (STA+AP mode), the first IP you see is AP IP (ESP8266 IP 192.168.4.1), the second IP is the WAN IP(your Wi-Fi IP 192.168.0.105 where ESP8266 is connected to)


    • AT+CWLAP: Scan Wi-Fi AP in the nearby area and show them all in a list.
      Text in first double quotes are WI-Fi SSID.


      • AT+RST: Reset command to reset ESP8266



      It's great! Your ESP8266 is ready to connect to the Internet.

      Load First Arduino Code:

      ESP8266 can be used as an Arduino board itself without buying another Arduino board to work with ESP8266. Let's flash Arduino code into ESP8266 to test it out. 
      1. Connect GPIO0 -> 1K resistor -> GND (Without GPIO0 pull low, you can't flash code to ESP8266!
      2. Copy the code below into your Arduino IDE and upload the code and the ESP8266-12E
      *********************************************************************************
      IMPORTANT:  After you upload Arduino codes, the AT command will no longer work. If you still prefer use AT command with ESP8266, you have to reflash AT command firmware to enable it. 

      It took me few days to figure out this!
      ***
      ******************************************************************************

      First Arduino code for ESP8266-12E, Connect to Wifi

      This Arduino code below will connect ESP8266 to your WiFi AP/router and display the IP address it obtain.  For this code to work, please replace Wifi_SSID with your Wifi-SSID and Wifi_Password with your own Wifi-Password. Do not forget to open Arduino IDE serial port to see the connection message!

      #include <ESP8266WiFi.h>
      
      void setup()
      {
        Serial.begin(115200);
        Serial.println();
      
        WiFi.begin("Wifi_SSID", "Wifi_Password");
      
        Serial.print("Connecting");
        while (WiFi.status() != WL_CONNECTED)
        {
          delay(500);
          Serial.print(".");
        }
        Serial.println();
      
        Serial.print("Connected, IP address: ");
        Serial.println(WiFi.localIP());
      }
      
      void loop() {}
      
      

      Second Arduino code for ESP8266-12E, Blink

      #include <ESP8266WiFi.h>
      void setup()
      {
        Serial.begin(115200);
        Serial.println();
        pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
      
        WiFi.begin("Wifi-SSID", "Wifi-Password");
      
        Serial.print("Connecting");
        while (WiFi.status() != WL_CONNECTED)
        {
          delay(500);
          Serial.print(".");
        }
        Serial.println();
      
        Serial.print("Connected, IP address: ");
        Serial.println(WiFi.localIP());
      }
      
      void loop() {
        digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                          // but actually the LED is on; this is because 
                                          // it is acive low on the ESP-01)
        delay(1000);                      // Wait for a second
        digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
        delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
        }
      

      That's all for this step by stpe notes. Hope you are getting something from here! :)

      REFERENCE

      1. ESP8266 Wi-Fi Library Great info to get more about ESP8266 Wi-Fi Library as well as what's AP, STA, and BOTH modes.
      2. Various ESP8266 boards Great info to understand the different types of ESP8266.
      ==============================================================

        EPS8266-12E Wi-Fi 筆記

      真的很高興,這個部落格在這幾天已經超過30萬的瀏覽次數!謝謝大家拜訪Stonez56的部落格來獲取有對你價值的資訊。😁

      長久以來,我一直想測試ESP8266,但是一直沒有成功。雖然,網上有很多教學和文章詳細介紹如何使用ESP8266,但即使我跟著很多這些教學一步一步地做,大部份都失敗了。 很多時候無法弄清楚哪裡出了問題,真是令人非常沮喪。 今天我手上的ESP8266已經正常的能回覆 AT Command,所以我趕快把這些步驟寫下來,不只可以提各位讀者參考,以後也可以作為自己的一份筆記。

      看看我之前失敗的例子...都堆在角落裡!


      不同版本的 ESP8266

      市面上有很多不同的版本,請參考這裡[2] 來了解其它ESP8266版本的差異。


      ESP8266 腳位說明

      ESP8266腳位說明如下。 由於大多數人可能會把ESP8266的金屬蓋朝上焊接,所以我在右側放置了一個反向的腳位,以便於大家參考。

      所需材料:

      •      ESP8266-12E * 1
      •      洞洞板* 1
      •      麵包板* 1
      •      電線 - 十多條
      •      電阻器1K * 4
      •      CP2102 USB 轉換器 * 1

      所需工具:

      •      電源(3.3V)
      •      烙鐵
      •      焊錫
      •      鋼絲鉗
      •      鑷子

      步驟一:

      ESP8266 腳位是 2mm 的間距,而不是2.54mm的標準間距。 所以我們必須把它銲在洞洞板上以方便連接。

      先將ESP8266放置在
      洞洞板上,並畫下其相對尺寸較大的尺寸,沿著兩側留下兩三個洞的距離,等會要銲上接腳,便於用杜邦線測試連接。 先用鉗子剪下畫好大小的洞洞板。

      [重要說明:我從ESP8266官方文件中發現,
      Wi-Fi天線不能放在金屬的上方,以便獲得更好的接收信號和處理能力!所以最後我把天線底下的洞洞板都用斜口鉗剪掉!]😄

      步驟二:

      如下所示,把每個ESP8266的腳位上用電線連接到洞洞板上。我發現電線剝皮後,比較容易焊一些。我看許多網友也都這樣做!

      注意:我以前的嘗試是焊接電線時沒有剝掉電線的外皮,焊接起來也比較困難; 也較不容易彎曲電線。 但是請小心,不要把這些電線短路! ☺

      步驟三:

      在ESP8266的兩側焊接上 8 個針腳,如下所示。

      步驟四:

      參考下面的示意圖,把所有電線接好準備測試。

      Schematic Diagram


      ESP8266連接方法:

      •      VCC - &gt; 3.3V 電源
      •      EN-CHPD - &gt; 1K 電阻 - &gt;3.3V
      •      重置 - &gt; 1K 電阻 - &gt;3.3V
      •      TX - &gt; USB / UART RX
      •      RX - &gt; USB / UART TX
      •      GPIO0 - &gt; 請先不要連接任何腳位,才能做 AT Command 測試
      •      GPIO15 - &gt; 1K 電阻 - &gt;GND
      •      GND - &gt;GND

      CP2012 USB / UART連接方法:

      •      RX - &gt; ESP8266 TX
      •      TX - &gt; ESP8266 RX
      •      GND - &gt; GND(ESP8266共同接地)

      注意:

      •      EPS8266只能使用 3.3V 電源! 使用5V會燒掉ESP8266!
      •      GPIO-0連接到GND:可上傳Arduino程式
      •      GPIO-0未連接:可輸入AT Command


      步驟五:

      如下圖,我用一個紅色小麵包板用來連接電阻和電源連接。 只要你按照上面的示意圖和接線提示連接即可。 (我只使用兩個 1K 電阻與VCC和GND共用腳位,不知道這是否是一個好的方法?)

      我買了一台電源供應器來提供3.3V穩定電源。它也可以顯示目前的電流量,如:“068mA”,讓我知道在特定的時間點,電流量是多少,非常方便! 我查了一下ESP8266的資料“68mA〜71mA”,表示它 Wi-Fi 是開啟中工作中。


      步驟六:

      測試AT命令。這是一個檢查ESP8266是否正常運作的快速方法。
      •      將 CP2012 連接到 Mac USB
      •      開啟3.3V電源

      Arduino IDE使用說明:

      •      先讓我們將ESP8266程式資料載入到Arduino IDE 中
      •      將此字串 “http://arduino.esp8266.com/stable/package_esp8266com_index.json” 複製到Arduino IDE Preference - &gt; Settings - &gt; Additional Board Manager URLs:  下方我用黃色標出的字符:



      • 一定要選擇正確的Arduino類型。 在選單中選擇“ESPino(ESP-12 Module)”如果您沒有看到此選項,請重新啟動一次Arduino IDE以確保ESP8266資料有帶進來。


      • 選擇 Port,我的 serial port 設定是 /dev/cu.SLAB_USBtoUART


        • 按一下 [Tools] -> [Serial Monitor] 打開序列埠的監看視窗。
        • 選擇連接速率 baud rate。 我用的是 [115200 baud].  您的ESP8266的內建速率可能是9600或38400.如果15200沒法使用,請嘗試所有其他的速率值。

        開使使用 AT Command:

        • 在最上方的命令列上打 AT,您應該能夠看到監看視窗回答“AT OK”。 恭喜,您的ESP8266已在正常工作中!

        • AT+GMR: 顯示 ESP8266 軔體版本. 我的 ESP8266 是 V1.2.0.0 Date: Dec 2, 2016.  
        • AT+CWJAP="Wi-Fi_SSID","Password": 使用指定的SSID 和 密碼 連接到特定的Wi-Fi分享器或路由器。 監看視窗會顯示,WiFi已連接成功!
              

        • AT+CWMODE?[1]: 設定ESP8266工作模式。讓我們將ESP8266設置為模式3 STA和AP。 這可以讓ESP8266作為客戶端連接到您的Wi-Fi路由器,ESP8266自己也可以作為路由器/,允許其他Wi-Fi客戶端連接到它。
          • AT+CWMODE=1: STA (Become a Wi-Fi client to connect to AP)
          • AT+CWMODE=2: AP (Become an Assess point, so other clients can connect to this AP)
          • AT+CWMODE=3: BOTH = STA + AP (As an access point and a Wi-Fi client)

        • AT+CIFSR: 顯示IP位址。 由於我們設置了CWMODE = 3(STA + AP模式),所以您看到的第一個IP是ESP8266自己的 IP(ESP8266 IP 192.168.4.1),第二個IP是連到Internet的路由器 IP(ESP8266 Wi-Fi IP 192.168.0.105)


        • AT+CWLAP: 掃描附近區域的Wi-Fi 路由器,並將其全部顯示在列表中。
          下方左側第一個雙引號中的文字是各路由器的 SSID。為了安全,我把 mac adress 畫掉了~


          • AT+RST: 重置 ESP8266,讓它重新開機!


          太好了! 您的ESP8266已準備好連接到Internet。

          載入第一個Arduino 程式到 ESP8266:

          其實ESP8266可以當作一般Arduino板來使用,它上面也有很多 I/O 腳位,不要再連另一塊 Arduino 來節省成本。 現在我們把Arduino的程式碼載入到ESP8266中進行測試。
          • 記得連接GPIO0 -&gt; 1K電阻器 - &gt; GND(GPIO0 要 pull low,不然,程式碼無法載入到ESP8266!
          • 將以下程式碼複製到您的Arduino IDE並載入到ESP8266-12E裡
          *********************************************************************************
          重要提示:在您上傳Arduino程碼後,AT命令將不能再使用。 如果您仍然想要使用ESP8266的AT命令,則必須上載AT command 的軔體才能再使用。
          ***
          ******************************************************************************

          第一個 ESP8266-12E 程式,連接到 WiFi AP :

          下面這個Arduino程式碼將啟動ESP8266連接到您的WiFi AP /路由器,並顯示它取得的IP地址。 要使用此程式碼,記得把您的Wifi密碼將Wifi_SSID替換為您的Wifi-SSID和Wifi_Password。

          #include <ESP8266WiFi.h>
          
          void setup()
          {
            Serial.begin(115200);
            Serial.println();
          
            WiFi.begin("Wifi_SSID", "Wifi_Password");
          
            Serial.print("Connecting");
            while (WiFi.status() != WL_CONNECTED)
            {
              delay(500);
              Serial.print(".");
            }
            Serial.println();
          
            Serial.print("Connected, IP address: ");
            Serial.println(WiFi.localIP());
          }
          
          void loop() 
          {}
          

          第二個 ESP8266-12E 程式,  閃爍 ESP8266 內建 LED

          #include <esp8266wifi.h>
          
          void setup()
          {
            Serial.begin(115200);
            Serial.println();
            pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
          
            WiFi.begin("Wifi-SSID", "Wifi-Password");
          
            Serial.print("Connecting");
            while (WiFi.status() != WL_CONNECTED)
            {
              delay(500);
              Serial.print(".");
            }
            Serial.println();
          
            Serial.print("Connected, IP address: ");
            Serial.println(WiFi.localIP());
          }
          
          void loop() {
            digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                              // but actually the LED is on; this is because 
                                              // it is acive low on the ESP-01)
            delay(1000);                      // Wait for a second
            digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
            delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
            }
          

          OK,希望你從這裡能得到你要的一些資訊!:)

          參考文件:

          1. ESP8266 Wi-Fi Library Great info to get more about ESP8266 Wi-Fi Library as well as what's AP, STA, and BOTH modes.
          2. Various ESP8266 boards Great info to understand the different types of ESP8266.

          2015/04/26

          A better Arduino IDE - Notepad++


          VS Code is the best Arduino IDE Today!(2021-07)



          Arduino IDE 1.6x has improved a lot over past few versions, such as adding line number, bug fixes, and many other features. However, Arudino IDE still has many miles to go to become a friendly editor for programmers. Syntax highlighting and programming language reference are programmer favorite features. However, they are not that fancy yet on the latest version of Arduino IDE V1.6.3.

          I've been using Notepad++ (N++) for a while and Notepad++ is one of the most famous programming tools available for free!! Recently, I found josephdouce’s contribution on SourceForge that Joseph developed a N++ plugin for Arduino. Although it’s still in prealpha stage, it looks promising!

          I would like to show you how to add N++ Arduino plugin into Notepad++ and use it as your editor.

          Download Files:

          1. Download latest Notepad++ By Don Ho
            • You many select Installer, zip package, or 7z package
          2. Download latest Arduino IDE by Arduino.cc
            • Select Installer or zip package if you don't have admin access right
          3. Download N++ Arduino Plugin by josephdouce

          Installation:

          1. Install Arduino by unzip the “Arduino-1.6.3-windows.zip” into your preferred folder or directly install it if you downloaded the Installer
          2. Install Notepad++ by unzip the download "npp.6.7.7.bin.zip" file into your preferred folder or directly install it if you downloaded the Installer
          3. Unzip N++ Arduino plugin zip files into an empty directory
          Detailed N++ Arduino Plugin Settings:
          • First, let's import Arduino_Language_0.2.0.xml
            Start Notepadd++ application and click "Language", "Define your language..."
          • You should see "User Defined Language" window popup. Click on "Import..." and select the Arduino_Language_0.2.0.xml file  (This should be in the unzipped N++ Arduino plugin directory).  You will see import successfully message, then you may close this window.



          • Copy API files to Notepad++ plugins\APIs directory (This is where you installed the Notepad++).
            In my computer, it is in c:\Program Files\Notepad++\APIs\


          • In Notepad++, Click Preference



          • Click "Auto Completion" on the left (blue background) and then tick both "Enable auto-completion on each input" and "Function parameters hint on input", then close this window. (circled below)


          How to use Arduino N++ Plugin:

          When you start Notepad++ application, remember to click "Lanauages" then click on "Arduino". That's it! As you can see, as soon as you type, Notepad++ looks for variables or keywords from the XML file and show relevant candidates in a popup menu. As a programmer, it is a lot easier to just pick one up from the list. Isn't it?! ;)

          Example:
          A) I defined a variable called CheckStatus
          B) As soon as I typed Check...
          C) A list of suggested variable/command starting with letter C is listed in the box for you to pick up!

          See below, Arduino language reference showing up automatically as you type!
          This is really helpful!


          Big thanks to these software contributors!!

          How to invoke Arduino IDE for compiling and uploading to Arduino boards:
          Quite few people was asking me if it's possible to compile code inside Notepad++. After few tries, I think it's impossible for now.  However, you may activate Arduino IDE inside Notepad++ with keystrokes you defined.

          In Notepad++, Click "Run.."





          You will see a popup window showed up. See illustration (A) below.
          Click the 3 little dot button after the drop-down box and then select your Arduino executable file arduino.exe and then type "$(FULL_CURRENT_PATH)" right after the arduino.exe file. Double quotations are needed to make this work.

          Here is mine for your reference:
          "F:\arduino\arduino.exe" "$(FULL_CURRENT_PATH)"











          Then Click "Save..." to assign a shortcut key. You will see another popup window(B). Tick the combination of CTRL, SHIFT, or ALT keys you like and pickup another key from the drop-down box. In my setup, I named it "Arduino" and selected CTRL + SHIFT + F5. From now on, I just need to hit the combination keys to invoke Arduino and bring the latest codes into Arduino IDE for compiling.

          Hit CTRL + SHIFT + F5 you will see Arduino IDE invoking screen....


















          See below, codes in Notepad++ are identical as those in Arduino IDE.











          PS: One problem though.... Each time you hit the combination keys, one instance of Arduino IDE will start and reside in the PC..... I don't have solution for this yet!

          Thanks author Sriram Iyer for this tip: Using-notepad-plus-plus-instead-of-the-arduino-ide

          End
          ================================================================

          一套比 Arduino IDE 更好用的編輯器 - Notepad++ / Arduino N++ Plugin


          Arduino 編輯器 V1.6x 雖然改進了不少,但是對寫程式的來說還是沒那麼好用。

          Notepad++ 是一套很有名的文字編輯軟體。我自己曾使用 Notepad++ 寫 PHP,覺得它真的很好用。最近看到 SourceForge 上, 有位高手(josephdouce)寫了一套 N++ plugin for Arduino,雖然它只是 Prealpha 版本,但它已可以讓使用者在 Notepad++ 裡寫 Arduino,不但提供 Syntax highlight,變數及指令的提示, 也會給顯示語法使用方法及參數的提示,看來蠻有潛力的!

          需下載的檔案:

          1. 由此下載最新版的 Notepad++ By Don Ho
            • 你可選擇要安裝版(Installer)或是壓縮檔(.zip or 7zip)再自行解壓縮也行
          2. 由此下載最新版的 Arduino IDE by Arduino.cc
            • 你可選擇要安裝版(Installer)或是壓縮檔(.zip or 7zip)再自行解壓縮也行
          3. 由此下載  N++ Arduino Plugin by josephdouce

          安裝方法:

          1. Arduino: 選擇壓縮檔者,只要把 “Arduino-1.6.3-windows.zip” 解壓縮到你想要執行的目錄即可。 選擇安裝檔者,就按步驟執行即可。
          2. Notepad++: 選擇壓縮檔者,只要把 “npp.6.7.7.bin.zip” 解壓縮到你想要執行的目錄即可。 選擇安裝檔者,就按步驟執行即可。
          3. N++ Arduino plugin: 解壓縮 "Notepad++.Arduino.0.2.0.zip" 到自己想放的目錄即可。
          N++ Arduino Plugin 安裝與設定:
          • 匯入 Arduino_Language_0.2.0.xml 設定檔
            開啟 Notepadd++ 然後點選 "Language/程式語言", "Define your language.../定義程式語言" 如下圖:
          • "User Defined Language/自訂程式語言" 視窗會跳出來。點選 "Import.../匯入"(見下圖) 然後由視窗裡點選 Arduino_Language_0.2.0.xml 檔案。 (這個檔案就是你剛剛解壓縮N++ Arduino plugin的目錄)。  如果匯入完成,你會看到完成的提示視窗。



          • 從N++ Arduino plugin解壓的目錄裡,把 API  "Arduinolbs" 目錄夾 整個 copy 到 Notepad++ plugins\API 目錄底下 ( Notepad++ 執行檔安裝位置裡有一個 \plugins\APIs 的目錄)  在我自己的電腦,Notepad++ 是安裝在 c:\Program Files\Notepad++\APIs\ 底下


          • 在回到 Notepad++, 點選 "Preference/自訂"



          • 從左邊點選 "Auto Completion/自動完成功能"  然後把 "Enable auto-completion on each input/啟動自動完成功能" 和 "Function parameters hint on input/自動顯示功能參數提示", 打勾 ,關掉視窗即設定完成。 參考下圖:

          Arduino N++ plugin for Notepad++ 使用方法:

          只要安裝成功,使用方法非常簡單! 打開 Notepad++, 在程式語言的清單裡選擇 Arduino 即可!
          往後只要你一邊打字, N++ plugin 會把相關的指令或是你使用過的變數在一 個小視窗上列出來。這樣一來,你可以挑想用的變數或是指令, 降低變數/指令使用出錯率。

          例如:
          A) 我定義了 CheckStatus 變數
          B) 只要我在 Notepad++ 裡打了 Check
          C) 所有指令或是變數是由 C 開頭的都會顯示在小視窗裡,CheckStatus 就在最底下,如下圖:

          Arduino 指令使用方法及參數也會自動顯示出來了! 對新手來說, 這樣可以減少查閱指令的使用方法,是不是太方便了!


          如何在 Notepad++ 裡呼叫 Arduino IDE 來編譯及上傳到Arduino上:

          有不少人問我,能不能在Notepad++ 裡直接呼叫 Arduino IDE 來編譯及上傳。找了網上的一些資料,發現目前還沒有方法可以做的到。不過,你可以自行定義快速鍵來呼叫 Arduino IDE 並且把正在編輯的程式碼直接傳到 Arduino IDE 裡。

          在 Notepad++ 裡, 點選 "Run.."





          你會看到一個 Run... 的視窗跳出來如下圖(A)
          點一下有3個小點的鈕,然後選取你的 Arduino 的執行檔,再加上左右側的雙引號在路徑的前後,空一格,再加上 "$(FULL_CURRENT_PATH)" 

          在我的PC上,它看起來應該像這樣:( 引號有四個,都要打上去才行)
          "F:\arduino\arduino.exe" "$(FULL_CURRENT_PATH)"










          按下 "Save.../存檔" 然後你會看到視窗(B) 自行定義快速鍵,把你想要指定的快速鍵打勾,再從下拉選單裡,選一個自己喜歡的組合,然後在 Name: 那裡自己取一個檔名來儲存。我自己取為 Arduino 並選取了 CTRL + SHIFT + F5. 按 OK, 關掉視窗。

          往後我只要按下  CTRL + SHIFT + F5 在 Notepad++ 裡,即可直接呼叫 Arduino IDE 來編譯及上傳。


          按下CTRL + SHIFT + F5 鈕後,會看到這個畫面表示 Arduino IDE 開始啟動:





















          右側視窗的 Notepad++ 呼叫 Arduino IDE, 你可以看到左側是 Arduino IDE 裡的程式碼和右側
          Notepad++ 裡的程式已經同步。














          PS: 有一點小小的問題.... 每次你呼叫一次 Arduino IDE,它的程式就會長註一個在電腦裡。我還不知道有沒有解法!

          謝謝網友 Sriram Iyer 網誌裡提供在 Notepad++ 裡呼叫 Arduion IDE 的方法: Using-notepad-plus-plus-instead-of-the-arduino-ide


          結束