Wifi module not found????

Posted on
  • Hello, the javascript code i have keeps giving me the error "module wifi not found", The picture is what my pico looks like.
    ----------------------------------------­ Java Script
    var wifi = require("wifi");
    var ssid = "Temp-Student";
    var pw = "TempStu1";
    wifi.connect(ssid, {password:pw}, function(err){
    console.log("connected? err=", err, "info=", wifi.getIP());
    });
    wifi.stopAP();
    ----------------------------------------­ Console


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    || || |_|||_|_|

          |_| http://espruino.com
    

    1v83 Copyright 2015 G.Williams

    echo(0);
    ERROR: SD card must be setup with E.connectSDCard first
    WARNING: Module "Wifi" not found
    Uncaught Error: Field or method "connect" does not already exist, and can't create it on undefined
    at line 1 col 5
    wifi.connect(ssid, {password:pw}, function(err){

    ^
    

    Uncaught Error: Field or method "stopAP" does not already exist, and can't create it on undefined
    at line 1 col 5
    wifi.stopAP();

    ^
    

    =undefined


    1 Attachment

    • Capture.PNG
  • Looks like your connecting the esp8266. You need to use the code from here. WiFi is not a module.

  • Yep, @Cale is right - since Wifi isn't built in on the Pico, you need to load up an ESP8266 modue to tell it what you're connecting it to:

    Serial2.setup(115200, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function(err) {
      //                ^^^^^^^^^^^^^^^^
      //                Use ESP8266WiFi here (and 9600 baud) if you have an ESP8266 with firmware older than 0.25
      if (err) throw err;
      wifi.reset(function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect("WiFi_Name","WPA2_Key", function(err) {
          if (err) throw err;
          console.log("Connected");
          // Now you can do something, like an HTTP request
          require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
            console.log("Response: ",res);
            res.on('data', function(d) {
              console.log("--->"+d);
            });
          });
        });
      });
    });
    
  • @Gordon I have put in the code, but i'm not getting any a weird message code in console when i type in wifi.connect().
    --------------------------------Console


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    || || |_|||_|_|

          |_| http://espruino.com
    

    1v83 Copyright 2015 G.Williams

    echo(0);
    =undefined
    wifi.connect()
    =undefined
    Uncaught No 'ready' after AT+RST
    at line 1 col 16
    if (err) throw err;

               ^
    

    in function "a" called from line 1 col 112
    ...a("No 'ready' after AT+RST");else return b

                              ^
    

    in function "b" called from line 1 col 15
    d=void 0;b&&b()

              ^
    

    in function called from system

  • Why are you using that old version of Espruino? Update to v84 (and to v85 when it comes out)

    Might you have an ESP8266 with an old version of the code on it? In that case, you use a different module and baud rate as noted above.

    Also - put a capacitor between Vcc and Gnd right next to the ESP8266, like 10-100uf range, preferably ceramic. I've had problems with ESP-01 boards like that resetting themselves without a cap on them...

  • Uncaught No 'ready' after AT+RST usually just means that the module isn't responding. It's probably:

    • It's not powered up - there should be a red LED lit on it if all is ok
    • You've got TX and RX round the wrong way - I can't really see from your diagram what goes where
    • You have the wrong baud rate because your board has a different firmware - use the test code from http://www.espruino.com/ESP8266
    • It's booted up in bootloader mode.
    • It's unhappy with the power - as DrAzzy says, a capacitor might help

    It's probably best to start off using this code from the link above:

    var serial = Serial2;
    var pins = { rx: A3, tx : A2 };
    function test(baud) {
      serial.removeAllListeners();
      var l="";
      serial.on('data', function(d) {l+=d;});
      serial.setup(baud, pins);
      serial.write("AT+GMR\r\n");
      setTimeout(function(){console.log(JSON.s­tringify(l));},800);
    }
    digitalWrite(B9,1); // enable on Pico Shim V2
    setTimeout(function() { test(9600); }, 2000);
    setTimeout(function() { test(115200); }, 3000);
    setTimeout(function() { test(57600); }, 4000);
    setTimeout(function() { console.log("Done!"); }, 5000);
    

    It'll just try and communicate with the board using different baud rates, so might help to narrow it down

    also: to format code in the forum, just add 3 backticks before and 3 after (each on a new line, with a blank line before and after) - just google 'markdown' for some examples.

  • Fix it just needed more power.

  • Great, glad you got it sorted!

    ... I also just moved this into 'Interfacing' from the ESP8266 forum - that one was for running Espruino actually on the ESP8266 itself

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

Wifi module not found????

Posted by Avatar for ert4 @ert4

Actions