The Wifi Project

Working with the ESP8266 board

last updated: Feb. 7, 2015

The ESP8266 is a 32 bit microcontroller with built-in wifi. The board I'm using has the ESP8266 with an antenna and a flash memory chip. It costs only $5. I've loaded an interpreter and wrote a few scripts to connect to my router and to log into an IRC channel.

Where I got the board


Loading the LUA interpreter

Flashing tool with the LUA interpreter

nodemcu flasher

This tool comes with obsolete firmware. I replaced it with NodeMCU build 20150126

script uploader

This is the tool for editing and loading of the scripts (for Windows)

My scripts

connect to the router (file name: init.lua)

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

The IRC script

// Most of this script is from channel = "#test14" function connect_callback(conn) conn:send("NICK robot222\r\n") conn:send("USER user_name 8 * :real name\r\n") conn:send("JOIN ""\r\n") end function receive_callback(conn, payload) print(payload) if string.find(payload, "PING :") == 1 then conn:send("PONG :" .. string.sub(payload, 7)) end pos = string.find(payload, "PRIVMSG "" :") if pos ~= nil then inmsg = string.sub(payload, pos + string.len(channel)+10) conn:send("PRIVMSG "" :did you say something like "..inmsg.."? \r\n") end end function startbot() conn:on("receive", receive_callback) conn:on("connection", connect_callback) conn:connect(6667, "") end -- The script starts here conn = net.createConnection(net.TCP, false) tmr.alarm(1, 1000, 1, function() if wifi.sta.getip()==nil then print("Waiting for connection...") else tmr.stop(1) -- maybe only stop it on successfull connection startbot() end end) --Script clips -- conn:send("PRIVMSG #test14 :hi...\r\n") -- conn:send("QUIT \r\n") -- print(wifi.sta.status()) -- 5 is what we want