Convert Figma logo to code with AI

esp8266 logoArduino

ESP8266 core for Arduino

15,966
13,337
15,966
382

Top Related Projects

Arduino core for the ESP32

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer

Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips

Quick Overview

The esp8266/Arduino repository is an open-source project that provides Arduino core support for ESP8266 Wi-Fi modules. It allows developers to program ESP8266 chips using the familiar Arduino IDE and ecosystem, making it easier to create IoT and embedded projects with Wi-Fi capabilities.

Pros

  • Easy integration with the Arduino ecosystem and IDE
  • Extensive library support for various sensors and peripherals
  • Active community and frequent updates
  • Low-cost hardware options for Wi-Fi-enabled projects

Cons

  • Limited processing power compared to more advanced microcontrollers
  • Higher power consumption than some alternatives
  • Potential stability issues in certain use cases
  • Learning curve for users new to ESP8266 specifics

Code Examples

  1. Connecting to Wi-Fi:
#include <ESP8266WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("YourSSID", "YourPassword");
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  
  Serial.println("Connected to WiFi");
}

void loop() {
  // Your code here
}
  1. Creating a simple web server:
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.begin("YourSSID", "YourPassword");
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  
  server.on("/", []() {
    server.send(200, "text/plain", "Hello from ESP8266!");
  });
  
  server.begin();
}

void loop() {
  server.handleClient();
}
  1. Reading a DHT sensor and publishing to MQTT:
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  dht.begin();
  WiFi.begin("YourSSID", "YourPassword");
  client.setServer("mqtt.example.com", 1883);
}

void loop() {
  if (!client.connected()) {
    client.connect("ESP8266Client");
  }
  
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  
  String payload = "Temperature: " + String(t) + ", Humidity: " + String(h);
  client.publish("sensor/dht", payload.c_str());
  
  delay(5000);
}

Getting Started

  1. Install the Arduino IDE
  2. Add ESP8266 board support:
    • Go to File > Preferences
    • Add http://arduino.esp8266.com/stable/package_esp8266com_index.json to Additional Boards Manager URLs
  3. Install ESP8266 board:
    • Go to Tools > Board > Boards Manager
    • Search for "esp8266" and install
  4. Select your ESP8266 board from Tools > Board menu
  5. Write your code, compile, and upload to the ESP8266

Competitor Comparisons

Arduino core for the ESP32

Pros of arduino-esp32

  • More powerful hardware with dual-core processor and increased memory
  • Better support for advanced features like Bluetooth and deep sleep modes
  • Newer platform with ongoing development and updates from Espressif

Cons of arduino-esp32

  • Slightly more complex setup and configuration process
  • Higher power consumption compared to ESP8266
  • Less mature ecosystem with fewer community libraries and resources

Code Comparison

ESP8266 (Arduino):

#include <ESP8266WiFi.h>

void setup() {
  WiFi.begin("SSID", "password");
}

ESP32 (Arduino):

#include <WiFi.h>

void setup() {
  WiFi.begin("SSID", "password");
}

The basic Wi-Fi connection code is very similar between the two platforms, with the main difference being the inclusion of different header files. However, the ESP32 offers more advanced features and APIs for tasks like Bluetooth communication and multi-core programming, which would require additional code specific to the ESP32 platform.

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Pros of nodemcu-firmware

  • Built-in Lua interpreter for easier scripting and rapid prototyping
  • More efficient memory usage due to optimized firmware
  • Includes a file system for storing Lua scripts and data

Cons of nodemcu-firmware

  • Limited Arduino library compatibility
  • Steeper learning curve for developers familiar with Arduino
  • Less frequent updates compared to Arduino core

Code Comparison

NodeMCU (Lua):

gpio.mode(4, gpio.OUTPUT)
tmr.create():alarm(1000, tmr.ALARM_AUTO, function()
    gpio.write(4, gpio.read(4) == gpio.HIGH and gpio.LOW or gpio.HIGH)
end)

Arduino:

void setup() {
  pinMode(4, OUTPUT);
}

void loop() {
  digitalWrite(4, !digitalRead(4));
  delay(1000);
}

Both examples demonstrate a simple LED blink on GPIO4, showcasing the syntax differences between Lua (NodeMCU) and C++ (Arduino). The NodeMCU version uses a timer for non-blocking execution, while the Arduino version uses a delay in the main loop.

esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer

Pros of esp-link

  • Specialized for WiFi-to-serial bridge functionality
  • Simpler setup for specific use cases like remote serial communication
  • Includes a web-based configuration interface

Cons of esp-link

  • More limited in scope compared to the broader Arduino ecosystem
  • Less active community and fewer resources for general ESP8266 development
  • May require additional effort for custom firmware development beyond its core functionality

Code Comparison

esp-link:

void ICACHE_FLASH_ATTR serbridgeInit() {
  uart_init(UART0, BIT_RATE_115200);
  uart_init(UART1, BIT_RATE_115200);
  system_os_task(serbridgeRecvTask, recvTaskPrio, recvTaskQueue, recvTaskQueueLen);
}

Arduino:

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

The esp-link code focuses on UART initialization and task setup for serial bridge functionality, while the Arduino code demonstrates a more general WiFi connection setup, showcasing the broader application scope of the Arduino framework for ESP8266.

Free and open (as much as possible) integrated SDK for ESP8266/ESP8285 chips

Pros of esp-open-sdk

  • Provides a complete, open-source toolchain for ESP8266 development
  • Offers more low-level control and customization options
  • Supports a wider range of ESP8266 modules and configurations

