Recently I've been expanding my home automation system using Netduino
devices that post data back to the main server over HTTP. The advantage
of this approach is that I don't have to run separate wires and each
Netduino I add can handle multiple analog, digital and OneWire inputs.
The protocol to post values is very simple: the Uri includes the unique
Id of the sensor and the payload is the value. The return value however
includes a min frequency, a max frequency and a desired accuracy. This
allows the server to throttle a chatty sensor to send less data by
reducing the resolution or by limiting how often it is allowed to send.
The third frequency specifies how often the device MUST report a value
even if it is unchanged. This allows the server to detect when a sensor
has stopped working.
One issue with using the Netduino and the various low level socket APIs
it provides is that it's far too easy to hang the device. I'm currently
building a watchdog timer circuit that will reset each Netduino if it
fails to report in.
Raw sensor data is interesting but the real power comes by applying the
various time-series aggregation methods I have in the system. For
example calculating the average in a given window of time, differencing
two sensors, ... Currently that's all internal to the home automation
system but I am considering expanding the RESTful API to allow querying
of the raw and aggregated sensor data.
I'm also looking at MQTT and various other protocols for sending sensor
data to see if there's an existing standard out there that would be
suitable.
I've been working on home automation for over 15 years and I'm close to achieving my goal which is a house that understands where everyone is at all times, can predict where you are going next and can control lighting, heating and other systems without you having to do or say anything. That's a true "smart home".
An overview of the many sensors I've experimented with for home automation including my favorite under-floor strain gauge, through all the usual PIR, beam and contact sensors to some more esoteric devices like an 8x8 thermal camera.
One way to reduce the volume of sensor data is to remove redundant points. In a system with timestamped data recorded on an irregular interval we can achieve this by removing co-linear points.
Home automation systems need to respond to events in the real world. Sometimes it's an analog value, sometimes it's binary, rarely is it clean and not susceptible to problems. Let's discuss some of the ways to convert these inputs into actions.
Another super useful function for handling sensor data and converting to probabilities is the logistic function 1/(1+e^-x). Using this you can easily map values onto a 0.0-1.0 probability range.
In a home automation system we often want to convert a measurement into a probability. The ATAN curve is one of my favorite curves for this as it's easy to map overything onto a 0.0-1.0 range.
An if-this-then-that style rules machine is insufficient for lighting control. This state machine accomplishes 90% of the correct behavior for a light that is controlled automatically and manually in a home automation system.