rpiarduinomusings

Raspberry Pi, Arduino, Sensors and the data they produce

Monthly Archives: March 2017

Playing with a NodeMCU /8266 Debugging

Playing with a NodeMCU /8266 Debugging

For a deeper dive into the tools, I wanted to play with the NodeMCU /LUA environment (3) , while debugging a NodeMCU that I could not seem to get to take the arduino 8266 code.

The Arduino programming of 8266 was an extension of something I already was familiar with, but this one chip would not take a program through that method.
 I decided to look into the native code that comes from the factor, which is Based on NodeMCU.  I searched and found a tool called ESPlorer, but it was made in Russia.   At first I was a bit apprehensive, but then I found I could get the source code, meaning I could look at the code, and then setup from that which made me happy.
With this tool and a bit of learning from a couple of my favorite sites(1, 4), I was able to launch and run the code, and to get a response from the “wayward” chip.
I found a init.lua file that after inserting my SSD and passphrase, I was able to get it uploaded and executed:
=========================================================
–init.lua
wifi.setmode(wifi.STATION)
wifi.sta.config(“my-ssid”,”my-passphrase”)
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
    if wifi.sta.getip() == nil then
        print(“IP unavaiable, Waiting…”)
    else
        tmr.stop(1)
        print(“ESP8266 mode is: ” .. wifi.getmode())
        print(“The module MAC address is: ” .. wifi.ap.getmac())
        print(“Config done, IP is “..wifi.sta.getip())
    end
end)
========================================================
Next I got a small webserver code to run:
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
    conn:on(“receive”,function(conn,payload)
    print(payload)
    conn:send(“<h1> ESP8266<BR>Server is working!</h1>”)
    conn:close()
    end)
end)
========================================================
ESPlorer interface as I execute the two code snippets::
Inline image 1
Web Page output:
Inline image 2
I hope to update this NodeMCU so that I can program it just as I did the earlier units, but this was a fun learning experience!
The ESPlorer user interface (in java)
Inline image 3
(1) http://randomnerdtutorials.com/esp8266-web-server/
(2) https://esp8266.ru/esplorer/
(3) https://nodemcu.readthedocs.io/en/master/en/flash/
(4) https://benlo.com/esp8266/esp8266QuickStart.html
Advertisements