Silly Problem

Posted on
  • Hey guys, Super stoked on the Espruino, looks like a great platform. That being said, just having some small issues getting started.

    I've installed the Chrome App on OS X, and have a regular Espruino board.

    Now, I've hooked up a DHT11 to a pin (I've tried B2, B3, C0, C1, C2).

    However, using the IDE, I cannot transfer over my sketches. I'm trying simply to use the example provided.

    var dht = require("DHT11").connect(whatever pin im trying);
    dht.read(function (a) {
      console.log("Temp is "+a.temp.toString()+" and RH is "+a.rh.toString());
    });
    

    and nothing happens when i try to send this to the espruino. It just hangs on

    echo(0);
    

    It seems to be an issue with importing modules, as the same happens for a BMP085. Is there something wrong?

  • I'm not sure why it's not auto-loading the modules correctly, but you can always put them on a micro SD card until you figure the main problem out (they go in node_modules directory on SD card)

  • Crazy, got the same issue now . I connect fine, but once the code is transferred over it ends with echo(0) and then is stuck....

    Do we need to completely reset the device somehow?

  • It works on my Google Pixel - I assume this is a Mac only issue. Exactly the same experience on the Mac.

  • Cool, thanks for the help. I hope they fix the Mac issue soon. How can I use an SD? It seems to be only supported by some boards, and I have the classic Espruino. Doesn't look like there is an SD card option for that.

  • wow, sorry about the last comment, i breadboarded my Espruino right away and didnt notice on the bottom there is an SD card slot!

    I'll give that a try for now!

  • I have been having this same issue on my Mac for at least a week now. Good to know it's not just me. Hopefully we can get a fix soon. In the meantime, are there any alternatives for sending code to the Espruino?

  • This is news to me :( I'll try it out on Mac today and will try and see what's going on - it's possible that Chrome for Mac has auto-updated again and the Serial API is now losing characters.

    Maybe you could try the dev version of the Web IDE and see if that fixes anything? http://www.github.com/espruino/EspruinoW­ebIDE

  • Thanks Gordon! I tried the dev IDE and it works a bit better, but I still can't make a proper POST. The CC3000 times out and restarts everytime, or I get a socket-1 error.

    Here is my code:

    var wlan = require("CC3000");
    var http = require("http");
    
    var data = JSON.stringify([{
        x : 0,
        y : 1,
        type : "scatter",
        mode : "markers"
    }]);
    
    var layout = JSON.stringify({
        fileopt : "extend",
        filename : "Espruino"
    });
    
    
    var payload = {
    un : "demos",
    key : "tj6mr52zgp",
    origin : "plot",
    platform : "rest",
    args : data,
    kwargs : layout,
    version : "0.0.1"
    };
    
    function request() {
      var urlpayload = "un="+payload.un+"&key="+payload.key+"&o­rigin="+payload.origin+"&platform="+payl­oad.platform+"&args="+payload.args+"&kwa­rgs="+payload.kwargs+"&version="+payload­.version;
      var options = {
      host: 'plot.ly',
      method: 'POST',
      path: '/clientresp',
      headers: {
              'Content-Type': 'application/x-www-form-urlencoded',
              'Content-Length': urlpayload.length
          }
    };
    
    var req = http.request(options, function(res) {
      console.log('STATUS: ' + res.statusCode);
      console.log('HEADERS: ' + JSON.stringify(res.headers));
      res.on('data', function (chunk) {
        console.log('BODY: ' + chunk);
      });
    });
    
    req.on('error', function(e) {
      console.log('problem with request: ' + e.message);
    });
    
    req.write(urlpayload);
    req.end();
    }
    
    
    wlan.connect( "evilfriends", "password", function (s) {
      if (s=="dhcp") {
        console.log('wifi connected!');
        request();
      }
    });
    

    It seems to be OK until it hits

    req.end()
    
  • Great, glad to see that got sorted - I'll release a new Web IDE tomorrow so hopefully it'll fix this for most of the others that are having issues.

    By the way, 1v56 turns out to be a bit unreliable with CC3000 at the moment due to an IRQ problem. This image fixes it though: http://www.espruino.com/binaries/git/com­mits/cb1101a1855f3b37bdeb2b7a91af12d4aa4­5dc99/

    However your problem isn't that. Just tried it on the PC here, and got the same issue. Well, not the same (there was no CC3000 to fall over!). It turns out you need to specify port:80 in options then it'll work. I'll add a check for that in a later versions.

  • Cool! Got it working, albiet she's a bit shakey. The CC3000 does seem a bit finicky for sure! I can't make too many POSTs, too quickly, and sometimes it just needs to restart after 5-10 successful POSTs. Does the CC3000 hold a connection for as long as it can? Or do you have to run all of your logic inside of the .connect() callback?

  • Another question:

    Is it possible to stream using the espruino?

    e.g

    var go = function() {
    
        var req = http.request(options, function(res) {
            console.log(res);
        });
    
        var x = 0;
        setInterval(function() {
            console.log(x);
            data = {"x": x, "y": 1};
            x++;
            json = JSON.stringify(data);
            req.write(json+'\n');
        },100);
    };
    

    Does the espruino support TCP?

  • Yes, Cc3000 is very shakey. Sadly it's a known issue with the CC3000 - Espruino does it's best to work around it by power cycling if there's an issue, but the chip itself and the drivers TI supply are horrific.

    The CC3000 will hold connections for as long as it can, yes - so you can kick off something with setInterval. For example: http://www.espruino.com/wifi_humidity

    And yes, you should be able to stream, and no - no TCP at the moment - just HTTP. There was talk of implementing websockets at some point - but I doubt anyone will actually contribute that so it's something I'll have to find time for.

  • Out of interest is the cc3000 the "go to" wireless board for the Espruino or are there others out there which may be more stable? I notice the electric Imps are quite popular on my twitter feed lately.

  • Well, the Imps are basically an Espruino anyway (except they run something called Squirrel instead of JavaScript)...

    At the moment the CC3000 is all we've got. There's WiFly (which doesn't use Espruino's HTTP library), and I think it should be pretty easy to use WIZnet's WiFi module now - but I don't have one yet (or any time) so I can't try.

    If the WIZnet WiFi is anything like their Ethernet board then it should be significantly better than the CC3000. The SPI protocol and drivers on that are a lot more suited to MCUs.

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

Silly Problem

Posted by Avatar for alexander-daniel @alexander-daniel

Actions