Wednesday, November 25, 2015

Elderly Monitoring: Revisiting with Brutal Simplicity

Short backstory:

I've been running over a year now with the current Elderly Monitor system in my house. Mother-in-law has dementia and the current system lets us know her general movements throughout her living space (e.g. how long has she been up this morning? How many trips to the bathroom?)  and whether or not she has opened the front door (e.g. is she going for a walk? Has she made her escape?).
The current system consists of X10 wireless monitors for the door (open/close) and living spaces (motion detection).  This is fed to a small Linux computer I've coded with tracking logic, the ability to speak "Front Door is Open", and the ability to communicate (event message and status query) using XMPP to a cloud server (Digital Ocean) and to our smart phones (running Xabber XMPP clients).
It has been a success but with the lessons learned  I've found the most critical aspect of this setup is the ability to simply detect that the front door has opened and then notify us via a speaker in our bedroom.  All of this flows from X10 to Linux computer to soundcard (the Cloud is not involved here).  Still, this seems overly complex. Can it be simplified yet still be expanded to deal with "enhancements" in the future?

Let's review some of the short comings of the current solution:

  1. X10 Wireless - This has been "mostly" reliable and inexpensive. Still, I do have an RF noisy house and what if the neighbor starts using X10 RF?  (Not likely, but for a rock solid solution, this is a weakness).  Also X10 pretty much means that I have to have a full blown PC (with X10 CM19a transceiver) unless I decide to seriously hack the protocol and build my own RF receiver.
  2. The PC - Why do I need a full blown PC just to do the basic "Door is Open"?  
  3. The Cloud - Sure, I've got it, but if I want to distribute the "Door is Open" beyond the bedroom speakers, I have to connect via the Cloud (currently) and subscribe to XMPP messages (essentially what I do with the smartphone).  I need to make some of this stuff local.
  4. Batteries. Batteries. Batteries - Damn. Did the X10 sensor batteries die? When did I change them last? Ugh.
  5. There is no indication of whether or not she has just opened the door or left the house. I can code this logic, but since I want to address the above short comings first, this will have to wait.
What is the simplest thing I can possibly do?  Especially if I want to add logic like #5?
I am revisiting this problem and addressing it with brutal simplicity. 

Two things are going to get ripped out:
  1. The PC. No more computer. A microcontroller should be able to do this.
  2. No more X10. I'm going "wired". No more batteries either. I want to "set and forget" this thing. I'll deal with a little wiring. All of the current sensors are less than 20 feet apart: Door, hallway, bedroom, bathroom.
Stay tuned.  More details to follow as I hash out my brutal "simplest thing that could possibly work" design.


Monday, October 19, 2015

Elderly Monitoring: Telling a Story with minimal sensors

How many sensors do you need to tell a story?

I have a motion sensor in my mother-in-law's room, her bathroom (down the hall from her bedroom)  and an open/close sensor on the house front door (which is next to her room).   With just these two (cheap) X10-RF sensors I can tell a lot about the nightly activity of my dementia suffering guest.

If you  haven't been following this blog's "elder care" stories: My mother-in-law has dementia so she lives with me and my family. She is apt to get confused and wander. Her room (the only available extra room in the house) is unfortunately next to the front door.  The rest of the bedrooms are one floor up. Mother-in-law needs constant monitoring. She has "escaped" our house several times (at night and at dawn -- when we are still asleep) with the idea that she is going to walk to "her house".  She also complains of insomnia and chronic pain.  Is she sleeping at night? Is she up wandering the house?

So, I've designed a cheap  sensor-based monitoring system. I explained that tech setup elsewhere.  Here I want to posit the question: What kind of "story" can you tell with a couple of sensors?

With just a bedroom, bathroom motion sensor and a sensor to alert us when she opens the front door, I can talk about the following:

  • Did she leave the house or is she just "checking the weather" (door opens but is followed by movement in her bedroom)?
  • Is she restless at night (motion in bedroom)?
  • How many times did she visit the bathroom?
  • Is she in the bathroom for an unusually long time? (Bathrooms are where a high incident of heart attacks tend to occur)
  • When did she get up in the morning? (Motion in bedroom, then bathroom, then bedroom again)
Now, my current software doesn't tell a complete story (yet), but with the reports/alerts it generates, my wife and I can determine with a quick view of the data on our smartphone, any of the above scenarios.

I'd like to add a couple more sensors, maybe a light sensor and temperature monitor for the bedroom to help flesh these stories out.

The moral (of this post) is: You can tell a lot with just a few sensors and a lot of common sense.  It isn't about the "hardware tech". It is, ultimately, about making sense of data.  I want to get my software to the point where it "tells the story" rather than just provide data for my wife and I to review.  Here is my ideal morning report (sent to my phone instead of the raw data events):

Betty slept between 9:30pm and 6:15am, awaking at 11:15pm and 2:30am to go to the bathroom.  At 6:30am she opened the front door, closed it and went back into her room. Her room light has been on since 6:45am and there is currently no movement in her room.
I don't need this report in verbose english (like above), but I should be able to quickly derive the above story from summarized data points.  All of this can be surmised by the current three sensors.

Sunday, October 11, 2015

Hacking Inside Out vs Outside In: Lua vs Clojure

I've got a couple of CFT (Copious Free Time) projects going on at the same time:


I've so far have 2 semi-working (new) implementations for each of these projects.  I  started developing both in a high level programming language (Clojure) and ended up runnng into a few walls that caused me to look at alternative implementation languages (in both cases Lua(JIT)).

With Clojure I got to swing around futures, core.async and rich data structure manipulation, but I hit implementation walls involving libraries (mostly Java) that don't quite do what I want. Soon I was finding myself installing broken, old or incompatible packages.   

Abandoning Clojure, I headed back to LuaJIT. Here I had much more control over my environment, but greatly missed builtin things like futures,  core.async and rich data structure manipulation.

Clojure and LuaJIT represents the opposite ends of the spectrum but they do have the ability to overlap (I can drop down to Java/JNI in Clojure and I can evolve Lisp-like richness out of Lua).

It's bottom up vs top down, or inside out vs outside in.

I need to bite the bullet, pick a direction and stick to it.

Thursday, October 01, 2015

Confab - Adhoc private VOIP/chat for conferencing

In my copious free time I am working on a new system I am (tentatively) calling Confab.
Confab is an adhoc (on demand) VOIP conference call system utilizing the popular gamer VOIP/chat system Mumble.

Confab will use any Mumble client (iOS, Android, Windows, Linux, etc) but will only implement enough of a subset of a Mumble server to allow for quick conference calls. (Mumble certs won't be used for authentication, so you won't have to install certs on your Mumble client.)

The idea is that there is no conference call service running until you need one. And, once you are done, it goes away.

But, why not use free stuff like Skype or Google Hangouts?

  1. Skype and Google Hangouts require registered accounts (with personal info about you)
  2. Skype and Google Hangouts persist your previous chats (which can be annoying if you never want to talk to these people again)
  3. Your account is "permanent". Your connections, your password, etc. Always there waiting to be cracked or exploited.


With Confab, you point your browser to the Confab Website, enter a conference start time and you are provided with a server name, a port number and a small once use password (e.g. a23gHYz). The Confab Mumble server (tied to the designated port) doesn't accept connections until the startup time.
Because each session is tied to a unique port number, there is more security than can be offered by a single server with "channels" or "rooms".

You give your participants the server name, the port number and password so they can join.  Once people join you can chat(text) or talk(voip).  The Confab session terminates after 10 minutes of idleness (no one is talking or chatting).  You can also configure an absolute call duration time (e.g. 60, 90 minutes, etc).  Each Confab session should support a couple of dozen participants.

