2018年1月27日 星期六

MyESP8266 EX1-1 ESP8266-12E 連上網路

MyESP8266   EX1-1


The Arduino IDE is a free and open-source program which lets you write, compile, and upload programs to a very large number of devices, including your ESP8266 module.
Follow these “Install the Arduino Software (IDE)” directions to get the IDE installed on your computer.
Note that the word “Arduino” often refers to a couple different things:
  • Arduino IDE Software
    • This is what you just installed
  • Arduino hardware
    • These are the microcontroller boards which are officially supported by the Arduino IDE
    • The design of these boards is open-source, so there are plenty of cheap alternatives which are perfectly compatible
  • Arduino programming language
    • This is the language which we will use in this tutorial to program your ESP8266 module
    • The official tutorials are the best way to learn this language - most of them will run on your ESP8266 module with a bit of tweaking, but you might find it easier to pick up something like this $8 Arduino Nano V3 Compatible Module which will run the examples unmodified

Install USB-Serial Drivers

There are a number of different USB-to-serial chips used in ESP8266 modules - depending on the chip and your operating system, you may or may not have drivers already built in. The Arduino IDE also installs a number of drivers.
The most common additional drivers you may want to install are:

Install ESP8266 Board Definition

The Arduino IDE you installed does not natively support the ESP8266. Fortunately it’s quite easy to add support via the “Boards Manager”.
Note: Official documentation for Arduino ESP8266 support can be found here.

Add the ESP8266 Board Manager URL

  1. In the Arduino menu, go to File->Preferences on Windows and Arduino->Preferences on OSX
  2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field
  3. Hit OK so save your preferences
Arduino Preferences

Install the ESP8266 Platform

  1. In the Arduino menu, go to Tools->Board->Boards Manager
  2. Search for esp8266
  3. Click on the esp8266 entry, select the latest version, and hit Install
    • This may take a couple minutes since it needs to download and install all of the ESP8266 tools
  4. Hit Close once you are done
Arduino Boards Manager

Install Arduino Libraries

Arduino libraries are code other members of the Arduino community have written, packaged, and released for you to use. One of the strengths of the Arduino community is the number and quality of libraries which make it simple and fast to add a lot of complex capabilities to your code. We will use the “Library Manager” in the Arduino IDE to install a couple libraries necessary for our tutorial.
  1. In the Arduino menu, go to Sketch->Include Library->Manage Libraries
  2. Search for and install the latest versions of the PubSubClient library:
  3. Hit Close once you are done
Arduino Library Manager PubSubClient

// Import required libraries
#include "ESP8266WiFi.h"
// WiFi parameters
const char* ssid = "74170287";
//const char* ssid = "wifi-name";

const char* password = "24063173";
//const char* password = "wifi-pass";

void setup(void)
{  
  // Start Serial
  Serial.begin(115200);

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Print the IP address
  Serial.println(WiFi.localIP());
  
}

void loop() {

}




沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...