Monday, September 15, 2014

Experimenting with the ESP8266 $5 wifi module

Before I start this blog post I'd like to profusely thank Joshua Newell ‏@ImJoshNya for providing the code, wiring basis and serial settings used in this experiment. The massive amount of support and assistance encountered in the maker community is a huge part of why I love it so much, all of you have been so supportive and receptive to my own inane ideas and provided a lot of input of your own.  

         Recently the maker community was all abuzz about (alliteration eh?) a new WiFi chipset that was at a record low price ($5 or less/board) that included not only WiFi connection but also the ability to simultaneously connect and broadcast its own access point, in addition to having an onboard microprocessor that has GPIO (General Purpose Input Output) pins easily triggered on this standalone unit. The whole unit is slightly smaller than the ubiquitous NRF24L01 with the same 2X4 header interface (with different pinouts though). For $5 this will quite literally boost the IOT (Internet Of Things) maker movement to a whole new level like the widely used NRF24L01 did for basic RF communication and sensor meshes. Well as this is a VERY new module there exists (as of the time of writing) no Arduino libraries but I'd be willing to bet that within 2 months there will be a plethora of both libraries and variants of this amazing chipset. After reading the Hackaday post about this module, I went and bought one off of the quintessential EBay. Unlike most of these modules for sale which shipped from China and took a week or so, I got mine form a US seller so it arrived in 3 days and at a better price point than most Chinese sellers. In addition to the module, this seller provided me with extensive documentation in proper English that hadn't hit the internet yet. You can find said documentation Here. The module I received was "V2 GPIO" with an additional LED and 2 GPIO pins broken out. Details on the different versions after the break.
Prior versions has only one LED and no GPIO pins. There are 5 distinct variants of this module;

ESP-01:
The most common module with printed PCB antenna:
-2x4 2.54 mm pitch header
-built-in PCB-printed antenna
-2 GPIOs: GPOI0/2
-UART URXD/UTXD
-RESET and CH_PD (powerdown)
-VCC/GND
-14.2 mm W x 14.2 mm L
ESP-02:
A less common module with antenna connector, that may be compatible with breadboards:
-Dual 1x4 2.54 mm pitch header in DIP form factor
-built-in U-FL connector for external antenna
-2 GPIOs: GPOI0/2
-UART URXD/UTXD
-RESET and CH_PD (powerdown)
-VCC/GND
-14.7 mm W x 14.2 mm L
ESP-03:
A SMT (Sufrace Mount Technology) module with all pins broken out to castellated pads with built-in ceramic antenna:
-Dual 1x7 2 mm pitch castellated pads
-built-in ceramic antenna
-7 GPIOs: GPOI0/2/12/13/14/15/18
-UART URXD/UTXD
-RESET and CH_PD (powerdown)
-VCC/GND
-12.2 mm W x 17.4 mm L
ESP-04:
Another SMT (Sufrace Mount Technology) module with all pins broken out to castellated pads without built-in antenna:
-Dual 1x7 2 mm pitch castellated pads
-external antenna on pad
-7 GPIOs: GPOI0/2/12/13/14/15/18
-UART URXD/UTXD
-RESET and CH_PD (powerdown)
-VCC/GND
-12.0 mm W x 15.0 mm L
ESP-05:
A simple UART-only module with antenna connector:
-Single 1x4 2.54 mm pitch header
-built-in U-FL connector for external antenna*]No GPIO
-UART URXD/UTXD
-No RESET nor CH_PD (powerdown)
-VCC/GND
-14.2 mm W x 14.2 mm L
The test rig
NRF24L01 and ESP8266 size comparison
ESP8266 module detail

I purchased the ESP-01 version for $5 with shipping, it arrived 3 days later and I immediately set to work on getting it to interface with my Arduino Uno using standard serial protocol. Unfortunately, I hooked it up correctly but it would not respond at all over serial. The RX light was flashing so it was receiving the command but not talking back at all. I tried pulling the CH_PD and GPIO pins high but that did not elicit a response. After asking around I found out that I likely had the baud rate wrong. Asked around and Josh was extremely helpful in instructing me how to connect it properly (put CH_PD to high) and sent me updated code Here. This had the proper baud rates of 115200 and 38400  (the ESP8366 communicates at 115200 and I was only running it at 9600). With the baud rates correct the module started talking back on serial. After initializing the RF stack, it connected to the wifi and started TCP connections. I am completely new to wifi integration in projects and am learning off of borrowed code for now. Hopefully by christmas I will have a project completed that uses this module (likely a door lock that unlocks and switches on the lights when I come home from school)

3 comments:

  1. Frr shipping to the US - but $14 shipping to the UK making this unfeasable for some... why do American companies do this when they must know China ships such small items for free. I have one of these by the look of it.. and though I can talk to it, I cannot get it to connect to the WIFI... going to have to learn how to re-flash it I guess... thanks for the info.

    ReplyDelete
    Replies
    1. Ye gods! I suggest getting one of the slightly pricier ones from china

      Delete
    2. Here is an explanation as to why it costs more to ship to the UK (http://www.washingtonpost.com/news/storyline/wp/2014/09/12/the-postal-service-is-losing-millions-a-year-to-help-you-buy-cheap-stuff-from-china/)

      Delete