Chuyển tới nội dung
Home » Nodemcu In Arduino Ide | Step 13: Adding Libraries

Nodemcu In Arduino Ide | Step 13: Adding Libraries

How to Setup and Program NodeMCU ESP8266–Complete Guide

Prerequisites: Arduino IDE Installed

Before starting this installation procedure, you need to have Arduino IDE installed on your computer. There are two versions of the Arduino IDE you can install: version 1 and version 2.

You can download and install Arduino IDE by clicking on the following link: arduino.cc/en/Main/Software

Which Arduino IDE version do we recommend? At the moment, there are some plugins for the ESP32 (like the SPIFFS Filesystem Uploader Plugin) that are not yet supported on Arduino 2. So, if you intend to use the SPIFFS plugin in the future, we recommend installing the legacy version 1.8.X. You just need to scroll down on the Arduino software page to find it.

If you’ll use Arduino 2, you can follow this tutorial instead:

If later on, you need to install the SPIFFS plugin, you can install Arduino 1.8.X and have both versions installed on your computer.

Do you need an ESP32 board? You can buy it here.

Troubleshooting

If you try to upload a new sketch to your ESP8266 and you get this error message “esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header“. It means that your ESP8266 is not in flashing/uploading mode.

Having the right board name and COM port selected, follow these steps:

  • Hold-down the “BOOT/FLASH” button in your ESP8266 development board
  • Press the “Upload” button in the Arduino IDE to upload your sketch:
  • When you see the “Connecting….” message in your Arduino IDE, release the finger from the “BOOT/FLASH” button
  • After that, you should see the “Done uploading” message

Your ESP8266 should have the new sketch running. Press the “ENABLE/RESET” button to restart the ESP8266 and run the new uploaded sketch.

How to Setup and Program NodeMCU ESP8266–Complete Guide
How to Setup and Program NodeMCU ESP8266–Complete Guide

Testing the Installation

Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:

1. Select your Board in Tools > Board menu (in my case it’s the DOIT ESP32 DEVKIT V1)

2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to install the CP210x USB to UART Bridge VCP Drivers):

3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan

4. A new sketch opens in your Arduino IDE:

5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code compiles and uploads to your board.

6. If everything went as expected, you should see a “Done uploading.” message.

7. Open the Arduino IDE Serial Monitor at a baud rate of 115200:

8. Press the ESP32 on-board Enable button and you should see the networks available near your ESP32:

Configure and Setup Arduino IDE To Use the NodeMCU ESP8266

The NodeMCU offers a variety of development environments, including compatibility with the Arduino IDE (Integrated Development Environment). The NodeMCU/ESP8266 community took the IDE selection a step further by creating an Arduino add-on. If you’re just getting started programming the ESP8266 or even an established developer, this is the highly recommended environment. Visit our dedicated page on setting up and configuring the Arduino IDE for a NodeMCU ESP8266.

Install the ESP8266 Board in Arduino IDE in less than 1 minute (Windows, Mac OS X, and Linux)
Install the ESP8266 Board in Arduino IDE in less than 1 minute (Windows, Mac OS X, and Linux)

Step 1: Control an LED From Web Browser

In this blog, we will see How to “Turn On and Turn Off” an LED that has connected to the Esp8266, the esp8266 has programmed from Arduino IDE to control the LED.We will connect the Esp8266 to the Wi-Fi router using SSID and password of our Home network Wifi , where the esp8266 connect to our wifi and create a webserver, which can be accessed by looking through the serial Monitor of the Arduino window or you can also log into your Wifi router and check for the list of clients connected to your Wi-Fi router.Here’s a window which explains the step by step procedure to connect the Esp8266 to the Wi-fi server and How to access the Webpage and control the LED connected to the Esp8266

For the above video I have used NodeMcu, you can use any type of Esp8266 to make this thing work in your web browser.

look for the mapping of pins in with your Esp8266 vendor, if the program not working properly for you , the fault will be with the pin mapping functionalities, Here I used the D7 pin which mapped to 13th pin when program from the Arduino IDE.

Connect your Esp8266 to Arduino IDE and Select the correct COM Port and board type and

upload the program.

Note change the SSID to your WiFi Name and password to your Wifi password. if you forget to change it , esp8266 will not connect connect your wifi.

————————————————————————————————————————–

If everything completed you can turn to your serial monitor and check for the ip address that your devices has connected to . you will presented with an serial monitor that look exactly to the picture below.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that’s the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Add NodeMCU Library to the IDE

