MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Toothbrush integration

    Scheduled Pinned Locked Moved Requests
    34 Posts 5 Posters 29.3k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      dfuerst
      last edited by

      should we go back to the “low level approach”?

      as i understand you can instantly determine if there is a certain brush(matching the macaddress via the config) within the bluetooth range upon activation of these.
      any interruption of brushing is detected, 20 sec or so too late of course i know, when the brush goes offline again.
      so can we start a stopwatch (let’s say at the center position) upon detection, stopping when not detecting the brush anymore and reseting to 00:00 after 2min followed by vanishing the stopwatch.
      i know that this wouldn’t be very accurate, but better then nothing. giving the user a feel for the time
      and for a pro like you i guess this would be very easy to develop.
      examples for start/stop/reset timers are quiet a lot available in the web.

      how do you think about

      1 Reply Last reply Reply Quote 0
      • D Offline
        dfuerst
        last edited by

        maybe contacting oralB via the developer program homepage ( https://developer.oralb.com/ ) could be helpful. there might be a support team helping developers creating new apps for their brush

        1 Reply Last reply Reply Quote 0
        • SvenSommerS Offline
          SvenSommer
          last edited by SvenSommer

          Hey,
          guided by the idea of your simple approach I wrote a little script which tries to detect, if the brush is running or not.
          Caused by the bluetooth behavior of the brush it is very limited in guessing when the brush was stopped or resumed.
          Here are some details:

          • If the toothbrush is started bluetooth is activated for 3 Seconds.
          • If the brush is paused/stopped bluetooth is activated again for 32 Seconds.

          This leads to the following limited possiblities in tracking a brush session.

          • A start of a session is only trackable, if the programm/script has started with a (for 32 seconds) silent brush.
          • A stop is only trackable 3 seconds after start.
          • A stop/pause leads to a 32 Seconds “cooldown phase”, were no tracking is possible. This will reset the timer to 0:00.

          This is only helpfull if you do not interrupt you brushing session. :smile:

          If you wanna try the current setup you can run the script by:

          1. Enter your module-directory: cd ~/MagicMirror/modules
          2. Clone repository : git clone https://github.com/SvenSommer/MMM-OralB
          3. Enter new directory: cd ~/MagicMirror/modules/MMM-OralB
          4. Install dependencies: sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
          5. Install noble module: npm install noble
          6. Exceute helper programm to find your brushID (this is not the mac-address): sudo node findBrushId.js
            This should lead to a output like
          Searching for OralB Toothbrushes with manufacturerData: "dc00010205030000000101"...
          changed state to:poweredOn
          Found OralB Tootbrush with ID: 544a1621209f
          
          
          1. Copy and paste your ID into the brushTimer.js file: sudo nano brushTimer.js
            (Save and exit with STRG + O and STRG + X )
          "use strict";
          
          var NodeHelper = require("node_helper");
          var noble = require('noble');
          
          //Copy Paste your ID here 
          var toothbrush_uuid = '544a1621209f';
          
          1. Run script with sudo node brushTimer.js
            This should lead to an output like:
          scanning started...
          Toothbrush is running
          0:1
          0:2
          0:3
          0:4
          0:5
          0:6
          0:7
          0:8
          0:9
          0:10
          0:11
          0:12
          0:13
          0:14
          0:15
          0:16
          0:17
          0:18
          Toothbrush stopped. "Cool down" for 32 seconds needed!
          
          

          Looking for some building inspiration?
          Check out my large, thin and metal framed mirror on robstechlog.com.

          Modules released:
          MMM-GoogleAnalytics
          MMM-GrafanaChart
          MMM-GrafanaGauges

          1 Reply Last reply Reply Quote 0
          • D Offline
            dfuerst
            last edited by

            Wow that was really fast!

            Testing your script brought me to 2 problems:

            testing brushTimer.js in the console worked for detecting the brush but did never stop, also not after 32 sec!

            including your module into the MM i got an error message upon activating the brush:

            “noble warning: unknown handle 64 disconnected!”
            “scanning was started. Everything is working fine.”

            this two message’s i get upon every activation, so the MM show always SEARCHING…

            any suggestions?

            1 Reply Last reply Reply Quote 0
            • D Offline
              dfuerst
              last edited by yawns

              Now i made a reinstall.

              brushtimer.js works until i rebuild electron!!!
              but without rebuilding MM just shows the white screen error.

              after rebuilding i get this upon sudo node brushTimer.js:

              pi@raspberrypi:~/MagicMirror/modules/MMM-OralB $ sudo node brushTimer.js
              module.js:597
                return process.dlopen(module, path._makeLong(filename));
                               ^
              
              Error: Module version mismatch. Expected 48, got 50.
                  at Error (native)
                  at Object.Module._extensions..node (module.js:597:18)
                  at Module.load (module.js:487:32)
                  at tryModuleLoad (module.js:446:12)
                  at Function.Module._load (module.js:438:3)
                  at Module.require (module.js:497:17)
                  at require (internal/module.js:20:19)
                  at Object. (/home/pi/MagicMirror/modules/MMM-OralB/node_modules/bluetooth-hci-socket/lib/native.js:3:15)
                  at Module._compile (module.js:570:32)
                  at Object.Module._extensions..js (module.js:579:10)
              

              so, after this rebuild i get the error of my previous post in MM

              SvenSommerS 1 Reply Last reply Reply Quote 0
              • SvenSommerS Offline
                SvenSommer @dfuerst
                last edited by

                @dfuerst
                Module version mismatch-Error
                Just to summarize and for clarification:
                The Module version mismatch. Expected 48, got 50
                or
                NODE_MODULE_VERSION 50. This version of Node.js requires
                NODE_MODULE_VERSION 51. Please try re-compiling or re-installing
                is a known “bug”, which we were able to solve by the rebuilding of electron as you posted a few days ago.

                So if you want to use the module in MM you have to use this statement in the MMM-OralB-folder:

                sudo npm rebuild --runtime=electron --target=1.4.6 --disturl=https://atom.io/download/atom-shell --abi=50
                

                If you want to test brushtimer.js-script standalone in the console, you need to build the packeges in the MMM-OralB-folder with

                npm rebuild
                

                Behavior of brushTimer.js script
                So if I understood you correctly, you were able to start the timer, but it never stopped?
                For a better understanding I added some debug information in the brushtimer.js -script. Cut you please trigger an update by

                cd ~/MagicMirror/modules/MMM-OralB
                git pull
                

                and try the following scenarios and provide me with the console output text.

                1. Start the Brush; wait like 10 seconds and stop.
                2. Start and stop within 3 seconds.
                3. Start, wait like 10 seconds and stop. Start again within the next 10 seconds for like 5 seconds.
                4. Start, wait like 10 seconds and stop. Start again after 40 seconds and stop whenever you like.

                Behavior of the module within the MM-framework
                You wrote:

                “noble warning: unknown handle 64 disconnected!”
                “scanning was started. Everything is working fine.”
                this two message’s i get upon every activation, so the MM show always SEARCHING…"
                

                Actually this behavior is the intended action right now. As I wrote in this Bug Hunt Post I have problems in bringing noble alive within MM²-framework.
                Surprisingly you aren’t suffering from this error, so could you please tell me:

                • Which platform (Rasperry Pi 2/3, etc.),
                • Node - version: node --version
                • npm - version: npm --version
                • MagicMirror: cd ~/MagicMirror/ and DISPLAY=:0 npm start

                you are using?

                Looking for some building inspiration?
                Check out my large, thin and metal framed mirror on robstechlog.com.

                Modules released:
                MMM-GoogleAnalytics
                MMM-GrafanaChart
                MMM-GrafanaGauges

                1 Reply Last reply Reply Quote 0
                • D Offline
                  dfuerst
                  last edited by

                  of course, i used the electron downgrade. obviously i didn’t know that i have to enter " npm rebuild" to test the .js, sorry for that.

                  you understood me correct. the timer never stopped, i will check that again after git pull

                  as i 'm abroad till monday i will provide this infos to you on monday.
                  you wrote the error is the xpected behaviour? as i mentioned MM showed just SEARCHING…

                  many thanks for your effort

                  1 Reply Last reply Reply Quote 0
                  • SvenSommerS Offline
                    SvenSommer
                    last edited by SvenSommer

                    For the Bug Hunt Post I reduced the code of the MM-scripts to a absolute minmum.
                    That’s the reason the module is always showing ‘SEARCHING…’ right now.

                    If the scripts would work as exspected the console output would show scanning was started. Everything is working fine. all the time the MM² is started.
                    Thats all I’m hoping to see right now.

                    Looking for some building inspiration?
                    Check out my large, thin and metal framed mirror on robstechlog.com.

                    Modules released:
                    MMM-GoogleAnalytics
                    MMM-GrafanaChart
                    MMM-GrafanaGauges

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      dfuerst
                      last edited by

                      ok. i understand. full reply on monday

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        dfuerst
                        last edited by

                        RPi3
                        NODE : v6.9.2
                        NPM: 3.10.9
                        MagicMirror@2.0.0

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          dfuerst
                          last edited by

                          scenario 1:

                          scanning started…
                          Toothbrush connection ALIVE atMon Jan 30 2017 17:12:15 GMT+0100 (CET)
                          Toothbrush is running
                          0:1
                          0:2
                          Toothbrush connection LOST at Mon Jan 30 2017 17:12:17 GMT+0100 (CET) was alive since Mon Jan 30 2017 17:12:15 GMT+0100 (CET)
                          two input in less than 3 sec! (2 sec) => ignoring input!
                          0:3
                          0:4
                          0:5
                          endless counting

                          scenario 2:

                          scanning started…
                          noble: unknown peripheral e0e5cffc4d8c connected!
                          noble: unknown peripheral e0e5cffc4d8c disconnected!
                          Toothbrush connection ALIVE atMon Jan 30 2017 17:14:25 GMT+0100 (CET)
                          Toothbrush is running
                          0:1
                          0:2
                          Toothbrush connection LOST at Mon Jan 30 2017 17:14:28 GMT+0100 (CET) was alive since Mon Jan 30 2017 17:14:25 GMT+0100 (CET)
                          two input in less than 3 sec! (2 sec) => ignoring input!
                          0:3
                          0:4
                          0:5
                          0:6
                          endless counting

                          scenario 3:

                          same result as in scenario1

                          scenario 4:

                          same result as in scenario1

                          SvenSommerS 1 Reply Last reply Reply Quote 1
                          • D Offline
                            dfuerst
                            last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              dfuerst
                              last edited by dfuerst

                              in MM:
                              scanning was started. Everything is working fine.
                              noble warning: unknown handle 64 disconnected!
                              , in MagicMirror

                              1 Reply Last reply Reply Quote 0
                              • SvenSommerS Offline
                                SvenSommer @dfuerst
                                last edited by

                                @dfuerst

                                Behavior of brushTimer.js script

                                According to results of the tested scenarios your brush has a different behavior than mine.
                                I was expecting a reconnect when you power off your brush.
                                This is very bad.

                                Maybe we can find another person to test the characteristics of this behavior?
                                @Shifty or @onetwankyfive: Are you able to give the testscript a run with the postet scenarios to help us out here?

                                Behavior of the module within the MM-framework

                                With th help of @aschulz90 I finally solved to run noble within the MM²-framework. See here for details.

                                I noticed the noble warning: unknown handle 64 disconnected!- warning. It’s nothing that should bother.

                                Looking for some building inspiration?
                                Check out my large, thin and metal framed mirror on robstechlog.com.

                                Modules released:
                                MMM-GoogleAnalytics
                                MMM-GrafanaChart
                                MMM-GrafanaGauges

                                O D 2 Replies Last reply Reply Quote 0
                                • O Offline
                                  onetwankyfive @SvenSommer
                                  last edited by

                                  @SvenSommer I have a brush that is compatible and can help… are the instructions posted 5 days ago the correct ones? I can give it a whirl tonight / tomorrow morning if they are.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    dfuerst @SvenSommer
                                    last edited by dfuerst

                                    @SvenSommer
                                    Ok, as proven during the scenarios:
                                    my brush does a connect followed by another reconnect after 3sec, which happens without user interaction.
                                    so i land again at ‘hcitool con’, can your script be modified easiely to operate as intended at the very beginning (scanning for BLE brush macaddrr. every few seconds and stopping upon not finding it anymore, vanishing+resetting after a defined time period) of this topic?

                                    btw i use the:
                                    Oral-B Pro 6500 Smart Series Electric Toothbrush with Bluetooth Technology Powered by Braun

                                    @onetwankyfive
                                    i appreciate your help testing the script, please provide us with the model no/type of your brush

                                    1 Reply Last reply Reply Quote 0
                                    • SvenSommerS Offline
                                      SvenSommer
                                      last edited by SvenSommer

                                      @onetwankyfive
                                      Thanks four your help! Yes, please follow these instructions of the eight steps to get the testscript running.

                                      For clarification, please provide us with the output from the four scenarios:

                                      1. Start the Brush; wait like 10 seconds and stop.
                                      2. Start and stop within 3 seconds.
                                      3. Start, wait like 10 seconds and stop. Start again within the next 10 seconds for like 5 seconds.
                                      4. Start, wait like 10 seconds and stop. Start again after 40 seconds and stop whenever you like.

                                      And as @dfuerst mentioned the model seems to differ in their behavior. I’m using a a Braun Oral-B PRO 6000. Do you know yours?

                                      @dfuerst
                                      I don’t get your point in using hcitool.
                                      Do you get a reconnect after you have stopped your brush with hcitool?
                                      Or is your brush connected via hcitool as long as it’s running?

                                      To answer your question: If you want to use hcitool, its easier to adapt to MMM-Networkscanner by @ianperrin like you did in your first attempt.
                                      But as I already mentioned, I’m sure this is even more unreliable and unaccurate.
                                      But if you wanna try, I’m willing to help you.

                                      Looking for some building inspiration?
                                      Check out my large, thin and metal framed mirror on robstechlog.com.

                                      Modules released:
                                      MMM-GoogleAnalytics
                                      MMM-GrafanaChart
                                      MMM-GrafanaGauges

                                      1 Reply Last reply Reply Quote 0
                                      • SvenSommerS Offline
                                        SvenSommer
                                        last edited by

                                        @onetwankyfive, @dfuerst
                                        As this is not an request topic any more I made a new one in the developer section. You can find it here.
                                        Feel free to move over, if you want to assist the development of the module I’m creating right now.

                                        Looking for some building inspiration?
                                        Check out my large, thin and metal framed mirror on robstechlog.com.

                                        Modules released:
                                        MMM-GoogleAnalytics
                                        MMM-GrafanaChart
                                        MMM-GrafanaGauges

                                        1 Reply Last reply Reply Quote 0

                                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                        With your input, this post could be even better 💗

                                        Register Login
                                        • 1
                                        • 2
                                        • 2 / 2
                                        • First post
                                          Last post
                                        Enjoying MagicMirror? Please consider a donation!
                                        MagicMirror created by Michael Teeuw.
                                        Forum managed by Sam, technical setup by Karsten.
                                        This forum is using NodeBB as its core | Contributors
                                        Contact | Privacy Policy