Wifi with ESP8266 - Part 3

Having received (in less than 2 weeks in fact) my devkit ordered from ebay, I was able to carry on my investigations.

As noted before, the devkit comes with a USB connection and power regulator. Same principle as on the Arduino boards. The version bought is the newest devkit 1.0 (AKA v2 on Seeedstudio).

NodeMCU Devkit 1.0

First try

NodeMCU 0.9.5 build 20150403  powered by Lua 5.1.4
Will run user.lc/user.lua in 1000ms
> Please run file.remove("user.lua") before first use.
Please run file.remove("user.lua") before first use.
Please run file.remove("user.lua") before first use.
Please run file.remove("user.lua") before first use.

OK... bizarre but a quick check with Google gives a workaround:

file.remove("user.lua")
node.restart()

According to one post, there are two Lua files inside a new board: init.lua and user.lua. These are used for factory testing purpose only. Now the message has become:

NodeMCU 0.9.5 build 20150403  powered by Lua 5.1.4
Will run user.lc/user.lua in 1000ms
> cannot open user.lua

And for information purpose, the content of the "init.lua" file:

> file.open("init.lua", "r")
> print(file.read())
--init.lua, something like this
print("Will run user.lc/user.lua in 1000ms")
tmr.alarm(0,1000,1,function()
  tmr.stop(0)
  local s,err
  if file.open("user.lc") then
    file.close()
    s,err = pcall(function() dofile("user.lc") end)
  else
    s,err = pcall(function() dofile("user.lua") end)
  end
  if not s then print(err) end
end)

> file.close()

So far so good...

Connecting to the Internet

Same procedure as last time:

  • Setting "Wifi Station" mode => OK
  • Registering SSID and password => OK
  • Obtening a IP address => OK
  • Connecting to an external website => variable
  • Connecting from a browser to the module => KO

For some reason, there is a incompatibility between most firmwares and my Wifi router. :-(

Time to try with a different/more recent firmware.

Flashing disaster

As we say in french "Never Two Without Three". So after the HM-12 and the ESP-201, something was bound to go awry!

Using the latest version of esptool, I uploaded a new firmware... flashing was reported as successful but the module couldn't even boot! And this was the case with all firmware I tried.

As as I discovered, this is because the devkit 1.0 is based on the ESP-12E board. The "E" letter is important as it means the flash is 4 MB (or 32Mb) instead of the 512 KB (2Mb) standard model. The mechanism address the flash seems different and it is essential to use specific parameters like:

./esptool.py write_flash -fm=dio -fs=32m  0x0 nodemcu_latest.bin

I.e. using DIO for flash_mode (instead of QIO) and 32Mb for flash_size (instead of 2Mb).

Then, at least I could boot! But the filesystem (used by LUA) was destroyed and the list of files was returning strange data.

It took me long while to find a way clear it (obviously file.format() didn't work) but I, at last, managed it by running:

./esptool.py erase_flash

That said, it is still impossible to open any file from LUA. There are a few comments about this problem on the Seeedstudio page, so I am not alone. I actually wonder if the nodemcu builds are truly compatible with this new hardware!

EDIT (02/07/2015):

Many thanks to Johny Mattsson for his workaround to this issue and for taking the time to notify me. I am happy to report that the new esptool.py (on dev branch) now unlocks the filesystem. See pull-request note Workaround write-protected flash when using esptool.py to flash in DIO mode for more information.

New access point

I happened to have a spare (old) wifi router.

And with this new set-up, TCP connections were fine either as a client or as a server!!!!

How annoying (and unpractical as I don't really want to multiply routers). And also what a waste of time and energy. Since all types of firmwares (AT, nodemcu, arduino's) are plagued by this problem, it might be link to the Espressif's SDK I presume. But I still can't pinpoint what exactly is happening and why some IPs are reachable while others are not.

At least, I could play with my two modules.

The story so far...

  • 2 modules 'ESP-201' and devkit 1.0 (using an ESP-12E)
  • Can't use my main Wifi Router but works fine on another one (except with a very old original firmware for the ESP-201)
  • LUA Filesystem broken on the devkit 1.0 (haven't retried on the ESP-201) making the use of nodemcu very unpractical

Like this blogger, who seems to have quite a lot of experience on ESP8266 modules, I am now convinced that Arduino's ecosystem is the way to go, at least for now.

TBC...