example
esp8266
ESP8266 network device driver
28100.9.0kameleon-core
esp8266networknetwifiesp-01
README.md

Overview

1582692155265.jpg

A network device driver for ESP8266 module (AT command).

Tested firmware versions:

ModuleManufacturerAT versionSDK version
ESP-01Ai-Thinker Technology Co. Ltd.1.2.0.01.5.4.1

Wiring

Here is a wiring example for UART0 of Kameleon Core.

ESP8266Kameleon Core
VCC3V3
GNDGND
TXD7 (UART0 RX)
RXD6 (UART0 TX)
CH_PD3V3

1583381462648.png

Usage

You can register ESP8266 network device driver using UART interface as below:

var UART = require('uart').UART;
var serial0 = new UART(0, {baudrate: 115200, bufferSize: 2048});
var wifi = require('wifi');
var esp8266 = require('@niklauslee/esp8266');

esp8266.setup(serial0, () => {
  var connectInfo = {ssid: "iptime", password: "12345678"};
  wifi.connect(connectInfo, err => {
    if (err) {
      console.error(err);
    } else {
      // You can use networking API ('net', 'http', etc.) after Wi-Fi connection.
    }
  });
});

We recommend you do not place Wi-Fi SSID and password in the code. Instead, you can enter WIFI_SSID and WIFI_PASSWORD using storage API as below in Terminal. Then, you can omit the connectInfo parameter.

Enter below lines in Terminal:

storage.setItem('WIFI_SSID', 'iptime');
storage.setItem('WIFI_PASSWORD', '12345678');

Then, you can connect Wi-Fi without connection info as below:

// ...
wifi.connect(err => {
  if (err) {
    console.error(err);
  } else {
    // You can use networking API ('net', 'http', etc.) after Wi-Fi connection.
  }
})