The IDE needs to know details about the NodeMCU module. This information is available in a configuration file which will is added to the IDE.

Select the File…Preferences

This will open up a new window, where we set the IDE to point to the configuration file.

In the field “Additional Boards Manager URLs:” enter

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Select the OK button at the bottom of the window when the link address is entered.

How to use NodeMCU with Arduino IDE for programming?
How to use NodeMCU with Arduino IDE for programming?

Prerequisites: Arduino IDE Installed

Before starting this installation procedure, make sure you have the latest version of the Arduino IDE installed in your computer. If you don’t, uninstall it and install it again. Otherwise, it may not work.

Having the latest Arduino IDE software installed from arduino.cc/en/Main/Software, continue with this tutorial.

Do you need an ESP8266 board? You can buy it here.

Prerequisites: Arduino IDE 2.0 Installed

Before proceeding make sure you have Arduino IDE 2.0 installed on your computer.

Go to the Arduino website and download the version for your operating system.

  • Windows: run the file downloaded and follow the instructions in the installation guide.
  • Mac OS X: copy the downloaded file into your application folder.
  • Linux: extract the downloaded file, and open the arduino-ide file that will launch the IDE.

If you have doubts, you can go to the Arduino Installation Guide.

Do you need an ESP8266 board? You can buy it here.

Recommended reading: Best ESP8266 Boards Comparison

How to Program NodeMCU with Arduino IDE
How to Program NodeMCU with Arduino IDE

Testing the Installation

To test the ESP8266 add-on installation, let’s see if we can blink an LED with the ESP8266 using the Arduino programming language.

Parts Required

Here’s the hardware that you need to complete this project:

If you’re using an ESP8266-01, you also need an FTDI programmer to upload code.

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Introduction: How to Program NodeMCU on Arduino IDE

The Osoyoo NodeMCU comes pre-programmed with Lua interpretter, but you don’t have to use it! Instead, you can use the Arduino IDE which may be a great starting point for Arduino lovers to familiarize themselves with the technologies surrounding the IoT.Note that when you use the NodeMCU board with the Arduino IDE ,it will write directly to the firmware, erasing the NodeMCU firmware.So if you want to back to Lua SDK,use the “flasher” to re-install the firmware.

The NodeMCU programming can be as easy as in Arduino,the main difference is the distribution of pins in the nodemcu board.Following below operations and enjoy your first NodeMCU & Arduino IDE travel!

Como Programar o ESP8266 na Placa NodeMcu - Video #2 - ESP8266 Primeiros Passos
Como Programar o ESP8266 na Placa NodeMcu – Video #2 – ESP8266 Primeiros Passos

Install ESP8266 NodeMCU Add-on in Arduino IDE

To install the ESP8266 board in your Arduino IDE, follow these next instructions:

1. In your Arduino IDE 2.0, go to File > Preferences.

2. Copy and paste the following line to the Additional Boards Manager URLs field.


http://arduino.esp8266.com/stable/package_esp8266com_index.json

Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma, as follows:


http://arduino.esp8266.com/stable/package_esp8266com_index.json, https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

3. Open the Boards Manager. You can go to Tools > Board > Boards Manager… or you can simply click the Boards Manager icon in the left-side corner.

4. Search for ESP8266 and press the install button for esp8266 by ESP8266 Community.

That’s it. It should be installed after a few seconds.

Step 3: Upload DS18b20 Temperature Sensor Data to Thingspeak From Esp8266 (nodemcu)

Hello all in this tutorial you will know how to use Ds18b20 Temperature data to thingspeak.com, you can follow above fritzing circuit diagram to control the Ds18b20 temperature sensor, This sensor follows one wire protocol which means you can connect many sensors as you want to the single pin and access temperature data calling the sensor by address.check the video below on how to work with this sensor and also proof of code working .

There is no much work to get work with this sensor, as there are plenty of example library that already available in the internet which anyone can make use and get started to work with this sensor.

Test the below code to know check whether you can get reading from the temperature sensor with ESP8266 or Nodemcu

if you get any error , make sure you have downloaded library for Ds18b20 Temperature sensor.

copy paste above code to your Arduino IDE and upload to your ESP8266 or Nodemcu if you are not sure about how to do this please check the video about to know how things work, if you don’t know yet to search search on this blog for getting started with Esp8266 in Arduino IDE.

