Avatar for DanB

DanB

Member since Jan 2018 • Last active Aug 2018
  • 3 conversations
  • 8 comments

Most recent activity

  • in ESP8266
    Avatar for DanB

    Hi Espruino Savants,

    I am trying to use the Espruino Command Line module on a Windows 10 PC. I type
    "espruino -p COM18" because my ESP8266 module is on COM18 (works fine with the WebIDE) and get a
    "No compatible USB Bluetooth 4.0 device found!" error. (Full error output message below.) Did I miss some setting?
    Thanks,
    Dan

    PS C:\Users\dan\Documents\Espruino\code\Esp­ruino> espruino -p COM18
    Espruino Command-line Tool 0.1.5
    -----------------------------------
    
    Connecting to 'COM18'
    C:\Users\dan\AppData\Roaming\npm\node_mo­dules\espruino\node_modules\bluetooth-hc­i-socket\lib\usb.js:70
        throw new Error('No compatible USB Bluetooth 4.0 device found!');
        ^
    
    Error: No compatible USB Bluetooth 4.0 device found!
        at BluetoothHciSocket.bindUser (C:\Users\dan\AppData\Roaming\npm\node_m­odules\espruino\node_modules\bluetooth-h­ci-socket\lib\usb.js:70:11)
        at BluetoothHciSocket.bindRaw (C:\Users\dan\AppData\Roaming\npm\node_m­odules\espruino\node_modules\bluetooth-h­ci-socket\lib\usb.js:28:8)
        at Hci.init (C:\Users\dan\AppData\Roaming\npm\node_m­odules\espruino\node_modules\noble\lib\h­ci-socket\hci.js:101:35)
        at NobleBindings.init (C:\Users\dan\AppData\Roaming\npm\node_m­odules\espruino\node_modules\noble\lib\h­ci-socket\bindings.js:82:13)
        at Noble.<anonymous> (C:\Users\dan\AppData\Roaming\npm\node_m­odules\espruino\node_modules\noble\lib\n­oble.js:55:24)
        at _combinedTickCallback (internal/process/next_tick.js:73:7)
        at process._tickCallback (internal/process/next_tick.js:104:9)
        at Module.runMain (module.js:606:11)
        at run (bootstrap_node.js:389:7)
        at startup (bootstrap_node.js:149:9)
    PS C:\Users\dan\Documents\Espruino\code\Esp­ruino>
    
  • in ESP8266
    Avatar for DanB

    Hi Gordon,

    Works! Thanks so much. BTW, I've been working with microcontrollers for 40 years (starting with the 6502, assembly, and FORTH); and I have to tell you, Espruino on the ESP8266 is the best thing I've ever worked with in this realm. Espruino is an awesome system! Thank you for developing it.
    Dan

  • in ESP8266
    Avatar for DanB

    Update: I found how to go back to a previous version from github (instructions at https://www.espruino.com/Modules). With the previous version of the MQTT module, I have no problems.

  • in ESP8266
    Avatar for DanB

    Hi All, I've been using the MQTT module without any problems for at least a month. However, I started having problems yesterday, which I see was the day that a new MQTT module was posted on https://www.espruino.com/modules

    mqtt.connect() gives this immediate error:

    >mqtt.connect()
    =undefined
    Uncaught SyntaxError: Got ':' expected EOF
     at line 1 col 70
    ...;var f=c.charCodeAt(0)>>4;a:{var d=c.substr(1,5);var k=1,l=0...
    

    Code is running on
    ESP8266-12E flashed with espruino_1v95_esp8266_4mb_combined_4096.­bin ...

    Test program, which has worked without a problem is listed below.

    Is there an error in the MQTT module? Is there a change in using it?
    Also, a related question: is there a way to access a previous version of a module?

    Thanks,

    Dan

    Program:

    var wifi = require("Wifi");
    
      var server = 'm14.cloudmqtt.com';
      var options = {
              keep_alive: 60,
              port: xxxx,
              clean_session: true,
              client_id: "xxxx",
              username: "xxxx",
              password: "xxxx",
              protocol_name: "MQTT",
              protocol_level: 0 };
    
      var mqtt = require("MQTT").create(server, options); // changes here
        mqtt.on('connected', function() {
        mqtt.subscribe("red");
          mqtt.subscribe("blue");
        console.log("connected");
      });
    
    mqtt.on('disconnected', function() {
      console.log("MQTT disconnected... reconnecting.");
      setTimeout(function() {
        mqtt.connect();
      }, 1000);
    });
      
       mqtt.on('publish', function (pub) {  // this place throw error
        console.log("topic: "+pub.topic);
        console.log("message: "+pub.message);
        if (pub.topic == "red") {
         if (pub.message == "on") {digitalWrite(16,0);}
         if (pub.message == "off") {digitalWrite(16,1);}
        }
          if (pub.topic == "blue") {
         if (pub.message == "on") {digitalWrite(2,0);}
         if (pub.message == "off") {digitalWrite(2,1);}
        }   
      });
    
    function onInit() {
      console.log("In onInit");
      wifi.connect("xxxx", {password:"xxxx"}, function(err){
    console.log("connected? err=", err, "info=", wifi.getIP());
    });
    wifi.stopAP(); 
    mqtt.connect(); 
    }
    
    • 7 comments
    • 4,225 views
  • in ESP8266
    Avatar for DanB

    Hi allObjects, thanks for your comment. I think that my problem was that I didn't completely understand how the "watch" function works, and (so far) my difficulties seem to have been solved by changing the hardware debouncing circuit that sends the pulses to the ESP8266. My diagnosis is that "watch" catches all the transitions of an undebounced switch input and the "debounce" option in "watch" happens in software. Thus, if there are too many inputs from undebounced switches, the "watch" queue becomes overloaded. The other thing I found is that "watch" really needs a fast edge input. The frustrating/fun part of my working with Espruino is that I have relearn to do all the things I used to know how to do in C.

  • in ESP8266
    Avatar for DanB

    Make that, "not missing as many pulses." Watch is still missing some pulses.

  • in ESP8266
    Avatar for DanB

    Thanks, DrAzzy. That makes sense. That also means I have to be careful about long computations.

    Actually, I initially wrote my program (a pulse counter) using watches, but it was missing pulses, which is why I tried the "while" approach. What I just figured out is that the "watch" on ESP8266 needs fast edges, rather than levels to trigger. I sharpened the edge of the input pulses, and now I am not missing pulses.

    Thanks again,
    Dan

Actions