Chat freely about anything...

User avatar
By Highflower
#45924 Hello all,
I have just got started with ESP8266 and I have a problem I hope someone can help me with.
I'm trying to use the ESP as an access point and want to be able to connect to it over wifi from my phone to flash a led on one of the GPIO pins.
I'm trying to follow the steps in Julian Ilets youtube video: http://www.youtube.com/watch?v=aPe6g2avfIU
The computer is a raspberry pi 2 with raspberrian and since I'm not very familiar with linux this have been quite a challenge for me so far..
However, I have been able to flush the ESP with nodeMCU firmware (from github: https://github.com/nodemcu/nodemcu-firmware) using esptool from the LXterminal using:
python esptool.py --port /dev/ttyUSB0 write_flash 0x00000 nodemcu-firmware-0.9.6-dev_20150704/pre_build/latest/nodemcu_latest.bin
No problem so far.. Then I'm using ESPlorer and load the following (from github):

Code: Select allwifi.setmode(wifi.SOFTAP);
wifi.ap.config({ssid="test",pwd="12345678"});
gpio.mode(4, gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
    conn:on("receive", function(client,request)
        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
            end
        end
        buf = buf.."<h1> Hello, NodeMcu.</h1><form src=\"/\">Turn PIN1 <select name=\"pin\" onchange=\"form.submit()\">";
        local _on,_off = "",""
        if(_GET.pin == "ON")then
              _on = " selected=true";
              gpio.write(4, gpio.HIGH);
        elseif(_GET.pin == "OFF")then
              _off = " selected=\"true\"";
              gpio.write(4, gpio.LOW);
        end
        buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>";
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)

I open the port with baud 9600 and it seems everything works fine when saving to ESP. When restarting the ESP without the USB connection I can find and connect to "test". I'm connected with IP 192.168.4.2 and it works to ping the esp. So far so good.. According to Julians video the page should then be on 192.168.4.1 but when trying to access this IP I get a response something like "Safari cannot open the page since the network connection was lost". Any ideas?

I'm using ESP8266 v01 powered by a nine volt battery with a YwRobot to convert it to 3.3 volt so I guess the current should not be a problem.

Sorry for a long post with maybe a lot of unnecessary information from a total noob... :oops:
Thanks in advance!
Best ragards
Olle