require CC3000 return blank function

Posted on
  • I am trying to connect to a CC3000 module but anytime I run the code in the web IDE the command line just return undefined and nothing else. Any ideas?

  • require("CC3000") itself returning a blank function is expected. When you run the code from http://www.espruino.com/CC3000 nothing gets printed until the result is received... Try:

    console.log("Initialising CC3000");
    var wlan = require("CC3000").connect();
    console.log("Connecting...");
    wlan.connect( "AccessPointName", "WPA2key", function (s) { 
      console.log(s);
      if (s=="dhcp") {
        require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
          res.on('data', function(data) {
            console.log(">" + data);
          });
        });
      }
    });
    console.log("Done.");
    

    And see what happens. It's possible that your Access Point's name or key isn't being recognized.

  • This is what I am getting back from the console:

    >echo(0);
    Initialising CC3000
    Connecting...
    Done.
    =undefined
    

    I guess what I am missing is the ability to respond to errors or just get a better feedback based on the connection status. What I mean is something like this:

    console.log("Initialising CC3000");
    var wlan = require("CC3000").connect();
    console.log("Connecting...");
    wlan.connect( "AccessPointName", "WPA2key", function (s) { 
      console.log(s);
      if (s=="dhcp") {
        require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
          res.on('data', function(data) {
            console.log(">" + data);
          });
        });
      }
    });
    wlan.on('error', function(e){
      console.log('Cannot connect to access point');
      console.log('Error: ' + e.message);
    });
    console.log("Done.");
    

    Otherwise, I have no idea what is going on with my module.

  • I think chances are that you've just got the wrong access point name and key, or the signal strength is too low for the CC3000 to connect.

    I'm pretty sure that Espruino is reporting back all the information it gets from the CC3000 module though. Unfortunately it's just like that - if the module doesn't like something it'll just sit there doing nothing :(

  • By the way, good news is that your module is communicating with Espruino ok though. If it wasn't, there would be error messages.

  • Now I am getting this error:

    echo(0);
    =undefined
    ERROR: Timeout in CC3000 driver (4103)
    ERROR: Connect failed (err -1)
    Looks like CC3000 has died again. Power cycling...
    ERROR: Timeout in CC3000 driver (4103)
    ERROR: Connect failed (err -1)
    Looks like CC3000 has died again. Power cycling...
    

    Do I have the wrong module?

    This is what I got:
    http://www.adafruit.com/products/1510

    This is what you guys recommend: http://www.adafruit.com/products/1469

    Should I get the recommended one or the one I have is going to work?

  • Hi Carlos,

    So you got connected to the WiFi access point? What was the problem?

    Which code are you using? It's not the code I pasted above with the console.log statements in...

    The module you chose is fine as long as you purchased the antenna too?

    CC3000 modules are notoriously unstable though - and in this case, it's just crashed in the 'connect' command. Does it happen every time, or just sometimes?

    About the only time I've seen this happen reliably is if you're not using http.get, but http.request, and you don't supply a port number (but that'll be fixed in the next version).

  • I finally got it to work. The new version 1v57 made everything great.

    Thank you so much for the help.

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

require CC3000 return blank function

Posted by Avatar for Carlos @Carlos

Actions