Skip to content

Instantly share code, notes, and snippets.

@mpater
Last active October 1, 2016 15:00
Show Gist options
  • Save mpater/4210a8b35342abda6dadc60562cbd108 to your computer and use it in GitHub Desktop.
Save mpater/4210a8b35342abda6dadc60562cbd108 to your computer and use it in GitHub Desktop.
ESP8266 notes

http://www.cnx-software.com/2015/10/29/getting-started-with-nodemcu-board-powered-by-esp8266-wisoc/

#get firmware
wget https://github.com/nodemcu/nodemcu-firmware/releases/download/0.9.6-dev_20150704/nodemcu_integer_0.9.6-dev_20150704.bin

#flash firmware
sudo python ./esptool.py --port /dev/ttyUSB0 write_flash 0x00000 ../nodemcu_integer_0.9.6-dev_20150704.bin

###Documentation

http://nodemcu.readthedocs.io/en/latest/en/upload/ https://github.com/kmpm/nodemcu-uploader https://github.com/nodemcu/nodemcu-firmware

Building Firmware https://nodemcu-build.com/

Flashing Firmware https://nodemcu.readthedocs.io/en/master/en/flash/

sudo python esptool.py --port /dev/ttyUSB0 write_flash -fm dio -fs 32m 0x00000 <nodemcu-firmware>.bin

esptool.py --port <serial-port-of-ESP8266> erase_flash
esptool.py --port <serial-port-of-ESP8266> write_flash <flash options> 0x00000 <nodemcu-firmware>.bin <init-data-address> esp_init_data_default.bin

###Tutorial http://www.allaboutcircuits.com/projects/how-to-make-an-interactive-tcp-server-nodemcu-on-the-esp8266/

-- restart
node.restart()

-- format device 
file.format()

-- show free space
remaining, used, total = file.fsinfo()
print("\nFile system info:\nTotal: "..total.." Bytes\nUsed: "..used.." Bytes\nRemaining: "..remaining.." Bytes\n")

-- connect to network
wifi.setmode(wifi.STATION)
wifi.sta.config("wifi_name","wifi_pass") -- Replace these two args with your own network
ip, nm, gw=wifi.sta.getip()
print("\nIP Info:\nIP Address: "..ip.." \nNetmask: "..nm.." \nGateway Addr: "..gw.."\n")
# upload file to device
python luatool.py --port /dev/ttyUSB0 --src init.lua --dest init.lua --verbose

https://github.com/kmpm/nodemcu-uploader

http://blog.falafel.com/working-with-files-in-nodemcu-on-the-esp8266/

-- execute file
dofile("hello.lua")

-- 'cat'
file.open("hello/world.txt")
print(file.readline())

file.rename("hello.lua", "init.lua")

-- 'ls'
for k,v in pairs(file.list()) do l = string.format("%-15s",k) print(l.."   "..v.." bytes") end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment