A RESTful API for sensor data
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.