Avatar for alexander-daniel

alexander-daniel

Member since Mar 2014 • Last active Mar 2014
  • 1 conversations
  • 6 comments

Most recent activity

    • 15 comments
    • 6,570 views
  • in General
    Avatar for alexander-daniel

    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?

  • in General
    Avatar for alexander-daniel

    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?

  • in General
    Avatar for alexander-daniel

    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+"&origin="+payload.origin+"&platform="+payload.platform+"&args="+payload.args+"&kwargs="+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()
    
  • in General
    Avatar for alexander-daniel

    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!

  • in General
    Avatar for alexander-daniel

    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.

  • in General
    Avatar for alexander-daniel

    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?

Actions