GithubHelp home page GithubHelp logo

esp8266-driver's Introduction

THIS DRIVER IS EXPERIMENTAL Currently this driver is not stable, so we recommend to use ESP8266 AT commands directly.

ESP8266-driver

Kaluma network device driver for ESP8266 module (AT command). This module implements netdev and ieee80211dev device drivers using ESP8266 AT commands. With this device drivers you can use following builtin modules:

Tested firmware versions:

Module Manufacturer AT version SDK version
ESP-01 Ai-Thinker Technology Co. Ltd. 1.2.0.0 1.5.4.1

Wiring

Here is a wiring example for UART0.

Raspberry Pi Pico ESP8266
3V3 VCC, CH_PD
GND GND
GP0 (UART0 TX) RXD
GP1 (UART0 RX) TXD

wiring

Install

npm install https://github.com/niklauslee/esp8266-driver

Usage

If you wired ESP8266 module to UART0 you can setup simply as below:

require("esp8266-driver")
  .setup()
  .then(() => {
    // ...
  });

Otherwise you can setup with an UART instance as below.

var UART = require("uart").UART;
var serial0 = new UART(0, { bufferSize: 4096 });
var esp8266 = require("esp8266-driver");
esp8266.setup(serial0).then(() => {
  // ...
});

You can see all AT commands and response in Terminal if you pass debug parameter as true.

require("esp8266-driver")
  .setup(null, { debug: true })
  .then(() => {
    // ...
  });

The classes in wifi, net, http builtin modules should be instantiated after setup().

var WiFi = require("wifi").WiFi;
require("esp8266-driver")
  .setup()
  .then(() => {
    var wifi = new WiFi();
    var connectInfo = { ssid: "iptime", password: "12345678" };
    wifi.connect(connectInfo, (err) => {
      // ...
    });
  });

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.

> storage.setItem('WIFI_SSID', 'your_ssid');
> storage.setItem('WIFI_PASSWORD', 'your_password');

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

var WiFi = require("wifi").WiFi;
require("esp8266-driver")
  .setup()
  .then(() => {
    var wifi = new WiFi();
    wifi.connect((err) => {
      // ...
    });
  });

API

esp8266.setup([serial[, options]])

  • serial <UART> A serial connected to ESP8266 module. If this parameter is omitted, UART0 is used as default. Default: UART0.
  • options <object> Options to be passed to internal AT command class.
  • Returns: <Promise>

Initialize ESP8266 module.

Limitations

Socket address and port

Socket connection doesn't have localAddress, localPort, removeAddress, removePort. The reason is that the info is not provided at the time of connection using AT command. Extra AT command (AT+CIPSTATUS) is required to get the info.

If you need the info necessarily, recommend to use AT command directly.

Half-close

Half-closing is not supported. Trying to half-close will cause just close.

Don't support keep-alive

Web browsers uses keep-alive connection by adding Connection: keep-alive in HTTP request headers.

Testing

To run test cases on the board.

$ kaluma flash ./test.js --bundle --shell

esp8266-driver's People

Contributors

niklauslee avatar runc2333 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

runc2333

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.