Cons of esp-open-sdk

  • Steeper learning curve and more complex setup process
  • Less extensive community support and documentation
  • Fewer ready-to-use libraries and examples compared to Arduino

Code Comparison

esp-open-sdk example:

#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"

void user_init(void) {
    // ESP8266 initialization code
}

Arduino example:

#include <ESP8266WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("SSID", "password");
}

void loop() {
  // Main program loop
}

The esp-open-sdk approach provides more direct access to ESP8266 hardware features, while Arduino offers a simpler, more abstracted programming model. Arduino is generally easier for beginners and provides a wide range of libraries, making it suitable for rapid prototyping. esp-open-sdk, on the other hand, is better suited for advanced users who require fine-grained control over the ESP8266 and are comfortable working with lower-level APIs.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Arduino core for ESP8266 WiFi chip

Quick links

Arduino on ESP8266

This project brings support for the ESP8266 chip to the Arduino environment. It lets you write sketches, using familiar Arduino functions and libraries, and run them directly on ESP8266, with no external microcontroller required.

ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and UDP, set up HTTP, mDNS, SSDP, and DNS servers, do OTA updates, use a file system in flash memory, and work with SD cards, servos, SPI and I2C peripherals.

Contents

Installing with Boards Manager

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit).

  • Download and install Arduino IDE 1.x or 2.x
  • Start Arduino and open the Preferences window
  • Enter https://arduino.esp8266.com/stable/package_esp8266com_index.json into the File>Preferences>Additional Boards Manager URLs field of the Arduino IDE. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).

Latest release Latest release

Boards manager link: https://arduino.esp8266.com/stable/package_esp8266com_index.json

Documentation: https://arduino-esp8266.readthedocs.io/en/3.1.2/

Using git version

Also known as latest git or master branch.

Using PlatformIO

PlatformIO is an open source ecosystem for IoT development with a cross-platform build system, a library manager, and full support for Espressif (ESP8266) development. It works on the following popular host operating systems: macOS, Windows, Linux 32/64, and Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).

Building with make

makeEspArduino is a generic makefile for any ESP8266 Arduino project. Using make instead of the Arduino IDE makes it easier to do automated and production builds.

Documentation

Documentation for latest development version: https://arduino-esp8266.readthedocs.io/en/latest/

Issues and support

ESP8266 Community Forum is a well-established community for questions and answers about Arduino for ESP8266. Stackoverflow is also an alternative. If you need help, have a "How do I..." type question, have a problem with a 3rd party library not hosted in this repo, or just want to discuss how to approach a problem, please ask there.

If you find the forum useful, please consider supporting it with a donation.
Donate

If you encounter an issue which you think is a bug in the ESP8266 Arduino Core or the associated libraries, or if you want to propose an enhancement, you are welcome to submit it here on Github: https://github.com/esp8266/Arduino/issues.

Please provide as much context as possible, as well as the information requested in the issue template:

  • ESP8266 Arduino core version which you are using (you can check it in Boards Manager)
  • your sketch code; please wrap it into a code block, see Github markdown manual
  • when encountering an issue that happens at run time, attach the serial output. Wrap it into a code block, just like the code.
  • for issues that happen at compile time, enable verbose compiler output in the IDE preferences, and attach that output (also inside a code block)
  • ESP8266 development board model
  • IDE settings (board choice, flash size)
  • etc

Contributing

For minor fixes of code and documentation, please go ahead and submit a pull request. A gentle introduction to the process can be found here.

Check out the list of issues that are easy to fix — easy issues pending. Working on them is a great way to move the project forward.

Larger changes (rewriting parts of existing code from scratch, adding new functions to the core, adding new libraries) should generally be discussed by opening an issue first. PRs with such changes require testing and approval.

Feature branches with lots of small commits (especially titled "oops", "fix typo", "forgot to add file", etc.) should be squashed before opening a pull request. At the same time, please refrain from putting multiple unrelated changes into a single pull request.

License and credits

Arduino IDE is developed and maintained by the Arduino team. The IDE is licensed under GPL.

ESP8266 core includes an xtensa gcc toolchain, which is also under GPL.

Esptool.py was initially created by Fredrik Ahlberg (@themadinventor, @kongo), and is currently maintained by Angus Gratton (@projectgus) under GPL 2.0 license.

Espressif's NONOS SDK included in this build is under Espressif MIT License.

ESP8266 core files are licensed under LGPL.

SPI Flash File System (SPIFFS) written by Peter Andersson is used in this project. It is distributed under the MIT license.

umm_malloc memory management library written by Ralph Hempel is used in this project. It is distributed under the MIT license.

SoftwareSerial library and examples written by Peter Lerup. Distributed under LGPL 2.1.

BearSSL library written by Thomas Pornin, built from https://github.com/earlephilhower/bearssl-esp8266, is used in this project. It is distributed under the MIT License.

LittleFS library written by ARM Limited and released under the BSD 3-clause license.

uzlib library written and (c) 2014-2018 Paul Sokolovsky, licensed under the ZLib license (https://www.zlib.net/zlib_license.html). uzlib is based on: tinf library by Joergen Ibsen (Deflate decompression); Deflate Static Huffman tree routines by Simon Tatham; LZ77 compressor by Paul Sokolovsky; with library integrated and maintained by Paul Sokolovsky.

Other useful links

Toolchain repo

Lwip link layer repo

SoftwareSerial repo

Serial Monitor Arduino IDE plugin Original discussion here, quick download there.

FTP Client/Server Library