Chat freely about the open source Javascript projects for ESP8266

User avatar
By Markus Gritsch
#31446 I tried to get the the webserver example working but failed so far.

Is this supposed to still work? I used the latest espruino build (just released 5 hours ago) from https://github.com/espruino/EspruinoBui ... er/ESP8266

Where have these wiki pages with the examples
https://github.com/esp8266-espruino/esp ... 07-Samples
been moved to?

How do I connect the ESP8266 module to an access point? How do I run itself as an access point? The webserver example code does neither.

Thanks,
Markus
User avatar
By hygy
#31460 Hi!

I ordered an nodemc, flashed the latest espruino binary.

I uploaded this code:

Code: Select all
var connectToWifi= function()
{
    var ssid="ssid";
    var pass="pass";

    console.log('connecting to wifi');


    ESP8266WiFi.init();
    ESP8266WiFi.connect(
        ssid,
        pass,
        function()
        {
            console.log('connected to wifi');
            var ipInfo = ESP8266WiFi.getIPInfo();
            print("Current IP address is: " + ESP8266WiFi.getAddressAsString(ipInfo.ip)+':'+ ESP8266WiFi.getAddressAsString(ipInfo.netmask));


            print("starting webserver");
            startWebServer();
        }
    );

};


var startWebServer = function()
{

    var GPIO2 = new Pin(2);
    var http = require("http");

    var httpSrv = http.createServer(function(request, response) {
        print(process.memory());

        response.write("<html><body>");
        if (request.url == "/on") {
            response.write("<b>LED os on</b>");
            digitalWrite(GPIO2, 0);
            print ("led on");
        } else if (request.url == "/off") {
            response.write("<b>LED os off</b>");
            print ("led off");
            digitalWrite(GPIO2, 1);

        } else {
            response.write("Welcome to ESP with JS");
        }
        response.end("<br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>");
    });

    httpSrv.listen(80);

};

connectToWifi();


What is started to work, but it is crashing when I press the led on or off button. I got this log:

Code: Select all _____                 _
|   __|___ ___ ___ _ _|_|___ ___
|   __|_ -| . |  _| | | |   | . |
|_____|___|  _|_| |___|_|_|_|___|
          |_| http://espruino.com
 1v81.592 Copyright 2015 G.Williams
>echo(0);
connecting to wifi
=undefined
connected to wifi
Current IP address is: 192.168.1.67:255.255.255.0
starting webserver
{ "free": 511, "usage": 512, "total": 1023, "history": 203 }
>
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 29896, room 16
tail 8
chksum 0xf3
load 0x3ffe8000, len 2108, room 0
tail 12
chksum 0x71
ho 0 tail 12 room 4
load 0x3ffe8840, len 28936, room 12
tail 12
chksum 0x27
csum 0x27
˜nç sys=67740 rtc=6204297
don't use rtc mem data
sdŽƒr$ŒßãŒb$ŒùLoading 864 bytes from flash...
>
Disconnected
>
 


My code is wrong? Or it is an esp8266 espruino error?

This is the good place, where I can post bug reports?

regards
HyGy
User avatar
By Erni
#31501 I just tried the original binaries from 27. sept and got the following result, before I upload any code:

Code: Select all"sdkVersion": "1.3.0",
  "cpuFrequency": 80, "freeHeap": 9112, "maxCon": 5 }


And with the latest from 16.okt

Code: Select all"sdkVersion": "1.4.0",
  "cpuFrequency": 80, "freeHeap": 4920, "maxCon": 5 }


So more than 4000 less free heap.
Still my webserver is running fine with free heap between 3000 and 3400