ESP8266 module name

Posted on
  • In any tutorial of using ESP8266 written that the module should be called like that

     var wifi = require("Wifi");
    

    But there is no Wifi.js in http://www.espruino.com/modules directory. And the terminal callback

    =undefined
    

    confirms that

    I assume that we need ESP8266WiFi.js, but the module crashes with

    WARNING: Parent must be an object - not a String, Integer, etc.
    Uncaught Error: Field or method "write" does not already exist, and can't create it on String
     at line 1 col 69
    ...og("["+JSON.stringify(a)),l.write(a),­c){var e=setTimeout(fun...
                                  ^
    in function "cmd" called from line 2 col 142
    ...ter AT+RST");else return b})
                                  ^
    in function "reset" called from line 1 col 94
    ...egister("+IPD",n);l.reset(c);return l
                                  ^
    in function "connect" called from line 4 col 1
    );
    ^
    

    trying to complete a simple task

    var wifi = require("ESP8266WiFi");
    
    wifi.connect ("mySSID", {password:"myPWD"}, function (){
    console.log ("Connected to ap");
    }
    );
    
    /*
    wifi.setIP ({ip:"192.168.1.50", gw:"192.168.1.1", netmask:"255.155.255.0"}, function (){
    console.log ("Ip set");
    }
    );*/
    

    Function wifi.setIP is defined in reference but there is no such function in module.
    What I`m doing wrong?

  • Hi @Questdoino,

    Wifi and ESP8266 are internal modules.

    Please check ESP8266_WifiUsage to figure out how to use the module Wifi on ESPs.

  • Are you using the ESP8266 to provide WiFi to another device running Espruino, or are you running Espruino on the ESP8266 itself?

  • I`m trying to use it itself

  • Ok, start from the beginning. At last flashed boot 1.6 and 1.91 firmware but this code doesn`t work

    var wifi = require("Wifi");
    
    console.log ("START");
    
    wifi.connect ("mySSID", {password:"myPWD"}, function (){
    console.log ("Connected to ap");
    }
    );
    
    
    wifi.setIP ({ip:"192.168.1.50", gw:"192.168.1.1", netmask:"255.155.255.0"}, function (){
    console.log ("Ip set");
    }
    );
    

    ESP stays in default AP mode, doesnt connect to "mySSID" AP and cant find wifi.setIP function

     _____                 _ 
    |   __|___ ___ ___ _ _|_|___ ___ 
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v91 Copyright 2016 G.Williams
    
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 1MB:512/512, manuf 0xe0 chip 0x4014
    
    START
    Uncaught Error: Function "setIP" not found!
     at line 1 col 167
    wifi.setIP ({ip:"192.168.1.50", gw:"192.168.1.1", netmask:"2...
                                  ^
    =undefined
    >
    

    The IDE warns that Wifi module not found. Where is it located?

  • There is no setip function for the esp8266 wifi.

    var wifi = require("Wifi");
    wifi.connect("my-ssid", {password:"my-pwd"}, function(err){
      console.log("connected? err=", err, "info=", wifi.getIP());
    });
    

    Use the code from the example page - the wifi ip will get echoed to the console..

  • Module Wifi not found

    In reference there is setIP function

  • Good luck.

  • 
    That ```setIP()``` function shouldn't be in the docs - it isn't implemented.
    
    Your module not found message is not unusual. To test loaded, load the above code in the IDE from right hand side. Then in left hand side key:
    
    

    wifi.getStatus();```

    You should get a return from that to indicate module was found and loaded and then can proceed to connect and subsequently save your wifi settings for easy connect at boot.

  • As I see, ESP8266 with Espruino onboard cant work in station mode without DHCP on AP enabled? (((

  • You have to wait until the next release, or fetch a travis build or build the firmware by your own.

    There have been added two functions to ESP8266 Wifi: setAPIP() and setIP() with PR #1033 and #1034.

  • If I follow, you mean you can't consistently find it? Well you can jump on your router and reserve the IP address? That's what I do. Next time it boots you'll know its IP which is great for servers and connecting over Telnet.

  • Ah so setIP() is coming. That explains it!

  • Yep and setAPIP() too :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ESP8266 module name

Posted by Avatar for Questdoino @Questdoino

Actions