ESP8266 12 series WiFi modules - Update:- out with Lua ..... in with Arduino IDE

In my quest to create standalone WiFi enabled Servo Stepper motor actuators, I stumbled across the ESP8266 WiFi family.

They are basically mcu's with WiFi communications.

  • 11 GPIO's and 1 ADC analog pin
  • 802.11 b/g/n protocol
  • Wi-Fi Direct (P2P), soft-AP
  • Integrated TCP/IP protocol stack
  • Integrated TR switch, balun, LNA, power amplifier and matching network
  • Integrated PLL, regulators, and power management units
  • +19.5dBm output power in 802.11b mode
  • Integrated temperature sensor
  • Power down leakage current of < 10uA
  • Integrated low power 32-bit CPU could be used as application processor
  • SDIO 2.0, SPI, UART
  • STBC, 1×1 MIMO, 2×1 MIMO
  • Wake up and transmit packets in < 2ms
  • Standby power consumption of < 1.0mW (DTIM3)

Out of the box I reprogrammed the firmware with NODEMCU (WIKI) which provides a Lua programming environment , which makes it easier to set things up (I also tested some AT command firmware and it also worked well too).

Note the Programming configuration GPIO-00 and GPIO-15 must be tied to ground for Firmware update, afterwards these can be removed, for programming I am using a basic FTDI module with the TX>RX & RX>TX crossed over.

To test the system through I used this code code here:-