below you can see the code for sending temperature data to thingspeak.com from Esp8266 or Nodemcu to do this you need have thingspeak api key which can get easily by registering to the website.

change SSID and password to your router password and also update the Nodemcu api key.

————————————————————————————————————————–

————————————————————————————————————————–

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that’s the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Easily Configure Arduino IDE for NodeMCU

ESP8266 | NodeMCU'ya Arduino IDE Üzerinden Nasıl Program Yüklenir?
ESP8266 | NodeMCU’ya Arduino IDE Üzerinden Nasıl Program Yüklenir?

Introduction: Quick Start to Nodemcu (ESP8266) on Arduino IDE

Thanks to the guys those who ported the Esp8266 into Arduino IDE and helping all the arduino users happy to the core. Yes it’s been long time since they did and this post is bit later to thanks the good hearted work by the guys out there.

Lets begin with Installing the Esp8266 support for the Arduino and see how to blink an LED ( the hello world in the electronics )

check out the video to know step by step tutorial on how to get started with our favourite chip Esp8266

Firstly open the Arduino IDEGo to files and click on the preference in the Arduino IDE

copy the below code in the Additional boards Managerhttp://arduino.esp8266.com/stable/package_esp8266com_index.jsonclick OK to close the preference Tab.

After completing the above steps , go to Tools and board, and then select board Manager

Navigate to esp8266 by esp8266 community and install the software for Arduino.

Once all the above process been completed we are read to program our esp8266 with Arduino IDE.

For this example I have used NodeMCU esp8266 and if you are using any other vendor wifi chips or generic wifi module please check with the esp8266 Pin mapping which is very essential to make things works.

The reason why I used D7 pin for this example is , I uploaded the basic blink program that comes with the examples program in the arduino IDE which is connected with 13 pin of arduino. The 13th pin is mapped into D7 pin of NodeMCU.

go to board and select the type of esp8266 you are using. and select the correct COM port to run the program on your esp8266 device.

void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); }

// the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

upload the program and see the results.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that’s the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Code To Test NodeMCU Functionality

This is a simple sketch that will flash the LED on pin D0 every 1/4 second (250mS). The routine will also have the NodeMCU send a small text message over the communication channel and will display it in the Serial Monitor.

Copy the code below and paste it into a blank sketch in the IDE.

10

11

12

13

