User Tools

Site Tools


Sidebar



esp8266

esp8266

>> AT\r\n
<< OK
>> AT+GMR\r\n
<< 00150900

Set Wifi mode to both Access Point and STAtion:

AT+CWMODE=3

List Access Points:

AT+CWLAP

get the connection status

AT+CIPSTATUS

restart the module

AT+RST

check SSID of connected network

AT+CWJAP?

get IP address

AT+CIFSR
send something to a UDP server running on your computer

- on your computer run a UDP server: nc -lu 10.0.0.161 9999 - then connect to the UDP server and send 5 bytes:

AT+CIPSTART=4,"UDP","10.0.0.161",9999
AT+CIPSEND=4,5
> 12345
SEND OK
setup a tcp server
AT+CIPMUX=1
AT+CIPSERVER=1,9999
AT+CIFSR

NodeMCU firmware

Flashing
NodeMCU API documentation
> =wifi.sta.getip()
10.0.0.209	255.255.255.0	10.0.0.1
> =wifi.ap.getip()
192.168.4.1	255.255.255.0	192.168.4.1
NodeMCU Lua ESP8266 ESP-12E WiFi Development Board
dir
function dir()
  l = file.list();
  for k,v in pairs(l) do
    print("name:"..k..", size:"..v)
  end
end
 
dir()
connect to your wifi network
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
print(wifi.sta.getip())
--192.168.18.110
create a http get function
function dns(domain,cb)
  sk=net.createConnection(net.TCP, 0) 
  sk:dns(domain,function(conn,ip) cb(ip) end) 
end

function httpget(domain,file)
  dns(domain, function(ip) 
    sk=net.createConnection(net.TCP, 0)
    sk:on("receive", function(sck, c) print(c) end )
    sk:connect(80,ip)
    sk:send("GET " .. file .. " HTTP/1.1\r\nHost: " .. domain .. "\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
  end)
end

Compile NodeMCU firmware yourself to disable certain modules

esp8266.txt · Last modified: 2015/10/14 17:49 by rick