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.

    MMM-OralB / Bluetooth equipped toothbrush integration

    Scheduled Pinned Locked Moved Development
    68 Posts 13 Posters 35.2k Views 20 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.
    • SvenSommerS Offline
      SvenSommer
      last edited by

      Hey, this topic should continue the development of the MMM-OralB module, to integrate the OralB - Bluetooth equipped toothbrushes.
      It already started here as a request and changed to a develop specific topic.

      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 dfuerst

        hmmm, for my understanding.

        brushtimer.js is waiting till a connect and upon the reconnect after 3sec (of Oral 6500) not accepting further connect’s?
        would it help to integrate a , let’s say, 5 sec not looking for reconnect’s function. or is it noble that doesn’t allow this.

        At HCITOOL, yes you are so right Sir, this won’t recognize a brushing interruption.
        i don’t think that i am able to write anything like your brushtimer myself. i don’t even understand the code you have written.
        i have already tried to modify NetworkScanner and got the MACaddress parsed, but i didn#t manage to do anything with this payload. Just because i don’t understand the basics.

        my modified node_helper looked like this:

        /* global require, module /
        /
        Magic Mirror

        • Node Helper: MMM-NetworkScannermod
        • By Ian Perrin http://ianperrin.com modified by dfuerst
        • MIT Licensed.
          */

        var NodeHelper = require(“node_helper”);
        var sudo = require(“sudo”);

        module.exports = NodeHelper.create({
        start: function function_name () {
        console.log("Starting module: " + this.name);
        },

        // Override socketNotificationReceived method.
        socketNotificationReceived: function(notification, payload) {
            console.log(this.name + ' received ' + notification);
        
            if (notification === "SCAN_NETWORK") {
                this.config = payload;
                this.scanNetwork();
                return true;
            }
        },
        
        scanNetwork: function() {
            console.log(this.name + " is scanning for mac addresses");
        
            var self = this;
            var hci = sudo(['hcitool', 'con']);
            var buffer = '';
            var errstream = '';
        
            hci.stdout.on('data', function (data) {
                buffer += data;
            });
        
            hci.stderr.on('data', function (data) {
                errstream += data;
            });
        
            hci.on('error', function (err) {
                errstream += err;
            });
        
            hci.on('close', function (code) {
                if (code !== 0) {
                    console.log(self.name + " received an error running hcitool: " + code + " - " + errstream);
                    return;
                }
                //Parse the response
                var rows = buffer.split('\n');
                var macAddresses = [];
        
                // HCI-TOOL SCAN table
                for (var i = 1; i < rows.length; i++) {
                    var cells = rows[i].split(' ').filter(String);
                    if (cells[2] && macAddresses.indexOf(cells[2].toUpperCase()) === -1) {
                        macAddresses.push(cells[2].toUpperCase());
                    }
                }
        
                self.sendSocketNotification('MAC_ADDRESSES', macAddresses);
            console.log(macAddresses);
            });
        
        }
        

        });

        that gave me in the console.log:

        [ ‘E0:E5:CF:FC:4D:8C’ ]

        how can i integrate this node_helper macaddr.SCAN into your module?

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

          @dfuerst
          By now brushtimer.js has already the whole logic the of the final modul implemented. It’s working like this.

          1. If a brush is connected it’s starts the timer. This happens when the “start/stop” button is pushed for the first time. After 3 seconds (mine and your) toothbrush turns off bluetooth connection. This is registred, but nothing happens (timer is still running) until:
          2. Brush is connected again. This means the “start/stop” button was hit again and this time is means to stop the timer, because the brush was already running and is now stopped. (If I understood your test output right, this point never happens when you tested it; your toothbrush isn’t connecting again, when you stopped it)
          3. Because (my) toothbrush doesn’t shut down the connection for 32 seconds after the stop, I have to wait until I can detect a new connection event.

          What you need to set up in your attempt is a timer. When you detect your mac-address you start your timer. And when its gone, stop it.

          Here is a clock object you can integrate and use. You can use Clock.resume() to start/resume the timer or Clock.pause() to wait. If you want to reset use Clock.Stop()
          Everytime the clock-timer is changed you fire a sendSocketNotification('TIMER_UPDATE', totalSeconds) like int the MMM-NetworkScanner-project with sendSocketNotification('MAC_ADDRESSES', macAddresses) to inform the main module an show it to the mirror-screen.

          var Clock = {
            totalSeconds: 0,
          
            start: function () {
              var self = this;
          
              this.interval = setInterval(function () {
                self.totalSeconds += 1;
          
                console.log(Math.floor(self.totalSeconds / 60 % 60) + ':' + parseInt(self.totalSeconds % 60));
              }, 1000);
            },
          
              pause: function () {
                clearInterval(this.interval);
                delete this.interval;
              },
          
              resume: function () {
                if (!this.interval) this.start();
              },
          
              stop: function(){
                  this.totalSeconds = 0;
                  clearInterval(this.interval);
                  delete this.interval;
              }
          };
          
          

          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 1
          • S Offline
            Shifty
            last edited by

            Hi,
            im on Holiday for some Days, but the week after next week i’m back home.
            After that i can help you with checking your code on my MM with my Toothbrush.

            I hope this will help you.

            1 Reply Last reply Reply Quote 0
            • A Offline
              aphex13
              last edited by

              Hi @SvenSommer, thank you for the work! i will check the module in the next days!
              would i be possible to connect more the one brush (toothbrush_uuid)?

              thanks!

              1 Reply Last reply Reply Quote 0
              • FistandantilusF Offline
                Fistandantilus
                last edited by

                Hi,

                I have tested the module today with a Oral B Genius 9000 toothbrush. I´m experiencing the same problems mentioned already in the old post. When I run brushTimer.js standalone in the module folder everything is working fine.
                To run it in MM I used:

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

                MM is starting now but when I switch on the toothbrush nothing happens. It is just displaying “Seaching…”
                How can I fix that?

                regards,
                F.

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

                  Hey @Fistandantilus,
                  Thanks for checking out the module. Sorry for disappointing you, but the MMM-OralB-module is not finished yet. The module is not capable of displaying any other message than ‘Searching…’ right now.

                  I stopped the development a few month ago, caused by the different matching results, we experienced in the testing phase at the individual toothbrushes.
                  But I’m definitely interested in making this module.

                  If you want to help me , you could send me your detailed test output of the scenario I pointed out before.

                  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 1
                  • FistandantilusF Offline
                    Fistandantilus
                    last edited by Fistandantilus

                    Good morning,

                    this is the result of brushtimer.js when I start the brush and stop it just by enableling bluetooth:

                    scanning started...
                    Toothbrush connection ALIVE atSun Jul 02 2017 07:39:55 GMT+0200 (CEST)
                    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
                    0:19
                    0:20
                    0:21
                    0:22
                    0:23
                    0:24
                    0:25
                    0:26
                    0:27
                    0:28
                    0:29
                    0:30
                    0:31
                    Toothbrush connection LOST at Sun Jul 02 2017 07:40:27 GMT+0200 (CEST) was alive since Sun Jul 02 2017 07:39:55 GMT+0200 (CEST)
                    Cooldown was432033 sec => => resetting timer
                    

                    When I start the real operating mode the timer doesn´t stop when I stop brushing because the bluetooth connection stays alive. So your described scenario is working as expected.

                    Did you try to contact Oral-B to see if there are sdk´s available for other platforms as well? Getting the connection status in a first step is great but of course all other information the brush is sending should be visualized as well to get rid of the mobile app.

                    1 Reply Last reply Reply Quote 0
                    • FistandantilusF Offline
                      Fistandantilus
                      last edited by yawns

                      Just sent a mail to Oral-B ;)

                      Hi,

                      you may already have heard about the raspberry pi project Magic Mirror (https://magicmirror.builders/). This is a project to display information on a mirror using a semi transparent mirror glas and a monitor behind. As most mirrors are used in bathrooms what is obviously? Exactly people are using toothbrushes in front of it. The timer and the app you are offering are great but as we already have the possibility to display information on the mirror itself we would like to get rid of addidional equipment and would like to build a module that is able to visualize the information your toothbrushes are sending. We kindly request your support to get that feature into the project.

                      best regards,
                      Sven

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

                        That’s an quite a nice offer…
                        Email is out, I’ll keep you updated.

                        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
                        • G Offline
                          goofy
                          last edited by

                          Hello,
                          this is a very interesting project :)
                          Do you have any updates for us :)

                          For me - i have also a Oral-B 6500 Series - is it helpful for you to get data from me ?

                          1 Reply Last reply Reply Quote 0
                          • FistandantilusF Offline
                            Fistandantilus
                            last edited by

                            Unfortunately I did not get any response from Braun/Oral B so far :(

                            I’m also still very interested in a working solution. Just a reliable timer which correctly recognizes the running brush would be enough. I don’t need all features the original app has.

                            F.

                            1 Reply Last reply Reply Quote 0
                            • G Offline
                              goofy
                              last edited by

                              Hello,
                              one thing - what for a kind of usb bluetooth stick do you use ?
                              i remember that you need a bluetooth v4.0 to read out data, maybe
                              this is the problem ?

                              1 Reply Last reply Reply Quote 0
                              • FistandantilusF Offline
                                Fistandantilus
                                last edited by Fistandantilus

                                I am using a Logilink BT0015. The stick isn’t the problem as the Bluetooth connection ist established. Currently there are only API available for iOS and Android. So in general it should be possible communicate with the brush using Debian as well. but someone has to write a library/a driver to read all data. The module here is something like a showcase that to just uses the Bluetooth connection and interpret its connection time but is is not able to read data from the brush itself. We cannot just use the connection status as the brush does not disconnect Bluetooth when you stop brushing so the timer would keep running.

                                1 Reply Last reply Reply Quote 0
                                • G Offline
                                  goofy
                                  last edited by yawns

                                  Hello,
                                  i wrote a email too - and i got an answer - but they write, that they don’t know about
                                  an sdk and if it’s posible to connect from a Linux to the toothbrush …
                                  They give me two links - but …
                                  http://www.pg.com/de_DE/
                                  www.scienceinthebox.com

                                  My result of my tests :)
                                  node --version
                                  v6.11.5
                                  npm --version
                                  3.10.10

                                  [Scenario 1 Start and Stop after 10 Sec]

                                  pi@raspberrypi:~/MagicMirror/modules/MMM-OralB $ sudo node brushTimer.js
                                  scanning started...
                                  Toothbrush connection ALIVE atSat Nov 04 2017 14:06:35 GMT+0100 (CET)
                                  Toothbrush is running
                                  0:1
                                  0:2
                                  
                                  0:41
                                  0:42
                                  Toothbrush connection LOST at Sat Nov 04 2017 14:07:17 GMT+0100 (CET) was alive since Sat Nov 04 2017 14:06:35 GMT+0100 (CET)
                                  Cooldown was432060 sec => => resetting timer
                                  [Scenario 2 Start and Stop after 3sec]
                                  Toothbrush connection ALIVE atSat Nov 04 2017 14:07:49 GMT+0100 (CET)
                                  Toothbrush is running
                                  0:1
                                  0:2
                                  
                                  0:35
                                  0:36
                                  Toothbrush connection LOST at Sat Nov 04 2017 14:08:25 GMT+0100 (CET) was alive since Sat Nov 04 2017 14:07:49 GMT+0100 (CET)
                                  Cooldown was432128 sec => => resetting timer
                                  [Scenario 3 Start, wait like 10 seconds and stop. Start again within the next 10 seconds for like 5 seconds]
                                  Toothbrush connection ALIVE atSat Nov 04 2017 14:09:59 GMT+0100 (CET)
                                  Toothbrush is running
                                  0:1
                                  0:2
                                  
                                  1:3
                                  1:4
                                  Toothbrush connection LOST at Sat Nov 04 2017 14:11:04 GMT+0100 (CET) was alive since Sat Nov 04 2017 14:09:59 GMT+0100 (CET)
                                  Cooldown was432286 sec => => resetting timer
                                  [Scenario 4 Start, wait like 10 seconds and stop. Start again after 40 seconds and stop 3sec later.]
                                  Toothbrush connection ALIVE atSat Nov 04 2017 14:11:59 GMT+0100 (CET)
                                  Toothbrush is running
                                  0:1
                                  0:2
                                  
                                  0:42
                                  0:43
                                  Toothbrush connection LOST at Sat Nov 04 2017 14:12:43 GMT+0100 (CET) was alive since Sat Nov 04 2017 14:11:59 GMT+0100 (CET)
                                  Cooldown was432385 sec => => resetting timer
                                  Toothbrush connection ALIVE atSat Nov 04 2017 14:12:50 GMT+0100 (CET)
                                  Toothbrush is running
                                  0:1
                                  0:2
                                  
                                  0:36
                                  0:37
                                  Toothbrush connection LOST at Sat Nov 04 2017 14:13:28 GMT+0100 (CET) was alive since Sat Nov 04 2017 14:12:50 GMT+0100 (CET)
                                  Cooldown was432430 sec => => resetting timer
                                  

                                  I think next week i try to have a lock on the android sdk … perhaps i can find something.
                                  PS: do you think it is possible to change the code that it’s possible to add 2 toothbrushs ?
                                  because - i have two …

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    doubleT Module Developer
                                    last edited by

                                    This topic came up again (https://forum.magicmirror.builders/topic/6073/integration-of-the-oral-b-toothbrush-data) so I thought I’d share my thoughts:

                                    Without a brush to test, the info from the thread and the documentation got me thinking: You’re only checking the on/off status of the brush right now. How about:
                                    A) Having a small dedicated Android device running the SDK to grab and forward the data?
                                    B) Using the Oral-B App on your phone would save your data in their cloud, right? And you can access that API, right? So to me it seems like you could get the data from the cloud – provided the app is running on your phone, forwarding the data.

                                    1 Reply Last reply Reply Quote 0
                                    • FistandantilusF Offline
                                      Fistandantilus
                                      last edited by

                                      Hi,

                                      this all requires additional equipment. I have a bluetooth enabled mirror and the toothbrush. That should be enough! I don´t want to run my phone to record data and display the recorded data later on the mirror. We just need to find a way to directly read and interpret the data using the direct bluetooth connection.
                                      Currently the script is just a proof of concept that we are able to read the connection status. The whole data part is still missing. I´m not that close to hardware integration and development that I could do that by my own. I can just offer support to test an maybe enhance the solution once somebody has written a library that is able to read the data send by the brush.

                                      1 Reply Last reply Reply Quote 0
                                      • FistandantilusF Offline
                                        Fistandantilus
                                        last edited by

                                        I have just written an additional request to PG asking for support. Lets see if I get an answer…

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

                                          I’m still hoping some genius starts to hack the protocol. This is the tricky part. Once this is done, building a module for the MM-framework is a walk in the park.

                                          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
                                          • U Offline
                                            uhorn
                                            last edited by

                                            Hi everybody,

                                            i’m a developer too and also very interested in solving this use case. At the moment i consider to build up my own magic mirror, but it depends on some useful features i want to have a real benefit from it.

                                            Actually i want to simply get the “start” and the “stop” signal from the brush to display a timer, which is stopped on “stop” and resumed on “start”.

                                            Other features are more unnecessary sugar in my opinion. I’m using electric toothbrushes from Braun/Oral-B since about 20 years from now. I never changed the brush mode (if i had to, i could feel the mode. they are very various) and i’m ignoring the segmented Ring, the motivation Smiley and the star rating consequent 2 times a day.

                                            2 years ago my toothbrush gone broken so i’ve got a new one. At this point i noticed, that both “Smart Guides” (that’s the shipped displays with Oral-B brushes) getting “start” signal from one brush.
                                            This means there a no “pairings” or “syncs” between the smart guide and the brush. (maybe some days my neighbor will trigger this… :D )
                                            Also my new brush is the first one advertising bluetooth integration. This leads to my assumption that “Smart Guides” not using bluetooth in anyway.

                                            I’m not really experienced or well educated in electronic components, but maybe there is something like a proprietary radio antenna, waiting for a simple signal.
                                            Maybe it’s possible to build up the same radio trigger with an antenna like the “Smart Guide” is using?

                                            Any ideas if this would be possible?

                                            Greetings

                                            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
                                            • 3
                                            • 4
                                            • 1 / 4
                                            • 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