ESP8266 ESP-07 Wifi Transceiver LED On Off

by Dimitris Harir

I bought a very inexpensive wifi transceiver the from ESP8266 ESP-07 ebay. The ESP8266 has powerful on-board processing and storage capabilities that allow it to be used with sensors and other application specific devices through its GPIOs with minimal development up-front and minimal loading during runtime. Its high degree of on-chip integration allows for minimal external circuitry.

 

I will show you how to update the firmware of the module and control a green led.

 

The ESP8266 has many versions mine has 16 pins VCC, GND, REST, CH_PD, ADC (analog to digital converter), RX, TX, and 9 GPIO pins. To send and receive data we need to connect it to the computer with an RS232 to serial converter, I used the CP2102. ESP8266 is 3.3 volt tolerant  so VCC RX TX need to be 3.3 volt. VCC will be connected to 3.3 volt output of the CP2102 to connect CP2102 RX and ESP8266 TX you may try without level shifter 3.3V should be enough for logical one in CP2102.  Just connect CP2102 RX and ESP TX pin. If that doesn’t work use level shifter. We must level shift the CP2102 TX to 3.3v before connecting it to the ESP8266 RX, just use a simple voltage divider like in the photo below.

ghjm

I didn’t use any level shifting on the RX and TX of the CP2102 i connected them directly the TX RX on the ESP8266 but this may damage the module. You also have to pull up the CH_PD just connect it to VCC throw a 10K resistor. To flash new firmware you also need to connect GPIO0 to GND and now you are ready to connect the CP2102 to a COM port on the Coputer.

ESP8266                CP2102

VCC             –>          3.3V

CH_PD       –>         3.3V Throw a 10k resistor

RX              –>          TX

TX             –>           RX

GPIO0      –>          GNB

GND         –>           GND

 

Go to https://github.com/nodemcu and download the nodemcu-flasher. After downloading the flasher extrack the .zip file and open the nodemcu-flasher-master folder and go to Win32 if you have 32 bit  windows or Win64  if you have 64 bit then find the δτφκιESP8266Flasher.exe and run it.

 

 

 

 

 

 

 

The ESP8266Flasher looks like this if you have connected the ESP8266 to the PC with CP2102 the COM Port will change automatically to the COM port that the CP2102 is connected if not change it. At Last press Flash(F) and wait. When it will finish it will look like the photo below.

δτφκιbhjk.l

 

 

 

 

 

cgvhk

Now disconnect GPIO0 from GND, close the nodemcu-flasher  and go to https://github.com/hwiguna/g33k/tree/master/ArduinoProjects/Windows/ESP8266_Related and download the latest version mine is LuaUploader_1.0.2.4.zip unzip the file and open the LuaUploader. It will look like this.

cgvhk

 

 

 

 

 

 

 

 

Go to Immediate and copy paste the following code that i found in “https://github.com/nodemcu/nodemcu-firmware” at Connect to your AP

wifi.setmode(wifi.STATION)
    wifi.sta.config("SSID", "password")

press execute

cgvhk

then type

ip = wifi.sta.getip()
    print(ip)

press execute
cgvhk
Great, our little ESP8266 module is connected to our local network with an IP 192.168.43.12.

 

Lets control the led now.

 

Go to the Editor in the Lua Uploader and then got to https://github.com/nodemcu/nodemcu-firmware and then to lua_examples and finally to webap_toggle_pin.lua. copy paste the code but comment out or delete the fist 2 lines because the causing  a problem. Also you mast add

ip = wifi.sta.getip()
print(ip)

in the top of the code.

 cgvhk

in the Lua Uploader change the Filename from my.lua to init.lua and press Save to ESP.

cgvhk

ip = wifi.sta.getip()
print(ip)
gpio.mode(1, gpio.OUTPUT)
srv=net.createServer(net.TCP) 
srv:listen(80,function(conn) 
    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"); 
        end
        local _GET = {}
        if (vars ~= nil)then 
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do 
                _GET[k] = v 
            end 
        end
        buf = buf.."<h1> Hello, Showme your code.</h1><form src=\"/\">Turn PIN1 <select name=\"pin\" onchange=\"form.submit()\">";
        local _on,_off = "",""
        if(_GET.pin == "ON")then
              _on = " selected=true";
              gpio.write(1, gpio.HIGH);
        elseif(_GET.pin == "OFF")then
              _off = " selected=\"true\"";
              gpio.write(1, gpio.LOW);
        end
        buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>";
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)

OK that is it. Connect a LED to the GPIO05 throw a 100-200 Ohm resistor and from a phone or pc in the same network go to the module IP address mine is 192.168.43.12 , you can tern on and off the led. I made this circuit. The ESP8266 want only 3.3V to work, the CP2102 is not needed. I made a hot spot with my phone and a can tern on and off the led gust be going to the browser and typing 192.168.43.12

IMG_20160130_015910

5 Comments on “ESP8266 ESP-07 Wifi Transceiver LED On Off

  1. I simply want to mention I am just all new to blogging and site-building and definitely liked you’re web-site. Very likely I’m want to bookmark your site . You surely come with incredible posts. Thanks a lot for revealing your web page.

Leave a Reply

Your email address will not be published. Required fields are marked *