Avatar for maze1980

maze1980

Member since Jun 2019 • Last active Jan 2020
  • 7 conversations
  • 119 comments

Most recent activity

  • in ESP32
    Avatar for maze1980

    I'd suggest to place the code for "wifi.on('disconnected',..." into the "wifi.on('connected'," function. I didn't try this, but as the disconnect function gets registered after every connect it should work.

  • in ESP32
    Avatar for maze1980

    https is not working on 2.04

    You have to build your own version, using less jsvars. However no details on how much to reduce the variables. See also: https://github.com/espruino/Espruino/iss­ues/1613

    I'll make a custom build, sooner or later, maybe end of this year. (Without the graphics library, without telnet and without ota.). And, if necessary for https, less jsvars.

  • in ESP32
    Avatar for maze1980

    For my ESP-WROOM-32 it doesn't work.
    And the ESP8266 uses http, even if you specify https.

  • in Electronics
    Avatar for maze1980

    I'd say even two motors with 10mA are too much and will drain a CR2032 battery really fast. I'd add a capacitor and a diode in parallel to each motor (over voltage/inverse voltage protection).

    However I'd check the motors first, do they have the right speed and power at the planned voltage, or do you need more power/a higher voltage and gears...

  • in ESP8266
    Avatar for maze1980

    res.on('data', is triggered as soon as the first data arrives, not when all data is there. That causes the error, if you replace the line console.log(JSON.parse(data).datetime); with console.log('###'); you'll see that `res.on('data', is triggered multiple times.
    As such you're trying to parse an incomplete JSON string, and the error is normal.
    Edit: And it's pure luck that it works in node.js.

  • in ESP8266
    Avatar for maze1980

    Just add const LED1 = D2 or const LED1 = NodeMCU.D4; //(pin2 of ESP8266) to get the build-in LED blinking.
    And actually you don't need the variables LED1 and on as you can simply call D2.toggle() or NodeMCU.D4.toggle() to toggle the pin D2/build-in LED:

    setInterval(function() {
       D2.toggle();
    }, 1000);
    

    To stop the blinking call clearInterval().

  • in General
    Avatar for maze1980

    If you want to use nodejs modules use nodejs, e.g. on a pc, rpi or opi.
    Espruino has limited js/ts compatibility, and runs typically on hardware with very limited memory, and as such most nodejs modules are simply to big to be includes and using non-supported js/ts. Espruino typically uses modules to provide and interface for I2C/1-wire/serial chips, see https://www.espruino.com/modules/
    I'm pretty sure it's impossible to use the mentioned module on Espruino.

  • in ESP32
    Avatar for maze1980

    I'd say it takes longer than 10s to connect to the Wifi initially, for whatever reason.

  • in ESP8266
    Avatar for maze1980

    The leap socket is listening only on the loopback port, to make the socket accessible from the outside execute these commands on Windows (on Linux it's different):

    netsh interface ipv4 install
    netsh interface portproxy add v4tov4 listenport=6437 connectport=6437 connectaddress=127.0.0.1
    

    However, it might be easier to run a local nodejs server on your computer (easier development and debugging). That server would read the leap motion data from the websocket, then interpret it provide a new webpage for the ESP8266 to control the servos directly. Logging and debugging would be much easier this way, and since you need to have the computer running anyway it's basically no extra cost.

  • in ESP32
    Avatar for maze1980

    I guess there is a better way: Do not create new timer every 1000ms, but only once. Just to quote one function:

    //get wifi status every second
    function iw1() {
      wifi_stat = Wifi.getDetails().status;
      //set led blink rate
      if(wifi_stat !== "connected") {led_speed = 100;}
      else {led_speed=500;}
      setTimeout(iw1,1000);
    }
    iw1();
    

    And how to do it better:

    //get wifi status every second
    function iw1() {
      wifi_stat = Wifi.getDetails().status;
      //set led blink rate
      if(wifi_stat !== "connected") {led_speed = 100;}
      else {led_speed=500;}
    }
    iw1();
    setInterval(iw1,1000);
    

    While there is a garbage collection, it might be called too late, or not working properly - I didn't look into it. But if you call setTimeout every 1000ms instead of setInterval once there's a really high chance it'll allocate a new block of memory for a new timer every 1000ms.
    The other functions shall be modified accordingly.

Actions