Test Lua Code uploaded via a Esplorer Lua Gui
led1 = 3
led2 = 4
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
    conn:on("receive", function(client,request)
        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
        buf = buf.."<h1> ESP8266 Web Server</h1>";
        buf = buf.."<p>GPIO0 <a href=\"?pin=ON1\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF1\"><button>OFF</button></a></p>";
        buf = buf.."<p>GPIO2 <a href=\"?pin=ON2\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF2\"><button>OFF</button></a></p>";
        local _on,_off = "",""
        if( == "ON1")then
              gpio.write(led1, gpio.HIGH);
        elseif( == "OFF1")then
              gpio.write(led1, gpio.LOW);
        elseif( == "ON2")then
              gpio.write(led2, gpio.HIGH);
        elseif( == "OFF2")then
              gpio.write(led2, gpio.LOW);
                       8266 Series 12 GPIO Table
 IO index   ESP8266 pin  IO index ESP8266 pin
      0    GPIO_16      7    GPIO_13
      1    GPIO_05      8    GPIO_15
      2    GPIO_04      9    GPIO_03
      3    GPIO_00     10    GPIO_01
      4    GPIO_02     11    GPIO_09
      5    GPIO_14     12    GPIO_10
      6    GPIO_12    

Above Table is a cross table for programming ... i.e. toggle_ing  IO index 3 in code will toggle the actual output pin GPIO_00.

The code can be run from the Lua Gui.

The ESP8266 (IP does its interrogation and makes the WIFI TCP connection with "James"

and using a web browser window the WiFi module can be accessed.

Now I have the basic "Round Robin" working I will be checking out the PWM outputs and analog input.

It can be (and i have) programmed using the Arduino IDE using an ESP8266 addon, more on that will follow (I guess  a simplified MRLCOMM could be placed inside the ESP chip too)

UPDATE 20150810 :-

WIred a stepper motor onto 4 of the ESP8266 GPIO pins

(its just a small one for testing, bigger and better to follow :-)

Proof of concept Web Browser GUI ----- just Forward and Backwards

Update 20150815 (basic working reference) :- Web button auto repeat.

Buttons on web pages seem to be only submit once type things.

My project requires continuous pulses on press button....

after a bit of digging  (tnx for the tip kwatters)

Here is some HTML5 Code below allows for auto-repete onmousedown

<!DOCTYPE html>

<input type="button" onmousedown="mousedownfunc('counter')" value="Click-me" onmouseup="mouseupfunc('counter')" /><br/>
<div id="counter">1</div>

var intervalId; // keep the ret val from setTimeout()
function mousedownfunc(divid) {
    intervalId = setInterval(runme, 100, divid);

function mouseupfunc() {

function runme(divid) {
    document.getElementById(divid).innerHTML = parseFloat(document.getElementById(divid).innerHTML) + 1;



Update 20150816 :-

After using the Arduino IDE over the weekend I am happy to say that it is pretty stable.

I bumped into a sketch from sparkfun enabling the ESP8266 to act as a Server "ESP8266 Thing"

With a bit of tweaking I am able to extract the ESP8288's input pins / analog Pin and also flip Output pins too. (buttons for outputs are missing at momo - work in progress).

BTW .... just found out with this metal cased version of the ESP8266 its not possible to use all the I/O's as they have not brought out all of the pins onto the PCB ,they are mysteriously caged in (Duhhhh%&%ç&ç)

>>>>HTML5 ESP8266 Arduino IDE Button code (just the juicy bits)

String req = client.readStringUntil('\r');    // read in webpage details

// Stock buttons
   client.println("<input type=button value=ON onmousedown=location.href='/?on4'>");
   client.println("<input type=button value=OFF onmousedown=location.href='/?off5'>");       
   client.println("&nbsp;<input type=button value='ALL OFF' onmousedown=location.href='/?off3579'><br><br>");       
// radio buttons
   client.println("<input type=radio onmousedown=location.href='/?on6'>ON</>");
   client.println("<input type=radio onmousedown=location.href='/?off7'>OFF</>");
   client.println("&nbsp;<input type=radio onmousedown=location.href='/?off3579'>ALL OFF</><br><br>");   
 // custom buttons
   client.print("<input type=submit value=ON style=width:100px;height:45px onClick=location.href='/?on8'>");
   client.print("<input type=submit value=OFF style=width:100px;height:45px onClick=location.href='/?off9'>");
   client.print("&nbsp;<input type=submit value='ALL OFF' style=width:100px;height:45px onClick=location.href='/?off3579'>");

/////////////  e.g.    detection of button press's

if (req.indexOf("4") >0 )
  digitalWrite(4, HIGH);    // set pin 5 high
  if (req.indexOf("5") >0 )
  digitalWrite(4, LOW);    // set pin 5 low

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
GroG's picture

Wireless Elves ! Looks great

Wireless Elves !

Looks great Gareth .. 11 GPIOs & a ADC ! looks like a lot of remote potential.

With the WebGUI we have refined the protocol over HTTP, one thing which we have not explored is the idea of how minimal a "Service" could be..    the idea intrigues me..   

We could try to make an Angular Service for the ESP8266 - which utilizes MRL communication and its GUI but talks directly to your chip...


borsaci06's picture


I have been working on these tiny and versatile modules for a while... have at least 10 different versions and all are awesome... easy to work with... with or without arduino.... a mrl service will be wonderful.... 


GroG's picture

I've jumped into

I've jumped into experimentation of one of my ESP8266 finally !    Yay  \o/ .

This is my plan

1. Get it worky - with some default code / library
2. Write a module for it
3. Write a service for it

Alright .. step 1 ... looking for wiring diagrams and documentation :
Starting with

Since my module seems to most closely resemble the picture

One thing I find unusual about the instructable is how the author talks about a 7.5v power supply although its a 3V module yes ?

ok ... looks like he just mentioning the 7.5 as an input to some regulator he did not mention...

borsaci06's picture

esp8266 wifi


here is some link which I found best for esp8266:

you will find all u want in these documentation...

cheers ...



GroG's picture

Thanks Dincer ! I found this

Thanks Dincer !

I found this too - had some problems trying to figure out what are ESP8266 module had vs Gareths.
Gareth seems to have a fancy version :)

borsaci06's picture

esp8266 wifi


The version Gareth has is esp12 which has more GPIOs and more flash... in your version u have only 2 GPIOs.. u will talk to the module via rx and tx... only thing to remember: CH_PD pin must be always HIGH.... 

I always solder it together with VCC... The other thing is, if u want to upload new firmware then u have to set GPIO_0 to LOW while programming...  for the time being just simply send AT commands to the module via any terminal prg at 115200 baud... then u can try to do the same via sketches from arduino...

good luck and pls don't hesitate to ask for help when needed... I have many working scripts for esp8266...