Arduino ESP8266 WiFi Shield

ESP8266 Shield

This is a common ESP8266 Arduino shield with the following markings:

WiFi 2.4 GHz
802.11 b/g/n
Designed in
Beijing
P.R.China
Moer info $ tech
support Please go
to elecshop.ml
Arduino ESP8266 WiFi
Shield Version 1.0
by WangTongze

The voltage switching circuitry on this shield doesn't work properly as it arrives, so you'll have to modify it slightly if you intend it to work as a shield (with SW1 and SW2 set to ON).

The DIP switches are:

Switch Function
SW1 Connect ESP8266 TX to pin D0
SW2 Connect ESP8266 RX to pin D1
SW3 Enable bootloader mode
SW4 Use DFU LED to show serial activity (?)

Power is drawn from the 5v pin (not Vin) so if connecting to Pixl.js ensure that Vin and 5V are shorted on the solder jumper unless you plan to power the shield separately.

Using as-is

Rewiring

ESP8266 Shield ESP8266 Shield

Pixl.js

If connecting to Pixl.js you should be aware that when if Pixl.js detects a connection on D0 at boot, it'll start using Serial1 as a console device rather than the LCD.

To avoid this you'll need to explicitly set the console back to the LCD at boot time:

function onInit() {
  Terminal.setConsole();
}

Software

Note: your module may not come with ESP8266 AT firmware installed. To fix this, see the the ESP8266 page. If you're using Pixl.js you can now update the firmware on the ESP8266 module via the Flasher section of the Web IDE.

Client

To connect to a WiFi access point.

var WIFI_NAME = "WiFi_Name";
var WIFI_PASS = "WPA2_Key";
var wifi;

function getPage() {
  require("http").get("http://www.pur3.co.uk/hello.txt", function(res) {
    console.log("Response: ",res);
    res.on('data', function(d) {
      console.log("--->"+d);
    });
  });
}

function go() {
  Serial1.setup(115200,{rx:D0,tx:D1});
  wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) {
    if (err) throw err;
    console.log("Connecting to WiFi");
    wifi.connect(WIFI_NAME, WIFI_PASS, function(err) {
      if (err) throw err;
      console.log("Connected");
      // Now you can do something, like an HTTP request
      getPage();
    });
  });
}

Access point

To set up as an access point called ESP123 with password HelloWorld that serves up a webpage on address 192.168.4.1:

var wifi;

function pageHandler(req, res) {
  res.writeHead(200);
  res.end("Hello World");
}

function go() {
  Serial1.setup(115200,{rx:D0,tx:D1});
  wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) {
    if (err) throw err;
    console.log("Connecting to WiFi");
    wifi.createAP("ESP123","HelloWorld",5,"wpa2_psk", function(err) {   
      if (err) throw err;
      console.log("Connected!");
      require("http").createServer(pageHandler).listen(80);
    });
  });
}

See the ESP8266 page for more information on how to use the ESP8266, and the Internet page for more examples of things you can do on Espruino with an Internet connection.

Buying

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.