Setup Wifi AP with ESP8266 with NodeMCU

Now lets do some programming on the device. You will find lot of examples on internet. In this demo, we will setup Wifi AP with ESP8266 and wait for connections. NodeMCU firmware runs init.lua when the module is rebooted. That is why you see a message when you connect ESP8266 with NodeMCU firmware just flashed.

lua: cannot open init.lua

Open the ESPlorer IDE and on the left side, start entering the following piece of code.

cfg = {}
cfg.ssid = "ESDEMO"
cfg.pwd = 'welcome1234'
wifi.ap.config(cfg)

This will just setup the ESP8266 in AP mode. Click Save and save the file as init.lua. ESPLorer will now transfer the file to the module and run it. You can scan for wifi network using your mobile or any other device. It will show a wifi network with SSID ESDEMO. You can connect to the network use the password welcome1234

Some tips

1. If you have a large program, you might see error messagaes for insuffecient memory. In such cases, split your program into multiple files. These additional files should have functions only. Then you can load these files only when it is required.
2. Use a custom build of NodeMCU. You can do it at http://nodemcu-build.com/ instead of having a build setup of your own. You will be able to select the modules that you want and exclude others. This saves a few KBs for your program.

Leave a Reply

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