General purpose WIFI control board x4 based on ESP8266-03

I’ve just finished getting the ESP8266 working. I can now configure it via a web browser and the LUA based firmware will also allow me to control 4 signal, on and off, that can feed relays or other low consumption devices.

ESP8266-03-x4ControlBoard-v01Pic2 ESP8266-03-x4ControlBoard-v01Pic1

Check the video on Youtube


Next is the temperature logger…

Image | Posted on by | Leave a comment

ESP8266 Breadboard Adapter with Reset and Flash jumper (8266BBA01) available on Tindie and eBay

The 8266BBA01 ESP8266 Breadboard Adaptor makes it easy to connect the ESP8266 to a breadboard or standalone for programming and testing. An 8 pin 0.1 inch pitch terminal is available in the bottom to directly connect to a breadboard.

An 8 pos screw terminal is available to get access to all the ESP8266 pins without soldering. A 2×4 socket makes it really easy to switch ESP8266 modules for quick testing and programming. (ESP8266 not included)

Order it on Tindie or eBay

Esp8266_Breadboard_v01_01 Esp8266_Breadboard_v01_02 Esp8266_Breadboard_v01_03 Esp8266_Breadboard_v01_04 Esp8266_Breadboard_v01_05 Esp8266_Breadboard_v07_01 Esp8266_Breadboard_v01_06 copy

Posted in Uncategorized | Leave a comment

ESP8266 based web configurable wifi general purpose control (Part III)

NOTE: Ready to go boards can be purchased here

The electronics part

InPart I and II we saw how to program and remotely configure the ESP8266 to turn it into a processor of TCP events. Now we will take those events and turn them into something useful by controlling a set of switches.

We start with a dual 4 bit binary counter, 74LS393N. This chip has 2 full 4 bit binary counters. We will connect the inputs together and the resets together. GPIO0 from the ESP8266 will be connected to the inputs and GPIO2 to the reset.  The output of the 393 will go into ULN2803 which is a 8xdarlington driver. The 2803 will drive relays or any other low power stuff. A set of leds will indicate which output is on.

Now when a TCP GPIO High/Low event is sent to the module IP address port 9999, this event will be redirected to the binary counter. The process is as follows:

  • a low/high event on GPIO2 sent to the port will reset the binary counter
  • a low/high event on GPIO0 sent to the port will count once
  • an ‘n’ low/high events on GPIO0 sent to the port will count ‘n’ times
  • with this arrangement we can count to 16 on each 1.2 of the binary counter.
  • we will use each of the 4 bits outputs to drive a signal (led, relay, etc)
  • one low/high events on GPIO0 will turn on output 1A and 1B
  • 2 low/high events on GPIO0 will turn on output 2A and 2B
  • 3 low/high events on GPIO0 will turn on output 1A, 2A, 1B and 2B
  • 16 low/high events on GPIO0 will turn on all outputs
  • a low/high event on GPIO2 will reset the binary counter and turn off all outputs.

Quite simple. Here is the circuit.


and the breadboard


Watch the prototype


Video | Posted on by | 8 Comments

ESP8266 based web configurable wifi general purpose control (Part II)

NOTE: Ready to go boards can be purchased here

On Part II I will go over how to program the ESP8266 so a USB to serial module and a terminal is not necessary: it will all be done via web. Also, I will explain how to drive a binary counter and control 4 relays (multi on/multi off) using GPIO0 as control and GPIO2 as reset. This way the ESP8266 really turns into a powerful device that can be added to any automation project and its easy to program on site.

The control firmware

The firmware needs to be able to allow the user to connect to the module and set the SSID and password of the network the module will be connected to. The steps to design the firmware are as follows:

  1. set the module to server (AP) mode
  2. set a name and password
  3. create a server
  4. listen on port 80
  5. module address is
  6. present a web page asking for SSID and password
  7. switch to Station mode and set SSID and password
  8. connect to network
  9. start listening for events coming on the ip address assigned by the network and port 9999

Here is the code to do it:“init.lua”,”w”)
file.writeline([[print(“WIFI control”)]])
— put module in AP mode
file.writeline([[print(“ESP8266 mode is: ” .. wifi.getmode())]])
— Set the SSID of the module in AP mode and access password
file.writeline([[if ssid and password then]])
file.writeline([[print(“ESP8266 SSID is: ” .. cfg.ssid .. ” and PASSWORD is: ” .. cfg.password)]])
— Now you should see an SSID wireless router named ESP_STATION when you scan for available WIFI networks
— Lets connect to the module from a computer of mobile device. So, find the SSID and connect using the password selected
file.writeline([[ap_mac = wifi.ap.getmac()]])
— create a server on port 80 and wait for a connection, when a connection is coming in function c will be executed
file.writeline([[c:on(“receive”, function(c, pl)]])

— print the payload pl received from the connection

— wait until SSID comes back and parse the SSID and the password
file.writeline([[if ssid_start and ssid_end then]])
file.writeline([[amper1_start, amper1_end =string.find(pl,”&”, ssid_end+1)]])
file.writeline([[if amper1_start and amper1_end then]])
file.writeline([[http_start, http_end =string.find(pl,”HTTP/1.1″, ssid_end+1)]])
file.writeline([[if http_start and http_end then]])
file.writeline([[ssid=string.sub(pl,ssid_end+1, amper1_start-1)]])
file.writeline([[password=string.sub(pl,amper1_end+10, http_start-2)]])
file.writeline([[print(“ESP8266 connecting to SSID: ” .. ssid .. ” with PASSWORD: ” .. password)]])
file.writeline([[if ssid and password then]])
— close the server and set the module to STATION mode
file.writeline([[print(“ESP8266 mode now is: ” .. wifi.getmode())]])
— configure the module wso it can connect to the network using the received SSID and password
file.writeline([[print(“Setting up ESP8266 for station mode…Please wait.”)]])
file.writeline([[print(“ESP8266 STATION IP now is: ” .. wifi.sta.getip())]])
file.writeline([[print(“ESP8266 AP IP now is: ” .. wifi.ap.getip())]])
— now the module is configured and connected to the network so lets start setting things up for the control logic

file.writeline([[tmr.delay(10) ]])
file.writeline([[sv=net.createServer(net.TCP, 30) ]])
file.writeline([[c:on(“receive”, function(c, pl)]])
file.writeline([[if tonumber(pl) ~= nil then]])
file.writeline([[if tonumber(pl) >= 1 and tonumber(pl) <= 16 then]])
file.writeline([[for count =1,tonumber(pl) do]])
file.writeline([[ print(count)]])
file.writeline([[tmr.delay(10) ]])
file.writeline([[ gpio.write(9,gpio.LOW)]])
file.writeline([[c:send(“Sequence finished”) ]])

file.writeline([[print(“ESP8266 STATION IP now is: ” .. new_ip)]])

file.writeline([[c:send(“ESP8266 STATION IP now is: ” .. new_ip) ]])

file.writeline([[c:send(“Action completed”) ]])

— this is the web page that requests the SSID and password from the user
file.writeline([[c:send(“<!DOCTYPE html> “)]])
file.writeline([[c:send(“<html lang=’en’> “)]])
file.writeline([[c:send(“<body> “)]])
file.writeline([[c:send(“<h1>ESP8266 Wireless control setup</h1> “)]])
file.writeline([[mac_mess1 = “The module MAC address is: ” .. ap_mac]])
file.writeline([[mac_mess2 = “You will need this MAC address to find the IP address of the module, please take note of it.”]])

file.writeline([[c:send(“<h2>” .. mac_mess1 .. “</h2> “)]])
file.writeline([[c:send(“<h2>” .. mac_mess2 .. “</h2> “)]])
file.writeline([[c:send(“<h2>Enter SSID and Password for your WIFI router</h2> “)]])
file.writeline([[c:send(“</form> </body> </html>”)]])
file.writeline([[c:send(“<form action=” method=’get’>”)]])
file.writeline([[c:send(“<input type=’text’ name=’SSID’ value=” maxlength=’100′ />”)]])
file.writeline([[c:send(“<br />”)]])
file.writeline([[c:send(“<input type=’text’ name=‘Password’ value=” maxlength=’100′ />”)]])
file.writeline([[c:send(“<input type=’submit’ value=’Submit’ />”)]])

Loading the firmware and testing

Load the file with the code written above as explained in Part I. Once the file is sent to the module you should do a node.restart() and will see the following:

OK. The module is now in AP mode so it is like a WIFI router and you should see ESP_STATION on your list of WIFI networks.


Now connect to ESP_STATION using the password that you have programmed into the firmware, “the_ESP8266_WIFI_password” above. Now connect to from a browser. You should see the webpage below. Enter SSID and password of your WIFI network so the ESP8266 can connect to it.



After a few seconds of waiting you should receive a message on the web browser with the IP address assigned to the module by your router; if you get a, just refresh the browser pointing to and you should get the new IP address. Since for this test we are monitoring the ESP8266 through a serial terminal, lets check what the output was:



On your browser you should see:


Now the ESP8266 is connected to our WIFI network and has IP address However, if you don;t get the browser to show the IP address, you can always refer to the MAC address of the ESP8266 shown on the SSID/Password entry page and the user will have to find the IP address by going into the router setup, depending on what kind of router that is. I will in the future figure out how to ensure that IP address is always posted back to the browser.


On Part II we saw how to configure the ESP8266 directly from a web browser and bypassing the USB to serial. Now we are getting closer to something that can be commercialized.

On Part III (yes, sorry, I chopped it into 3 parts) I will show how to connect the GPIO0 and GPIO2 signals to some binary counters and driver to drive relays or any other device.

Posted in Uncategorized | 7 Comments

ESP8266 based web configurable wifi general purpose control (Part I)

NOTE: Ready to go boards can be purchased here

From AT commands to firmware controlled

The kind of new ESP8266 wifi module is not only cheap, about 3-4 dollars, its also a pretty versatile module that enables tons of remote control applications (yeah, internet of things). The first project that came to mind is to move my antenna switch control from being run by a RaspberryPi board and an 8 relay board, which makes the project pass the 100 dollar mark, to being controlled itself by a wifi board that can be programmed. Well, the ESP8266 was the solution for me, and cheap! I will describe the project, and although it is not finished yet, I will get as far as I can and then continue updating as I progress.

 Getting started

There is plenty of material out there to get anyone going. The key things to know is that you will need a USB to serial module to initially talk to the ESP8266. Any FTDI232 based module will pretty much work. Then you need to chose a serial terminal to send commands to the serial module that will send commands to the ESP8266. Something like CoolTerm or SSCOM32 would do the job. I use SSCOM on Windows and CoolTerm on the Mac, simply because CoolTerm for Windows is not working for me (crashes). Also, when you start copying LUA code into the module, CoolTerm does a great job.

My setup

ESP8266 of course, pic below.


Any USB to serial module would do it. Here is one:



Now connect them as below. Note that GPIO0 should be left floating except for firmware upgrade.

esp8266-reflash-firmware copy

Getting ready to load new firmware

Connect your ESP8266 module as follows:

  • Vcc = 3.3V (needs around 300-400mA peak)
  • Gnd = -ve ground
  • CH_PD = Chip enable so always +ve
  • RST = Leave floating or ground to reset
  • GPIO0 = Normally floating but this needs to be grounded when you start the update.
  • UTXD = Tx data connect to Txd on FTDI/Serial interface
  • URXD = Rx data connect to Rx of FTDI/Serial interface

You also need to download the new firmware and update tool from ElectroDragon: The firmware tool is called XTCOM

Before you start the update, make sure your ESP8266 is working normally as follows:

  1. Connect-up as above but leave GPIO0 floating.
  2. Access the serial interface with a terminal program such as PuTTY or Termite.
  3. Set the terminal s/w baud rate to either 57600 or 115200 (depends on whether you have an early or later model). The CoolComponents models are 115200.
  4. Power-up the ESP8266 and you should see some readable text indicating that it’s ready. If you get nonsense try changing the baud rate.
  5. If all is well, try some AT commands.
  6. Try AT+RST which should re-start the module.
  7. Try AT+GMR which should give the firmware version.
  8. NB: When entering AT commands there are no spaces and you cannot use backspace to correct errors as each character is sent as it is typed!

If all is well, you can move on to the firmware update.

Loading the LUA interpreter firmware

This project requires firmware programming in LUA, so the next thing we will do is load the firmware. Here you can find more detailed instructions on how to load firmware and a number of tools to do it. Lets download the LUA firmware from here. And the flash tool from here. Flash the module making sure you pull down GPIO0, and turn the module off and on; flash start memory is 0x000000.
Disconnect GPIO0, turn the module off and on, If everything went smooth, now you can type node.restart() on the serial terminal (I’m using CoolTerm on Mac for this example) and you should get a response like in the picture below.


Simple LUA example

Lets look at very simple example of programming the module. We will use the startup functionality built in the LUA firmware as follows:

  1. create a file named init.lua
  2. write LUA commands into this file
  3. close the file

This file will get executed every time the module boots. This gives you a lot of possibilities if you want to use the module as a server or a device responding to events. A complete reference to the ESPressif SDK can be found here. Lets write some simple code.

– Open the file for writing“init.lua”,”w”)
— Write a simple text message that will be echoed to the terminal
file.writeline([[print(“Some simple message”)]])
— Set the mode to SOFTAP
— Get the new mode and print it
file.writeline([[print(“ESP8266 mode is: ” .. wifi.getmode())]])
— Close the file

Put these code in a file (textfile) and we will send the text file to the ESP8266 using CoolTerm. Make sure that the Connection->Options>transmit settings allow a delay so the lines can be transmitted without error, as follows:


Select Connection->Options->Send textfile and send the above file. You should get the output below:


Yeah! All working! Now lets get a bit more complex.

A more elaborated LUA example: GPIO0 blinker with reset signal on GPIO2

We will write some code that sets up GPIO0 and GPIO2, creates a TCP server and turns GPIO0 on and off ‘n’ number of times according to the value sent through TCP, upon completion of the sequence it turns GPIO2 off and on so it can be use as a reset signal. Here it goes:

– Open the file for writing“init.lua”,”w”)
— Open the file for writing
file.writeline([[print(“GPIO0 blinker and GPIO2 reset”)]])
— Open GPIO0 and 2 for output
— Wait a bit to ensure completion
file.writeline([[tmr.delay(10) ]])
— Cycle GPIO2 so it can be use as reset signal
— Create TCP server
file.writeline([[sv=net.createServer(net.TCP, 30) ]])
— Listen on port 9999, and callback function ‘c’
— Wait until payload ‘pl ‘ is received
file.writeline([[c:on(“receive”, function(c, pl)]])
— Check for valid number received (should be between 1 and 16 for this example)
file.writeline([[if tonumber(pl) ~= nil then]])
file.writeline([[if tonumber(pl) >= 1 and tonumber(pl) <= 16 then]])
— Send another reset event on GPIO2
— Loop according to the number received
file.writeline([[for count =1,tonumber(pl) do]])
file.writeline([[ print(count)]])
file.writeline([[tmr.delay(10) ]])
— Blink GPIO0
file.writeline([[ gpio.write(9,gpio.LOW)]])
file.writeline([[c:send(“Sequence finished”) ]])
file.writeline([[c:send(“Action completed”) ]])

Lets send the file to the module. You should see the output below:


Lets do a node.restart(), you should see the first welcome message and the program will go into wait for an event to come from port 9999.


Now you need to connect the module to the network, so lets issue the following commands. You will need your wifi router SSID and password :



To test the events receiving part, you can use any old TCP terminal emulator, I use ‘TCP Test Tool” for iPhone, and it allows me to connect and send data to the module. Here is a screen picture of the iPhone app, connected to port 9999 and sending the number 8, receiving back the messages.


Now lets see what we received on the serial terminal:


And there you go, we received the number eight and cycled through the blinker 8 times, that means GPIO0 cycled 8 times while GPIO2 cycled once to indicate a reset at the end of the sequence.


The ESP8266 is a cheap but powerful self contained wifi computer. It can be controlled through firmware upload and if you chose to do it with the LUA firmware, things get quite simple and results are achieved. The possibilities are limitless. On the next posting I will explain how to program the ESP8266 so a USB to serial module and a terminal is not necessary: it will all be done via web. Also, I will explain how to drive a binary counter and control 4 relays (multi on/multi off) using GPIO0 as control and GPIO2 as reset. This way the ESP8266 really turns into a powerful device that can be added to any automation project and its easy to program on site.


I tried to list all the helpful resources I found, I’ll update as more show up.

ESP8266 specs, descriptions, etc, by Nurdsape
Firmware that lets you easily control the GPIO0 and GPIO2 pins, by Electrodragon
ESP8266 community GitHub space. Web server example, Arduino example, bcc compiler and code examples
Firmware upgrade detailed instructions by UKHASnet
More documentation, SDK, firmware, flash tool, XTCOM tool, etc
More tools, documents, toolchain for Linux and Windows
LUA based interactive firmware, examples and tools by NODEMCU
SSCOM32E.exe serial terminal
ESP8266 and LUA examples  by Scargill
Problems with FTDI drivers? Check this out
ESP8266 specs, descriptions, tools from Electrodragon
ESP8266 firmware and SDK by ESPressif
Find most of the available firmware versions on this link

Posted in Uncategorized | 9 Comments

Ham Radio Wireless Antenna Selector

As a spinoff the speaker control project, I have developed a wireless antenna selctor. It handles 4 different antennas, selectable through web browser or an iphone app.
A Raspberry Pi is used as the main controller running apache, python and php. A Custard Pi board with 8 relays is used to communiate with the Raspberry Pi and handle the switching of the antenna lines. Shortly I will post pictures of the project and app.

Posted in Uncategorized | Leave a comment

Co-creation and crowdsourcing in Oil and Gas software: paving the future for highly technical software.

The challenges faced by the Oil and Gas industry are enormous. The easy reservoirs have been found and are mostly depleted. Oil companies need to replace their reserves, hence they need to find new proven assets. Whatever is left to be found is well hidden, difficult to detect, difficult to identify, and extremely difficult to model and develop. Existing reservoirs that are currenlty being produced need to be handle with extreme care, ensuring that oil or gas recovery is maximized and production is optimized. Fortunately, a new class of reservoirs entered the picture a decade or so ago: unconventionals. Unconventional reservoirs are a class of reservoir type that fundamentally differs from classic reservoirs. Unconventional reservoirs are plenty and distributed across the globe. They have brought a new hope for asset replacement. In unconventional reservoirs, Oil or gas is trapped in very low porosity and very low permeability medium. The science for exploring and modeling these reservoirs is much less developed than that for conventional reservoirs. Producing these reservoirs require also new techniques such as fracking, expensive and resource intense. Optimization of these production techniques is of utmost importance.
Going forward we will increasingly be looking in more challenging environments, reservoir with only become most complex and the technology and science needed to successful exploit them with need to continue to grow at a rapid pace to keep up.
Software is pervasive across these wide spectrum of big challenges. There is no single person, group or company that can provide solutions to all these challenges. Collaboration is needed to converge to efficient solutions that solve the problems at hand. But collaboration is not enough. Efficient solutions need diversity of approach, different points of view that compete but also build upon each other making the end solution much more efficient and powerful.
Oil and gas professionals and experts who use software to address their challenges must work together to find solutions, but to be able to do it within the boundaries and policies of their organizations, a proper software solution is indispensible.
Since the introduction of computers in the geosciences world (oil and gas, exploration through production) back in the 70s and 80s, the standard software product used were single software packages that did something (or somethings) very well in the user’s opinion. Using this single, monolithic packages, the user had access to what he or she considered to be the best technology available. The IT departments loved it because there was a single infrastructure to maintain, and data managers enjoyed it due to the fact that there was one data storage to maintain. This single monolithic packages did not allow other players to come and deliver technology on top of them. They were close. As things got more and more complex towards the end of the 80s and through the 90s, single packages could not address all the needs of the geoscientists, so they opted for bringing in different packages. Each package, usually from a different vendor, will offer best in class technology according to the user’s criteria. This is a scenario that is frightening for IT and Data Managers. Usually each different product needs a different IT infrastructure and a different data management scheme. As for the single package, it was not possible to have 3rd parties developing technology on top of them. Closed systems.
But things kept getting more and more complex. To the point the industry realized that there was no way a single vendor or even a handful of large vendors, could deliver all the technology needed to solve the huge challenges faced. A different paradigm was needed. The new paradigm was a combination of software platform and extensibility. A platform could be defined as a major piece of software, as an operating system, an operating environment, or a database, under which various smaller application programs can be designed to run through an extensibility layer. Oil and gas companies, by means of using a platform with robust extensibility capabilities, can then consume technology from many 3rd party vendors, not only technologies produced by the platform vendor. This diversity of technologies give the oil and gas company a much larger spectrum of choices. Additionally, oil and gas companies can develop their own technology on top of the platform.
The combination of platform and extensibility brings the opportunity for new business models in oil and gas software. Small vendors, even a one man shop, can now produce differentiating technology and deliver it to large companies through the platform, provided the platform is open to anyone to deliver technology on top of it. Even more, several vendors can deliver solutions in the same space, which creates a healthy competition that naturally advances the quality of the solutions.
An open and extensible platform is a petri dish for innovation. By allowing small and big players alike to develop and deploy technology to such a demanding, difficult and mature industry as oil and gas, it naturally nurtures co-creation, because it enables anyone to participate in the improvement of the workflows that can be executed within the platform. Modules from different vendors can participate in a single workflow, adding value to the end user. A successful extensible platform for oil and gas will enable co-creation and crowdsourcing within a very conservative industry and will shape the future of how very complex challenges are addressed efficiently.

Posted in Uncategorized | Tagged , , , , , , | Leave a comment