void setup() {

pinMode(D0, OUTPUT); // Blue LED Beside CP2102

Serial.begin(9600);

void loop() {

Serial.println(“Welcome To PCBoard.ca”); // display message on console

digitalWrite(D0, HIGH);

delay(500);

digitalWrite(D0, LOW);

delay(250);

After entering the sketch, press the right-facing arrow to Compile and Upload the code to the NodeMCU. You will be prompted to save the sketch, name the sketch “blinky” and press Save. The saving, compiling, and uploading of the sketch to the NodeMCU may take a minute or two depending on the speed of your system.

After the compile and upload are complete, the LED on the NodeMCU will begin to blink. In some situations, the RST (reset) may need to be pressed to reset the NodeMCU after uploading.

Press the Serial Monitor icon (located on the upper right side of the screen). This will display the welcome message which is generated on the NodeMCU.

The Serial Monitor will display text as the NodeMCU generates it.

If you do not see text, check the terminal speed box located at the bottom of the window (showing in Red). It must be set for 9600 to display text coming from the NodeMCU.

Top 10 Dự án Arduino HOT nhất 2023 - Tự học lập trình Arduino | Top 10 Arduino projects
Top 10 Dự án Arduino HOT nhất 2023 – Tự học lập trình Arduino | Top 10 Arduino projects

Arduino IDE NodeMCU Configuration Complete

This completes the configuration of the Arduino IDE to recognize and generate code for the NodeMCU. Coding syntax for the NodeMCU in the IDE follows the Arduino framework, including pin designations and communications ports.

Below is a coding example for the NodeMCU which flashes an onboard LED and also has allows the NodeMCU to generate a text that can be seen through the serial monitor.

Download and Install the Arduino IDE

The Arduino IDE (Integrated Development Environment) is available for no cost. You can visit the Arduino site (www.arduino.cc), which is an excellent resource for all-things Arudino.

From there, you will want to download the latest Arduino IDE (https://www.arduino.cc/en/Main/Software)

After downloading the IDE, proceed to install using the default setup options.

Buat Sendiri Stoplamp Running Text V.2 Costom 29 Animasi
Buat Sendiri Stoplamp Running Text V.2 Costom 29 Animasi

Step 2: Control Electrical Devices From User Web Browser Using Esp8266 Nodemcu

Make sure all the devices are connected to the same router, this example doesn’t include a port forwarding function which will not allow us to control the device from outside the home network.

Components that you need for completing this project are very simple, you need to have an esp8266 wifi module and a relay, make sure you buying a 5v relay which very easy to use with esp chips doesn’t require external supply too. we can make use of the Vin pin of the nodemcu or if you are using a generic chip, you need to supply an external 5v to the relay.

For this example project I have used only 2 relay circuit, but the actual program wrote for connecting four relay module.

You can check the above video on how this thing works and how to connect your browser to the ip address returned from esp and all the details are included in this video.

Copy the below arduino code and paste into your Arduino IDE and upload the program to your nodemcu or any other esp devices that you are using, make sure to choose the correct port and device name from the board. also don’t forget to change the SSID and password to your Wi-fi settings.

This program for the esp8266 wrote to return the status of the device , which will in turn notify us with the device state in the browser which will also make the user to know which device has currently turned on or off.

Copy the above code and complete the process. Share and let others know about this tiny chip which can do dozens of magic.

if you like the above tutorial and if you want try out with cool projects you can also check this link here , that’s the amazon book link where you can use that book to make IoT with Esp8266 or Nodemcu, that books gives you basic coverage on how to do simple things and get yourself started with arduino and goes on developing projects like sending data to webserver and creating a webserver, uploading and controlling data from a webpage, how to interface TFT LCD and I2C devices and many more things can find on the link.

Testing the Installation

To test the ESP8266 add-on installation, we’ll upload a simple code that blinks the on-board LED (GPIO 2).

Copy the following code to your Arduino IDE:


/********* Rui Santos Complete project details at https://RandomNerdTutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/ *********/ #include

#define LED 2 void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(LED, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED, HIGH); Serial.println("LED is on"); delay(1000); digitalWrite(LED, LOW); Serial.println("LED is off"); delay(1000); }

Uploading the Sketch

On the top drop-down menu, select the “unknown” board. A new window, as shown below, will open.

You should select your ESP8266 board model and the COM port. In our example, we’re using the NodeMCU 1.0 board. Click OK when you’re done.

Now, you just need to click on the Upload button.

After a few seconds, the upload should be complete.

The ESP8266 on-board LED should be blinking every second.

Serial Monitor

You can click on the Serial Monitor icon to open the Serial Monitor tab.

That’s it! You’ve installed the ESP8266 Boards successfully in Arduino IDE 2.0.

Smart Home project - Đồ án Nhà Thông Minh sử dụng Blynk | Arduino, app android
Smart Home project – Đồ án Nhà Thông Minh sử dụng Blynk | Arduino, app android

Installing ESP32 Add-on in Arduino IDE

To install the ESP32 board in your Arduino IDE, follow these next instructions:

  1. In your Arduino IDE, go to File> Preferences

  2. Enter the following into the “Additional Board Manager URLs” field:

    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

    Then, click the “OK” button:

    Note: if you already have the ESP8266 boards URL, you can separate the URLs with a comma as follows:

    https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

  3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

  4. Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:

  5. That’s it. It should be installed after a few seconds.

Defining The Communications Port

The communications port must be defined to allow the Arduino IDE to communicate with the NodeMCU. Connect your PC by a USB cable to the NodeMCU.

After connection, the PC will provide power to the NodeMCU. The communication port used will vary by system.

To determine which communications port has been selected on your system, select the Tools…Port menu option.

The options list will present the available COM ports. For our example, our NodeMCU added COM6 and will be selected by clicking on COM6.

Shown below the Board selection, are several NodeMCU settings. These include CPU Frequency, Flash Size, and also Upload Speed. If Upload Speed is not set to 115200, select the speed of 115200 from the options from that item. The speed of 115200 is the optimum transfer rate that is used to transfer data to and from the NodeMCU.

Smart Home with Google Assistant & Alexa using NodeMCU ESP8266 (Manual + Voice) | IoT Projects 2021
Smart Home with Google Assistant & Alexa using NodeMCU ESP8266 (Manual + Voice) | IoT Projects 2021

Step 13: Adding Libraries

In case you need to add the libraries to the Arduino follow the example path is shown in the figure i.e C:\Users\Armtronix\Documents\Arduino\libraries. Enter into the libraries folder then paste the file in that as shown below.

There is a new Arduino IDE—Arduino IDE 2.0 (beta version). In this tutorial, you’ll learn how to install the ESP8266 boards in Arduino IDE 2.0 and upload code to the board. This tutorial is compatible with Windows, Mac OS X, and Linux operating systems.

Accordingly to the Arduino website: “The Arduino IDE 2.0 is an improvement of the classic IDE, with increased performance, improved user interface and many new features, such as autocompletion, a built-in debugger and syncing sketches with Arduino Cloud“.

If you want to install the ESP8266 boards on the “classic” Arduino IDE, follow the next tutorial instead:

If you prefer programming the ESP8266 using VS Code + PlatformIO, go to the following tutorial:

  • Getting Started with VS Code and PlatformIO IDE for ESP32 and ESP8266 (Windows, Mac OS X, Linux Ubuntu)

You might also like reading the ESP32 Guide: Installing ESP32 Board in Arduino IDE 2.0 (Windows, Mac OS X, Linux)

Wrapping Up

This is a quick guide that illustrates how to prepare your Arduino IDE for the ESP8266 on a Windows PC, Mac OS X, or Linux computer.

Next, you might want to read: Getting started with ESP8266.

That’s it, you’re ready to start building your own IoT projects with the ESP8266!

  • Home Automation Using ESP8266
  • ESP8266 Web Server Step-by-step
  • ESP8266 Wi-Fi Button – DIY Amazon Dash Button Clone
  • ESP8266 Daily Task – Publish Temperature Readings to ThingSpeak
  • ESP8266 Weather Forecaster
  • Nextion Display with ESP8266 – Touchscreen User Interface for Node-RED
  • More ESP8266 projects…

Do you have any questions? Leave a comment below!

Thanks for reading. If you like this post probably you might like my next ones, so subscribe to my newsletter.

Solved USB Not Detected NodeMCU ESP8266- Drivers issue
Solved USB Not Detected NodeMCU ESP8266- Drivers issue

Wrapping Up

This is a quick guide that illustrates how to prepare your Arduino IDE for the ESP32 on a Windows PC, Mac OS X, or Linux computer. If you encounter any issues during the installation procedure, take a look at the ESP32 troubleshooting guide.

Now, you can start building your own IoT projects with the ESP32!

  • Learn ESP32 with Arduino IDE [eBook + Video Course]
  • ESP32 vs ESP8266 – Pros and Cons
  • Free ESP32 Projects and Tutorials
  • Build an ESP32 Web Server with Arduino IDE
  • ESP32 DHT11/DHT22 Web Server with Arduino IDE

Thanks for reading.

Trong hướng dẫn này, bạn sẽ học cách nạp code cho ESP8266 trong Arduino IDE 2.0. Bài hướng dẫn này thích hợp với các hệ điều hành Windows, Mac OS X và Linux.

Sau khi cài đặt thành công Arduino IDE

Để cài đặt bảng ESP8266 trong Arduino IDE của bạn, hãy làm theo các hướng dẫn tiếp theo sau:

1. Mở Arduino IDE của bạn lên, vào File > Preferences.

2. Sao chép và dán dòng sau vào trường URL Trình quản lý bảng bổ sung .

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Lưu ý: nếu arduino của bạn đã có URL của bảng ESP32, bạn có thể thêm URL của ESP8266 và phân tách các URL bằng dấu phẩy, như sau:

http://arduino.esp8266.com/stable/package_esp8266com_index.json, https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

3. Mở trình quản lý Boards Manager. Bạn có thể đi tới Tools > Board > Boards Manager… hoặc bạn chỉ cần nhấp vào biểu tượng Boards Manager ở góc bên trái.

4. Tìm kiếm ESP8266 và cài đặt thử viện esp8266 by ESP8266 Community..

Nó sẽ được cài đặt sau một vài giây.

Để kiểm tra cài đặt tiện ích bổ sung ESP8266, chúng ta sẽ thử nạp vào Board mạch một đoạn code đơn giản làm nhấp nháy đèn LED trên bo mạch (GPIO 2).

/*BlinkTurns an LED on for one second, then off for one second, repeatedly.https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink*/// the setup function runs once when you press reset or power the boardvoid setup() {// initialize digital pin LED_BUILTIN as an output.pinMode(LED_BUILTIN, OUTPUT);}// the loop function runs over and over again forevervoid loop() {digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)delay(1000); // wait for a seconddigitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOWdelay(1000); // wait for a second}

Trên menu thả xuống trên cùng, chọn “unknown” board. Một cửa sổ mới, như hình bên dưới, sẽ mở ra.

Chọn kiểu bo mạch ESP8266 và cổng COM. Trong ví dụ này, chúng ta đang sử dụng bảng NodeMCU 1.0. Bây giờ, bạn chỉ cần nhấp vào nút nạp code .Sau khoảng 30 giây, quá trình tải lên sẽ hoàn tất.Đèn LED trên bo mạch ESP8266 sẽ nhấp nháy mỗi giây. Để thay đổi thời gian nhấp nháy của đè led bạn chỉ cần thay đổi giá trị trong hàm delay().

Thử quan sát thành quả của mình nhé.

Chúng tôi hy vọng bạn thấy hướng dẫn series này hữu ích. Bạn đã học được cách cài đặt và nạp code cho ESP8266.Muốn tìm hiểu thêm? Chúng tôi sẽ liên tục cập nhật các chia sẻ mới hãy theo dõi bài tiếp theo.[Lập Trình ESP8266] Hướng Dẫn Cài Đặt Và Nạp Code Đầu Tiên Cho ESP8266

The ESP8266 community created an add-on for the Arduino IDE that allows you to program the ESP8266 using the Arduino IDE and its programming language.

This tutorial shows how to install the ESP8266 board in Arduino IDE whether you’re using Windows, Mac OS X or Linux.

Uploading the Sketch

Uploading the Sketch to the ESP-12E

If you’re using an ESP-12E NodeMCU Kit, uploading the sketch is very simple, since it has built-in programmer. Plug your board to your computer. Make sure you have the right board selected:

You also need to select the Port:

Then, copy the code provided:


/********* Rui Santos Complete project details at https://randomnerdtutorials.com *********/ int pin = 2; void setup() { // initialize GPIO 2 as an output. pinMode(pin, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(pin, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(pin, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

Click the “Upload” button in the Arduino IDE and wait a few seconds until you see the message “Done uploading.” in the bottom left corner.

Uploading the Sketch to the ESP-01

Uploading code to the ESP-01 requires establishing a serial communication between your ESP8266 and a FTDI Programmer as shown in the schematic diagram below.

The following table shows the connections you need to make between the ESP8266 and the FTDI programmer.

ESP8266 FTDI programmer
RX TX
TX RX
CH_PD 3.3V
GPIO 0 GND
VCC 3.3V
GND GND

If you have a brand new FTDI Programmer and you need to install your FTDI drivers on Windows PC, visit this website for the official drivers: http://www.ftdichip.com/Drivers/VCP.htm.

Then, you just need to connect the FTDI programmer to your computer, and upload the sketch to your ESP8266 board. You should see the “Done Uploading” message after a few seconds.

How to program esp8266 using arduino
How to program esp8266 using arduino

Step 5: Setup ESP8266 Support

When you’ve restarted, select NodeMCU 0.9 (or NodeMCU 1.0) from the Tools->Board dropdown Config the Board menu and choose the right Port for your device. CPU Frequency:80MHz,Flash Size:4M(3M SPIFFS),Upload Speed:115200 Now just proceed as the Arduino: Start your sketching! Note: 115200 baud upload speed is a good place to start – later on you can try higher speeds but 115200 is a good safe place to start.

There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language. In this tutorial we’ll show you how to install the ESP32 board in Arduino IDE whether you’re using Windows, Mac OS X or Linux.

Using Arduino 2.0? Follow this tutorial instead: Installing ESP32 Board in Arduino IDE 2.0

Selecting the NodeMCU Board Driver

The NodeMCU now needs to be selected in the IDE.

Navigate to the Boards Manager from the Tools…Board…Boards Manager menu option (the very first option in the list).

A new options window will appear.

From the Boards Manager window, enter esp8266 in the search bar.

This will display the new ESP8266 driver as supplied by the ESP8266 Community. At the bottom of the options box, select the version to be set up (select the most recent version).

Now select Install to complete the installation of the driver which will take a few seconds to download and install.

Select Close to complete the installation.

Arduino IDE: Fixing 'No Port' Error & Installing Drivers for ESP32, Arduino Uno, and ESP8266 NodeMCU
Arduino IDE: Fixing ‘No Port’ Error & Installing Drivers for ESP32, Arduino Uno, and ESP8266 NodeMCU

Step 2: Install the COM/Serial Port Driver

In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to ESP8266 IOT Board and the other side to your computer’s USB port.

The new version NodeMCUv1.0 comes with the CP2102 serial chip,you can download and install the driver from:https://www.silabs.com/products/development-tools/…. The NodeMCUv0.9 comes with the CH340 serial chip,you can download and install the driver from:https://github.com/nodemcu/nodemcu-devkit/tree/mas…

Step 12: Uploading the Program to ESP8266 Module

On the blink example code change all number 13 to number 16 and then click on the right arrow shown in the figure to upload the program to the module. This will start blinking the on board led on the nodemcu module

void setup()

{// initialize digital pin 16 as an output.

pinMode(16, OUTPUT);

// the loop function runs over and over again forever

void loop()

delay(10);

digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(16, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

How To Install Arduino IDE 2.1.1 / 2.2.1, CP2102 Drivers, ESP32 Boards to Windows 11 & Program
How To Install Arduino IDE 2.1.1 / 2.2.1, CP2102 Drivers, ESP32 Boards to Windows 11 & Program

Step 4: Install the ESP8266 Board Package

Enter http://arduino.esp8266.com/stable/package_esp8266… into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences (Open Arduino IDE–>File–>Perferences–>Settings). Enter the link and click “OK” to save your changes. Next, use the Board Manager to install the ESP8266 package Enter the Boards Manager and find the board type as below: Scroll the Broads Manager screen down to the bottom, you will see A module called “esp8266 by esp8266 Community” (see following picture), select the latest version and click “Install“. The ESP8266 package has benn installed successfully. Note: You’d better close the Arduino IDE and restart it again.

Install ESP8266 Add-on in Arduino IDE

To install the ESP8266 board in your Arduino IDE, follow these next instructions:

  1. In your Arduino IDE, go to File> Preferences

  2. Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into the “Additional Boards Manager URLs” field as shown in the figure below. Then, click the “OK” button:

    Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma as follows:

    https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

  3. Open the Boards Manager. Go to Tools > Board > Boards Manager…

  4. Search for ESP8266 and press install button for the “ESP8266 by ESP8266 Community“:

  5. That’s it. It should be installed after a few seconds.

Send Data From Arduino to NodeMCU and NodeMCU to Arduino Via Serial Communication
Send Data From Arduino to NodeMCU and NodeMCU to Arduino Via Serial Communication

Troubleshooting

If you try to upload a new sketch to your ESP32 and you get this error message “A fatal error occurred: Failed to connect to ESP32: Timed out… Connecting…“. It means that your ESP32 is not in flashing/uploading mode.

Having the right board name and COM por selected, follow these steps:

  • Hold-down the “BOOT” button in your ESP32 board
  • Press the “Upload” button in the Arduino IDE to upload your sketch:
  • After you see the “Connecting….” message in your Arduino IDE, release the finger from the “BOOT” button:
  • After that, you should see the “Done uploading” message

That’s it. Your ESP32 should have the new sketch running. Press the “ENABLE” button to restart the ESP32 and run the new uploaded sketch.

You’ll also have to repeat that button sequence every time you want to upload a new sketch. But if you want to solve this issue once for all without the need to press the BOOT button, follow the suggestions in the next guide:

If you experience any problems or issues with your ESP32, take a look at our in-depth ESP32 Troubleshooting Guide.

Arduino IDE and NodeMCU – Conclusion

This completes the configuration of the Arduino IDE to allow for the programming of the NodeMCU ESP8266. The ability to interface to the NodeMCU is endless with everything from LEDs, temperature sensors, motor controllers and servos, LCD displays, moisture sensors, and more. The possibilities are endless.

There are many great resources for programming information and coding examples. YouTube is an excellent place to watch for information and tutorials, along with the Arduino support site.

[Fully Explained]--Single Data--Serial Communication between Arduino and NodeMCU (ESP8266)
[Fully Explained]–Single Data–Serial Communication between Arduino and NodeMCU (ESP8266)

Keywords searched by users: nodemcu in arduino ide

Quick Start To Nodemcu (Esp8266) On Arduino Ide : 3 Steps (With Pictures) -  Instructables
Quick Start To Nodemcu (Esp8266) On Arduino Ide : 3 Steps (With Pictures) – Instructables
Arduino & Nodemcu | Add Wifi And Gpios | Tutorial # 31 - Youtube
Arduino & Nodemcu | Add Wifi And Gpios | Tutorial # 31 – Youtube
Getting Started With Esp8266 12E Or Nodemcu Using Arduino Ide - Youtube
Getting Started With Esp8266 12E Or Nodemcu Using Arduino Ide – Youtube
Installing Esp8266 In Arduino Ide (Windows, Mac Os X, Linux) | Random Nerd  Tutorials
Installing Esp8266 In Arduino Ide (Windows, Mac Os X, Linux) | Random Nerd Tutorials
Interfacing Arduino Uno With Nodemcu - Icircuit
Interfacing Arduino Uno With Nodemcu – Icircuit
Nodemcu Nodemcu I2C With Arduino Ide | Nodemcu
Nodemcu Nodemcu I2C With Arduino Ide | Nodemcu
Nodemcu Nodemcu Gpio With Arduino Ide | Nodemcu
Nodemcu Nodemcu Gpio With Arduino Ide | Nodemcu
Send Data From Arduino To Nodemcu And Nodemcu To Arduino... - Hackster.Io
Send Data From Arduino To Nodemcu And Nodemcu To Arduino… – Hackster.Io
Send Data From Arduino To Nodemcu And Nodemcu To Arduino... - Hackster.Io
Send Data From Arduino To Nodemcu And Nodemcu To Arduino… – Hackster.Io
Steps To Setup Arduino Ide For Nodemcu Esp8266 : 14 Steps - Instructables
Steps To Setup Arduino Ide For Nodemcu Esp8266 : 14 Steps – Instructables
Two Way Serial Communication Between Nodemcu And Arduino - Programming  Questions - Arduino Forum
Two Way Serial Communication Between Nodemcu And Arduino – Programming Questions – Arduino Forum
Installing Esp8266 Board In The Arduino Ide: Step-By-Step Guide
Installing Esp8266 Board In The Arduino Ide: Step-By-Step Guide
How To Program Nodemcu With Arduino Ide - Iotguider
How To Program Nodemcu With Arduino Ide – Iotguider
How To Add And Use Nodemcu V3 With Arduino Ide | Getting Started | Esp8266  - Youtube
How To Add And Use Nodemcu V3 With Arduino Ide | Getting Started | Esp8266 – Youtube
Intro To Nodemcu And Arduino Ide | Microcontroller Tutorials
Intro To Nodemcu And Arduino Ide | Microcontroller Tutorials
Interfacing Arduino Uno With Nodemcu - Icircuit
Interfacing Arduino Uno With Nodemcu – Icircuit
Nodemcu Esp8266 Vs. Arduino Uno Board - Makerguides.Com
Nodemcu Esp8266 Vs. Arduino Uno Board – Makerguides.Com
Nodemcu Nodemcu I2C With Arduino Ide | Nodemcu
Nodemcu Nodemcu I2C With Arduino Ide | Nodemcu
Esp8266 Getting Started With Arduino Ide | Benn Thomsen
Esp8266 Getting Started With Arduino Ide | Benn Thomsen
How To Program Esp8266-12E Using Arduino Ide - Hackster.Io
How To Program Esp8266-12E Using Arduino Ide – Hackster.Io
How To Program Nodemcu With Arduino Ide - Youtube
How To Program Nodemcu With Arduino Ide – Youtube
Receive Data In Nodemcu 8266 From Arduino Uno - Project Guidance - Arduino  Forum
Receive Data In Nodemcu 8266 From Arduino Uno – Project Guidance – Arduino Forum
Arduino | Lolin Nodemcu V3 Esp8266 With Arduino | Getting Started | Control  The Led - Youtube
Arduino | Lolin Nodemcu V3 Esp8266 With Arduino | Getting Started | Control The Led – Youtube
How To Program Esp8266 Nodemcu With Arduino Ide | Led Blink - Electric Diy  Lab
How To Program Esp8266 Nodemcu With Arduino Ide | Led Blink – Electric Diy Lab
Quick Start To Nodemcu (Esp8266) On Arduino Ide : 3 Steps (With Pictures) -  Instructables
Quick Start To Nodemcu (Esp8266) On Arduino Ide : 3 Steps (With Pictures) – Instructables
Serial Communication Between Nodemcu And Arduino - Iotguider
Serial Communication Between Nodemcu And Arduino – Iotguider
Esp8266 Nodemcu Http Get And Http Post With Arduino Ide | Random Nerd  Tutorials
Esp8266 Nodemcu Http Get And Http Post With Arduino Ide | Random Nerd Tutorials

See more here: kientrucannam.vn

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *