• The goal here is for her to maybe tuck the Puck.js into her bra strap of something. Sounds weird but evidently women use their bra straps as a sort of pocket :-)

    Core principle.. on an alert, use the Espruino Hub to convert the BLE advertisement of the alert to MQTT and use Node-Red to take action on that button press with a Twilio webhook to send the kids a SMS.

    First draft - the button sends the alert right away. But then I thought it might be good to have a cancel feature for x seconds.

    Second draft - button sets the red LED flashing for 10 seconds during which time the whole shooting match can be cancelled. If not cancelled, send the alert.

    var pressCount = 0;
    var batt = 0;
    
    var alertQueued = 0;
    
    digitalWrite([LED3,LED2,LED1], 0);
    
    var flasherID;
    var timeoutID;
     
    function showAlert() {
      pressCount++;
      batt = Puck.getBatteryPercentage();
      clearInterval(flasherID);
      alertQueued=0;
    
      NRF.setAdvertising({
        0x1812 : [pressCount],
        0x180f : batt,
        });
      LED1.write(1);
    }
    
    function delayedAlert() {
      timeoutID = setTimeout(showAlert, 10000);
      alertQueued=1;
    }
     
     
    function clearAlert() {
      clearTimeout(timeoutID);
      clearInterval(flasherID);
      alertQueued=0;
      LED1.write(0);
    }
    
    
    setWatch(function() {
      if (alertQueued) {
        clearAlert();
      } else {
        delayedAlert();
        flasherID = setInterval("digitalWrite(LED1,redLEDOn=­!redLEDOn);",200);
      }
    }, BTN, { edge:"rising", repeat:true, debounce:50 });
    
    

    The LED will stay on after the alert is set. To clear it, just cycle it again but cancel during the delay.

    Next Steps -
    I tried to get the gyro/accel to help me determine a fall.

    I tried the tilt>35 interrupt and I could get that to work on its own but not in conjunction with the button press.

    Even if I did get them to work together it seems like there would need to be a LOT of tuning to get it right. The detector seems like by default it tests all axis. So turning left or right is no different than falling flat.

    Maybe one of the other detection mechanisms could work. But she is nearly 90 so her baseline activity level is pretty slow.

    https://youtu.be/MCevqAU_b64

  • Sat 2020.09.19

    Wow @user118219, It is amazing what is actually packed behind those straps!

    Which Puck version is being used? (solution suggestions may be dependent)

    http://www.espruino.com/Reference#l_Puck­_accel

    Wouldn't it be prudent to activate on a collision detection only in lieu of a button press and collision detection for the case should the individual be rendered unconscious? [USP - Unique Selling Point]


    ref: 'but not in conjunction with the button press.'

    Have any of these tutorials been referenced?

    http://www.espruino.com/Tutorials
    from which:
    http://www.espruino.com/Puck.js+SMS
    http://www.espruino.com/Puck.js+Door+Lig­ht
    http://www.espruino.com/Accelerometer

  • Hi Joseph, I need to create this too. I will try and find something that will help us on the fall part. In the meantime, could you please explain how to do this part:

    "Node-Red to take action on that button press with a Twilio webhook to send the kids a SMS."

    I know about Twilio and how you can do the SMS part, but I don't know how to convert node-red into a web hook. this is my very first puck project (successfully importing your code into my puck was a yay moment for me (lol).

    jen

  • Do you think it would help if you had a soft silicone strap to hold the puck in? I have some of these.

  • I use Twilio for a bunch of my tech tinkering. It is a programmable SMS and Voice service. The service lets you get a phone number for $1/month and each SMS is like 0.7 cents.

    Once you get an account on Twilio and create a number, you can access the service a number of ways. The easiest in this case was to just install the Node-Red Twilio node and put my account credentials in.

    https://flows.nodered.org/node/node-red-­node-twilio

    I have the Espruino/Node-Red servers running on as Raspberry Pi Zero W which cost $10. Not including the power adapter but I have a ton of low power plugs laying around.

  • Thanks for that link to the paper. I'll look into those solutions. I have a separate thread going about how to listen for both button presses and gyro/accel events. I'll update this thread with the results.

  • thanks! :)

  • Sat 2020.09.19

    ref: 'get a phone number for $1/month and each SMS is like 0.7 cents'

    Why not do it for that magical word FREE?
    (at least you are able to in N.A. - Have been doing in this manner for over a decade)


    Send an HTML post request to a web service:

    https://www.makeuseof.com/tag/email-to-s­ms/

  • I added the psudo motion detector that was explained by Gordon and am using both that and the RSSI as a way to detect motion of the puck (any motion is good in this use-case).

    For now, I am testing on my lab unit in my house so that I can tweak the threshold for magnetometer triggering and see if there is any noticeable patterns in RSSI as I move from room to room. Not much data in the charts yet...

  • And I added a count-down timer that resets ever movement trigger.
    Maybe set the timer for 1 hr and if no motion within the hour then trigger. I'll need to disable this alarm during evening hours.

    By the way, for those who think this is creepy spying..... just wait until you have a 90 some year old person who wants independence and living alone!

    The real reason for the lack of movement timer is to determine if the puck is still sitting on the night stand and not being worn.

  • Looks great! It's really good to be able to graph all this info nicely

  • @Gordon your movement detector using magnetometer works really well.

  • @Gordon , your suggestions for formatting the SMS messages worked really well. Using the Node-Red function block I can change my SMS Alert Messages to be more reader friendly instead of the engineering geek cryptic integer and T/F payload data points.

    I super appreciate the help given here. I have enough SW Dev background to know that various things can be done but I didn't know how to get them done in this Espruino / Node-Red environment.

    I now have

    1. Button Press alerts with a 10 second grace period where the wearer can cancel the pending alert.
    2. Motion detection with a 1 hour countdown timer. Detected motion will always reset the countdown so that the SMS Lack of Motion alert fires after 1 hour of no motion (only during normal waking hours).
    3. Battery Level is recorded with all messages
    4. RSSI can be used to determine if the Espruino has left the building. The 'left the building' state can halt the lack of motion timer. Obviously, if the puck has moved out of range then the motion event can't reset the timer.
  • I'm working with the dashboards now. What are all of your opinions on the two flavors of Node-Red dashboards. It looks like the node-red-contrib-ui one is being deprecated and going to node-red-dashboard .

    The problem I think I see is that it is hard to move back and forth between the two. I am a total rookie but when I built a flow in the older one and tried to switch to the newer one there were a lot of errors even beyond the obvious UI nodes. Not sure.

    Anyway, I have moved to the newer dashboard and have two tabs: "Home" for the puck and "Rpi" for the host pi metrics.

    I have mirror systems running on a Pi-zero-w and a Pi-4. I was tinkering with the RPi dashboard and the Pi-4 helps me test out the fan control portion of the system that activates on temp>x. My screenshot is on the Pi-4 but the only difference is that on a Pi-zero-w the utilization is greater. Still low on the zero but not that low.

  • By the way, if this is allowed here... if anyone wants to tinker with Twilio it would help us both if you use my referral code. We each get a $10usd credit if you use my link.
    http://www.twilio.com/referral/akNa6G

    Twilio is cheap for low volume scenarios. It is like $1/mo base plus 1/7 penny per SMS.

  • That looks great! Honestly I haven't had much time to look at dashboards - I was against changing the one that's suggested (I think you mentioned it in Github?) purely because I've used it in videos (http://www.espruino.com/Home+Automation) and really don't want to have to redo them! Didn't realise it was deprecated though :(

  • @Gordon not sure how authoritative this is...

    https://randomnerdtutorials.com/upgrade-­from-node-red-contrib-ui-to-node-red-das­hboard/
    Upgrade from Node-RED-Contrib-UI to Node-RED-Dashboard

    [NEW GUIDE] Learn how to use Node-RED Dashboard with your Raspberry Pi

    If you followed the Build a Home Automation System for $100 course prior to August 27 2016, you know that I’ve used Node-RED-Contrib-UI to build the user interface for the home automation system. But, sadly the guy that developed the Node-RED-Contrib-UI will no longer be able to update that package.

    Luckily, the Node-RED team announced that Node-RED-Contribu-UI will continue to be developed under a new name: Node-RED-Dashboard.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

My Mom is elderly but won't use a "I've fallen, call 911 service" - but she will use a "I've fallen, text my kids" button.

Posted by Avatar for HeneryH_(Henery_Hawk) @HeneryH_(Henery_Hawk)

Actions