• Hi.
    I'm trying to run some program with a CC3000 WiFi module as Stand Alone Mode.
    The program below( mostly, on the sample codes ) is working as I expected when it runs with WebIDE, but not when it's on Stand Alone Mode.

    1. console.log("START!!!");
    2. LED3.write(true);
    3. var http = require("http");
    4. var wlan = require("CC3000").connect();
    5. var h = wlan.connect( "xxxxxx", "yyyyyyy", function (s) {
    6. if (s=="dhcp") {
    7. require("http").get("http://192.168.100.100:3000/sample_requests", function(res) {
    8. LED2.write(true);
    9. res.on('data', function(data) {
    10. console.log(">" + data);
    11. });
    12. });
    13. }
    14. });

    On Stand Alone Mode( after press the RESET BTN ), I'm geting this error below.

    1. ERROR: Not connected to the internet

    Here is the other information.

    • Espruino is powered by USB.
    • It seems like too first for connecting to WiFi network.( like a moment )
    • it seems like connect method is done successfully, because 'require("cc3000").connect().connect( "accesspointname", "wpa2key", function() { })' returns true value

    Is there any step that I missed?

    Thanks!

  • What do you mean by 'stand alone mode'? You mean that you have saved the code?

    Your problem could be that commands that you issue on the console (like connect()) are done when you enter them - not when Espruino powers up. To fix that, you need to put the code you need to run at startup in a function called onInit:

    1. var http = require("http");
    2. var wlan;
    3. function onInit() {
    4. console.log("START!!!");
    5. LED3.write(true);
    6. wlan = require("CC3000").connect();
    7. var h = wlan.connect( "xxxxxx", "yyyyyyy", function (s) {
    8. if (s=="dhcp") {
    9. require("http").get("http://192.168.100.100:3000/sample_requests", function(res) {
    10. LED2.write(true);
    11. res.on('data', function(data) {
    12. console.log(">" + data);
    13. });
    14. });
    15. }
    16. });
    17. }
    18. onInit();

    Now, when you save, the next time Espruino starts onInit is called and the CC3000 connects.

    One other thing that could be an issue is that if you have Espruino powered from a computer, the computer connects to it via USB but stops reading data after a few characters have been sent. This means that if you're using print/console.log then after a while Espruino will stop working as it's waiting for the computer to read the data it's printing. If you either run a terminal app, or connect Espruino to a USB power supply, it'll be fine though.

  • You mean that you have saved the code?

    yes, that's exactly what I meant.
    And thank you so much, your help solved my problem.

    I also understand the other tips.

    thanks a lot! :)

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

CC3000 Wifi module on Stand Alone Mode doesn't seem working

Posted by Avatar for rocky_manobi @rocky_manobi

Actions