• So I have my new ESP8266 and it is up and running. Couple problems. I'm still having problems with the "AT wasn't found". Happens way too often and I have a great internet connection.

    The second part is creating an access point. This works:

    
    Serial2.setup(115200, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.createAP("Test", "guest", 1, "wep", function(err) {
          console.log("Connected");
          require("http").createServer(function (req, res) {
            res.writeHead(200, {'Content-Type': 'text/plain'});
            res.write('Hello World');
            res.end();
          }).listen(80);
        });
      });
    });
    
    

    But this is having issues:

    
    function onPageRequest(req, res) {
      var a = url.parse(req.url, true);
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('<html><body>');
      res.write('<p>Pin is '+(BTN.read()?'on':'off')+'</p>');
      res.write('<a href="?led=1">on</a><br/><a href="?led=0">off</a>');
      res.end('</body></html>');
      if ("led" in a.query) digitalWrite(LED1, a.query["led"]);
    }
    
    Serial2.setup(115200, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi").connect(Serial2, function(err) {
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.createAP("Test", "guest", 1, "wep", function(err) {
          console.log("Connected");
          require("http").createServer(onPageRequest).listen(80);
        });
      });
    });
    
    

    says this:

    
    Uncaught Error: Field or method "led" does not already exist, and can't create it on null
     at line 8 col 57
      if ("led" in a.query) digitalWrite(LED1, a.query["led"]);
    
    
About

Avatar for Cale @Cale started