MagicMirror² v2.14.0 is available! For more information about this release, check out this topic.

unable to get noble package running

  • Platform: Raspberry Pi 3

    Node Version: v7.4.0

    MagicMirror Version: v2.1.0

    Description: For bluetooth integration I would like to add noble to a MM²-module. Whith this package I was able to interact with bluetooth devices when I ran nodejs-scripts without the MM²-framework. When I try to integrate it within the node_helper.js. I’m not able to initialise the blueetoh device.
    This is simply done by

    var noble = require('noble');
    noble.on('stateChange', function(state) {
        if (state === 'poweredOn') {
            noble.startScanning([], true);
            console.log('scanning started...');
        else  {
            console.log('scanning stopped.');

    Within node_helper there is now response, no error message. Just nothing happens.

    If I run a script in the same folder, outside of MM²-Framework with

    sudo node testscript.js

    everytthing is working fine.

    Steps to Reproduce:

    1. To test the working testscript:
    • Enter your module-directory: cd ~/MagicMirror/modules
    • Clone repository : git clone
    • Enter new directory: cd ~/MagicMirror/modules/MMM-OralB
    • Install dependencies: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
    • Install noble module: npm install noble
    • Exceute testscript:sudo node testscript.js
    • This should lead to a output like
    scanning was started. Everything is working fine.
    1. To test the node_helper:
    • Excute first five steps from above.
    • For compatibility reasons run:
    cd ~/MagicMirror/modules/MMM-OralB
    sudo npm rebuild --runtime=electron --target=1.4.6 --disturl= --abi=50
    • Integrate module in config-file
            module: 'MMM-OralB',
            position: 'bottom_left',
    • Start MM², so the module gets loaded.

    Expected Results: Same console output: scanning was started. Everything is working fine.

    Actual Results: Nothing no output. No error. Pure deadly silence. 🙂

    Configuration: Here the config.js:

    var config = {
    	port: 8080,
    	ipWhitelist: ["", "::ffff:", "::1","::ffff:"],
    	language: 'de',
    	timeFormat: 24,
    	units: 'metric',
    	modules: [
    			module: 'alert',
    			module: 'clock',
    			position: 'center'
    			module: 'MMM-OralB',
    			position: 'bottom_left',
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== 'undefined') {module.exports = config;}

    Additional Notes: Next to noble is a module to provide advertising Ble-Services its called bleno (from the same developer). This was successfully integrated in an module by @aschulz90. I tried to adapt to his code to find an error in my code. But this wasn’t helping either.

  • I have tested your module (both in MM and stand-alone) and in both cases i get "scanning was started. Everything is working fine." shown in the console (i use a RaspberryPi 2 with an USB-Bluetooth adapter).

    Are you runnung MagicMirror with sudo-rights? If there is no console output, then it indicates, that the bluetooth adapter wasn’t started (no “stateChange”-event).

    Is my module fully working for you? I currently can’t think of any reason it should only work in one of the both cases (except for the “version mismatch”-error).

  • @aschulz90
    Thanks for your effort and you for quick help. After using a totally new image and installing everything again. I finally started the MM² with sudo-rights without using a ssh-connection.
    This finally solved my issue.

    Via ssh-connection I’m unable to start the MM². I tried DISPLAY=:0 sudo npm start. This caused

    > magicmirror@2.1.0 start /home/pi/MagicMirror
    > electron js/electron.js
    No protocol specified
    npm ERR! Linux 4.4.45-v7+
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
    npm ERR! node v6.9.4
    npm ERR! npm  v3.10.10
    npm ERR! code ELIFECYCLE
    npm ERR! magicmirror@2.1.0 start: `electron js/electron.js`
    npm ERR! Exit status 1

    Is there a way to start the MM² via ssh with sudo rights?

  • @SvenSommer

    Here the following command is suggested:

    DISPLAY=:0 nohup npm start &

  • @SvenSommer Late but…
    Running without root/sudo
    Run the following command:

    sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

    This grants the node binary cap_net_raw privileges, so it can start/stop BLE advertising.

    Note: The above command requires setcap to be installed, it can be installed using the following:

    sudo apt-get install libcap2-bin

    This works on my Zero W with Debian Stretch

  • @SvenSommer this solution worked for ur project?
    Having the same problem to run noble via ssh.

    for me the command : sudo setcap cap_net_raw+eip $(eval readlink -f which node) , seems to do nothing.

Log in to reply