Why not just use a normal Mumble server?  I want to drop the gaming oriented features, but I plan to add unique server-side features such as:
  • Federated servers - connect multiple servers to allow inter-conference calls.
  • Support for bridging to other "open" chat/voip servers.
  • Support "audio casts" (recording and simultaneous broadcasting of audio via one user's phone/computer) to dozens of participants
  • Moderated conferences (e.g. question and answer sessions, etc) via helper bots.
  • Voicemail (and text message) capabilities (call in and leave a message for others)
  • Possible support of POTS (plain old telephone service) bridges

I'm finishing up the basic Mumble-compatible server right now (not yet supporting the above features).  It is designed to be lightweight and fairly scale-able. I have no intention on providing or modifying existing client side software.

My server software will be released as open source.  I am planning on setting up a small test server on Amazon AWS or Digital Ocean.  I'll let you know (here) when it is stood up.  If this works out, maybe I can get some donations (Amazon, PayPal, etc) to offset the costs...

Sunday, July 19, 2015

Elder Home Care in an RF noisy house

The BT tags I mentioned in my previous post is acting erratically.  During certain times the tracker tokens lose contact with the server (for minutes) even if just a couple of feet away.  BT LE is supposed to be broadcasting on a channel not used by IEEE 802.11 Wi-Fi, so I am not sure what is drowning the broadcast. I don't have a 2.4Ghz wireless (house) phone so that isn't the culprit.

I don't have a spectrum analyzer, so I am limited in my investigative resources...

I'd hate to have to drop down to 433Mhz sensors.

The good news is that this can possibly be solved in software.  The problem is the "false positives".  Since the monitor notifies me upon the sensor going out of range, when these RF anomalies occur I am falsely alerted.  One approach is to have a "control" tag permanently installed in the room with the detector. If both the control and tracking tag go "out of range" then it must be an RF anomaly and I shouldn't be notified.

Friday, July 03, 2015

Phase II of Elder Home Care (formerly Elder Home Alone) Monitoring System

It's been a while since I've posted about my home monitoring system.

Short recap:

A couple of years ago, my Mother-in-law lived alone in a Condo and was prone to leave her stove on accidentally and other forgetful things. I started working on a home care monitor for the "Independent Elderly".  It would include basic occupancy trackers, water overflow detectors and stove/kitchen monitoring (to make sure it isn't left unattended and to monitor her eating habits).

Well, fast forward to..  my dementia diagnosed Mother-in-law moved in just over a year ago.  So, the problems are a bit different.  She wanders. She gets up in the middle of the night to go to the bathroom and can't find her way back to her bedroom. She may go upstairs in the dark and stumble or venture outside.  Sometimes, during the day she may decide to walk home... to her childhood home, several states away.  She is old, but fast.

The current system uses "cheap" X10 RF motion detectors and door monitors. I can review past activities (e.g. when did she get up this morning? Did she frequent the bathroom last night?) or I can be alerted to the house door being opened (Is she just checking the weather? Is she going to sit on the porch? Is she going to make a run for it?).
The alerting system consists of some software I wrote (runs under Linux on a small Intel NUC PC) and it, currently, sends XMPP (Jabber/Chat) messages to a cloud server (on Digital Ocean) which runs Prosody XMPP server. My wife and I are connected to this server using XMPP chat software (Xabber) on our Android phones.  We can query the monitoring system from our phone or be chimed when the door opens.

It has run well for a year now. :)

But, now that my Mother-in-law is prone to taking long unannounced walks, this system is not enough.
The phone chimes when the door is opened. Is it one of the kids? Is it her checking the weather? Is the door already opened from a previous check?  Is she *really* still sitting on the porch 10 minutes from now?

So, after an early phone call one morning, from the Police (she managed to get several blocks from the house before sunrise), we decided we needed to invest in a tracking solution.

Most tracking solutions either involve GPS (battery drain, and overkill -- if we know that she has left we can pretty much find her in a matter of minutes -- if we know she has left.

Not a lot of solutions out there.  Found one on an Alzheimers website. It *only* requires recharging every 48 hours. Ugh.  What do we do while it charges? Do we need to buy two?

So, I decided to look into BT LE (Bluetooth LE). I had built several BT LE tags years ago and was interested to see what the state of the art was today.  Apparently, Fitbit uses BT LE beaconing. That is, every second or so it broadcasts it's address so your phone can handily connect to it on demand.
BTE has a very limited range, but that's okay.
Also, Apple has been pushing "iBeacon" for their own (non-elderly) tracking purposes. They have a spec and a number of hardware vendors. I found this tag on Amazon for $14. Although meant to be used with Apple devices, it does a simple BTE beacon/broadcast that I can readily track.  This is perfect size to be "hidden" in her purse (in a small crevice/pocket) and the battery should last 6 months - 1 year (I'll assume 3 months and schedule an early battery replacement).

Armed with the BT 4.0 PCI card in my NUC, I attacked this challenge a week ago. Now I have a rudimentary system that will let me know when my Mother-in-law has ventured beyond the front porch. My android phone (running Xabber) is notified whenever the tag goes out of range.

There is a lot of work to perfect this, but I am happy with the preliminary results. I will be moving the notifier beyond the phone (maybe home media -- DNLA/TV/etc or just speakers on the NUC) and making it work locally in case we lose Internet connectivity.

I will be releasing the software into open source within the next few weeks.

Saturday, February 28, 2015

Virtualization: Your PC is a Universe

PCs (and, honestly I am really talking about Laptops and the newer PC replacement tablets) are so powerful that they no longer have to be thought of as singular "client" resources.  That is, with sufficient memory (let's start at 8GB RAM)  and with enough SSD speed storage (>128GB),  folk like myself typically run many virtual computers inside our computers.

If I need to run Windows, I just fire up Virtualbox. If I need to do server development, I can pick stuff like Vagrant, Docker or go directly to LXC.  I can do Android development. I can do Windows development. I can try out Haiku or some new BSD.  I can do all of this without changing the underlying OS.  The underlying OS, in fact, is starting to become irrelevant.  Give me a Windows box and I can do full Linux stuff on it without replacing the OS: Just start up a Linux VM.

The thing is, at any given moment, my laptop is a Universe of virtual computers. I can network these computers together; I can simulate resources; I can test them, probe them and manipulate them.

This is new. Yes, yes -- the tech is pretty old (e.g. virtual machines), but the realization of this tech on a portable computer is new.

If you want to see where we may be heading, check out something like Rump kernels or OSv. We are starting to leave the OS behind and look at computing in terms of "microservices" -- collaborating virtual computers that solve a particular problem.

With the resources we now have on hand, why are we talking about systemd and Dbus and other single computer entities?

The next time you approach a design, try thinking about how your laptop can be *everything*. And then let that influence your design.


I will be Cyborg.

I haven't had a lot of time to post to this blog and I am wondering if this is the end of the line for it.
Well, we will see.  But for now...

I am approaching 50 (in 1.5 years) and my eyes are shot (I'm very near sighted).  The screen is blurry (I have transitional bi-focals, so my "clear" view is pretty marginal) and isn't going to get any better.

So, if my eyes sight starts to quickly wane (my eye doctor isn't really concerned... yet), what do I do?
While I can use magnifying glasses for my circuit work (which starting to become a thing of the past for me anyway), what about my programming and computer science stuff  (i.e. my screen work)?

Duh.
I'm a programmer and technologist.  I can hack something together to supplement my poor vision.  Even if I were to go blind (that isn't currently in the cards, but who knows), there are ways to continue to do "Computer Science".
There is technology already out there, and I can always invent what I need to aid me if my eyesight worsens.

Sometimes I forget that, with software and some gadgetry, we invent whatever we need. We are indeed sorcerers and alchemists :)