• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 26.4k 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 yawns Jan 23, 2017, 5:34 PM Jan 23, 2017, 5:21 PM

    try :

    cd ~/MagicMirror/modules/MMM-Button
    sudo npm rebuild --runtime=electron --target=1.4.6 --disturl=https://atom.io/download/atom-shell --abi=50
    
    D 1 Reply Last reply Jan 23, 2017, 5:23 PM Reply Quote 2
    • D Offline
      dfuerst @dfuerst
      last edited by Jan 23, 2017, 5:23 PM

      not in the mmmbutton folder of course

      S 1 Reply Last reply Jan 23, 2017, 5:29 PM Reply Quote 0
      • S Offline
        SvenSommer @dfuerst
        last edited by Jan 23, 2017, 5:29 PM

        @dfuerst It worked! Thank you very much!!

        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 Jan 23, 2017, 8:41 PM

          exciting.
          you get everything needed for a really high quality piece of module.

          battery level
          brushing mode
          brushing time
          pressure
          quadrant
          smiley

          i am a bit concerned about the user readout. (Do you think it might be possible to determine which of eg. 3 brushes is presently used?)

          1 Reply Last reply Reply Quote 0
          • S Offline
            SvenSommer
            last edited by Jan 24, 2017, 8:01 PM

            Hey,
            I have bad news.

            The readable informations provided by the brush via bluetooth aren’t changing. Not while the toothbrush is running. I guess the characteristics we were able to readout, are used like placeholder for the sdk.

            Second try was to get notified if a broadcastd value (characteristic) is changing. Nothing here either.
            Every characteristic (like brushing time, battery level, etc) is using the same id and only provides a different name. So a notification service wasn’t possible.

            Seems like there is no way to get the information read out via bluetooth without using the sdk…

            I also tried to include the provided sdk into the MM-framework.
            Therefore I had a try with node-java, which allows to run java classes within nodejs. The files from the android sdk are java classes.

            It went pretty nice in the beginning. But then I ran into an error
            ‘Expected stackmap frame at this location.’ which is caused by the compiling the sdk classes on another system (linux not android), I would assume.

            I was amazed that I wasn’t able to find any code snippets of frameworks from other developers to “hack the brush” when I first started. By now its seems obvious that it’s not that easy.

            If anybody else is gonna have a try, please don’t hesitate to ask if you need assistance.

            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 Jan 24, 2017, 8:53 PM

              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 Jan 24, 2017, 9:05 PM

                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
                • S Offline
                  SvenSommer
                  last edited by SvenSommer Jan 26, 2017, 9:46 PM Jan 26, 2017, 9:45 PM

                  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 Jan 27, 2017, 6:13 AM

                    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 Jan 27, 2017, 8:31 AM Jan 27, 2017, 7:58 AM

                      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

                      S 1 Reply Last reply Jan 27, 2017, 11:39 AM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 2 / 4
                      2 / 4
                      • First post
                        16/34
                        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