ESP 8266

Internet of Things

ESP8266 is low cost and highly integrated IC with Xtensa processor, RF front end, build-in TCP-IP stack which make this IC perfect for Internet of Thing WIFI connectivity.

FEATURES

  • 802.11 b / g / n
  • Wi-Fi Direct (P2P), soft-AP
  • Built-in TCP / IP protocol stack
  • Built-in TR switch, balun, LNA, power amplifier and matching network
  • Built-in PLL, voltage regulator and power management components
  • 802.11b mode + 19.5dBm output power
  • Built-in temperature sensor
  • Support antenna diversity
  • off leakage current is less than 10uA
  • Built-in low-power 32-bit CPU: can double as an application processor
  • SDIO 2.0, SPI, UART
  • STBC, 1×1 MIMO, 2×1 MIMO
  • A-MPDU, A-MSDU aggregation and the 0.4 Within wake
  • 2ms, connect and transfer data packets
  • standby power consumption of less than 1.0mW (DTIM3)

My first ESP was from Olimex: https://www.olimex.com/Products/IoT/MOD-WIFI-ESP8266-DEV/open-source-hardware

Programming ESP

Firmware

The ESP8266 board may have one of many different firmware versions on it. Many come with AT firmware for serial communications. Some come with no user firmware at all. I use the NodeMCU Lua firmware as a starting point because it gives you an interactive programming language which allows you to experiment and build simple working programs without a lot of effort.

The tool you will use to flash the NodeMCU firmware on your ESP8266 board is the nodemcu-flasher https://github.com/nodemcu/nodemcu-flasher. It is open source on github.

ESP8266Flasher.exe for Win32 https://github.com/nodemcu/nodemcu-flasher/blob/master/Win32/Release/ESP8266Flasher.exe?raw=true

ESP8266Flasher.exe for Win64 https://github.com/nodemcu/nodemcu-flasher/blob/master/Win64/Release/ESP8266Flasher.exe?raw=true

Connections

    Power.
        +3.3 volts to Vcc
        ground
    Communications.
        TxD on the board to RxD on the adapter
        RxD on the board to TxD on the adapter
        Ground
    Jumpers.
        Connect Vcc to CH_PD to enable the chip
        Connect GPI0 to GND to enable flash reprogramming

For ESP-12E here it is the connection:

 normal/default boot mode
  • GPIO0 -> HIGH
  • GPIO2 -> HIGH
  • GPIO15 -> LOW
    upload/flash mode.
  • GPIO0 -> LOW
  • GPIO2 -> HIGH
  • GPIO15 -> LOW
  • Baudrate: 57600
  • Flash size: 4MByte
  • Flash Speed: 40MHz
  • SPI Mode: DIO

Flashing firmware

Plug the USB to serial adapter into your PC. Most adapters are automatically recognized by Windows 7 and 8. Users of XP or older versions of Windows may need a driver which should be supplied by the manufacturer of the USB adapter. The adapter will appear as a new COM port on your system. Check the Device Manager if necessary.

Run ESP8266Flasher.exe

If you only have one COM device, the port will appear automatically. If you have more than one, select the correct one from the drop down menu.

The flasher program comes with default NodeMCU firmware in memory. This is unlikely to be the latest version, but to get started quickly, use the default internal image. Later, you can download the latest firmware, then select the [Config] tab and choose the new .bin file. Select the 0x7C000 default and 0x7E000 blank sections. Uncheck the box for the 0x10000 IROM section.

Click on Flash(E) to start the programming process. If the MAC addresses don't appear within a few seconds, disconnect the power to the board and reconnect it. If it still doesn't work, check your connections. Make sure that the jumper between GND and GPIO0 is there so that the board is in reflash mode.

Reflashing the chip will take a couple of minutes. When the job is done, disconnect power from the board and remove the jumper from GND to GPIO0 to leave reflash mode.

You are now ready to program the ESP8266 for your own application.

Programming

LuaLoader is a Windows program for uploading files to the ESP8266 and working with the Lua serial interface. As well as being a simple terminal program, it has built in Lua command buttons that make it easy to interact and experiment with the ESP8266 board. http://benlo.com/esp8266/index.html#LuaLoader

Download: http://benlo.com/esp8266/LuaLoader.zip

LuaLoader.exe is a simple Windows application that requires no special installation.

 From the Settings menu, select COM Port Settings and choose the appropriate COM port for your USB to serial adapter. Don't change any other setting.

Clicking buttons on LuaLoader sends commands to the board. Power your board and watch for the initial message. After displaying some funny characters (these are firmware reset parameters sent at 74880 baud), you should see the version information of the NodeMCU build:

NodeMCU 0.9.5 build 20150107 powered by Lua 5.1.4

LuaLoader will warn you if a later firmware build is available.

After booting, NodeMCU will attempt to run a file called init.lua in flash memory. Since you haven't put it there, it will report an error and show the > prompt. You are now ready to interact with Lua on the ESP8266.

[heap command] Click the Heap button to display the amount of RAM available. LuaLoader will type the command = node.heap() and the ESP8266 will respond with 23016 or some other value, followed by the > prompt again.

Commands