ESP8266 Module
Info & Guides
NurdSpace complete guide
Electrodragon
LUA Programming Language
http://www.esp8266.com/
Software
CoolTerm - Free Serial Terminal Emulator
nodemcu Firmware & Programmer - LUA Firmware
LuaLoader - Great MultiFunctional software (run the file as Administrator if you do not see your comm port)
ESPlorer - IDE for ESP8266 developers
Pin-Outs
ESP8266
CH340 Programmer
Quick Guide
lua code
wifi.setmode(wifi.STATION);
wifi.sta.config({ssid="YOURROUTERNAME",pwd="YOURROUTERPASSWORD"});
gpio.mode(4, 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><b> Arduino Virgins - IoT LED</b></h1><form src=\"/\">Turn GPIO2 <select name=\"pin\" onchange=\"form.submit()\">";
local _on,_off = "",""
if(_GET.pin == "ON")then
_on = " selected=true";
gpio.write(4, gpio.HIGH);
elseif(_GET.pin == "OFF")then
_off = " selected=\"true\"";
gpio.write(4, gpio.LOW);
end
buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>";
client:send(buf);
client:close();
collectgarbage();
end)
end)
Notes
You should see the following web page
ESP8266 PROJECT NOTES
A high percentage of the project information was taken from Julian Ilets Videos shown below.
Part 1 of 4
Part 2 of 4
Part 3 of 4
Part 4 of 4
This may also be useful. More information from Great Scott
TO-DO
Create a colour wiring schematic in Fritzing.
Take a video of it working.
Upload more scripts.
NurdSpace complete guide
Electrodragon
LUA Programming Language
http://www.esp8266.com/
Software
CoolTerm - Free Serial Terminal Emulator
nodemcu Firmware & Programmer - LUA Firmware
LuaLoader - Great MultiFunctional software (run the file as Administrator if you do not see your comm port)
ESPlorer - IDE for ESP8266 developers
Pin-Outs
ESP8266
CH340 Programmer
Quick Guide
- Wire up 8266 as per schematic above.
- Confirm communications are working to the 8266 with Coolterm.
- Set the 8266 into 'Flash update' mode by setting GPI00 to GND.
- Reset the power to the device.
- Download Flasher & firmware found here and flash the firmware to the ESP8266.
- Confirm comms again with Coolterm noting the change in firmware.
- Set the 8266 into 'Flash update' mode by setting GPI00 to GND.
- Reset the power to the device.
- Download nodemcu found here and flash the ESP8266 with 'ESP8266Flasher' using the default binary (nodemcu_latest.bin: 0x00000).
- Confirm comms again with Coolterm. a status line similar to
- 'NodeMCU 0.9.5 build 20150311 powered by Lua 5.1.4' will indicate LUA firmware is now installed.
- Download LuaLoader from here and set it to your correct Com Port. If LuaLoader does not see your Com Port set it to run as 'Administrator' in the file compatibility settings.
- You can now use LuaLoader to load programs onto the ESP8266 like the one below . . .
Webserver with web enabled LED
lua code
wifi.setmode(wifi.STATION);
wifi.sta.config({ssid="YOURROUTERNAME",pwd="YOURROUTERPASSWORD"});
gpio.mode(4, 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><b> Arduino Virgins - IoT LED</b></h1><form src=\"/\">Turn GPIO2 <select name=\"pin\" onchange=\"form.submit()\">";
local _on,_off = "",""
if(_GET.pin == "ON")then
_on = " selected=true";
gpio.write(4, gpio.HIGH);
elseif(_GET.pin == "OFF")then
_off = " selected=\"true\"";
gpio.write(4, gpio.LOW);
end
buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>";
client:send(buf);
client:close();
collectgarbage();
end)
end)
Notes
- Replace YOUROUTERNAME with the name of your own router and YOUROUTERPASSWORD with your routers password.
- Upload this code using LuaLoader by copying it to your clipboard and using the 'Paste Text' button in LuaLoader to upload it to the ESP8266.
- Connect an LED negative to a 220Ohm resistor, and the other end of the resistor to GND. Then connect the positive end of the LED to the GPIO2 pin on the ESP8266. . . . schematic to follow.
- Use the 'Get IP' button in LuaLoader to get the IP address of the ESP8266(if you do not see a response of 'nil'you probably have the wrong routername and password setup in the above step).
- Put the first address in your web browser. Its normally something like 192.168.0.20
You should see the following web page
ESP8266 PROJECT NOTES
- My ESP8266-01 Module was set to 9600 baud by default.
- After flashing it with ver 0.92 baud rate was 115200bps.
- It CAN NOT be powered by the CH340 programmer. It has to have its own supply of 3.3v @ 20-250mA.
A high percentage of the project information was taken from Julian Ilets Videos shown below.
Part 1 of 4
Part 2 of 4
Part 3 of 4
Part 4 of 4
This may also be useful. More information from Great Scott
TO-DO
Create a colour wiring schematic in Fritzing.
Take a video of it working.
Upload more scripts.
Hi!
ReplyDeleteI would like control more GPIO . Can you help me add more button in the sourche code?
Thanks