Insights

At DVT, we run regular online events focused on the latest technology trends within the IT industry and invite guest speakers to share their knowledge and insights on various topics. The DVT Insights Events aim to enlighten you, educate you and often, provide a new view on a burning issue within the technology space.

Lessons in IoT: How I made my Smart House
Knowledge Chikuse

Lessons in IoT: How I made my Smart House

Thursday, 08 October 2015 15:25

Imagine this: you wake up in the middle of the night to get a drink. You don't want to turn on the lights because you're still half asleep, but you need to or else you won't find your way. Luckily your lights are programmed to switch on, dimly, if they detect motion towards the kitchen. By the time you wake up, around seven, your music system knows to turn on the easy listening channel. You also get regular updates on your indoor temperature, notified of suspicious activity on your property, and the sprinklers know when to chase the early birds away.


Now stop imagining, because I've just built this smart house for myself, and these are some of the lessons I learned while doing it.


The first challenge was finding the right platform – information platform that is. There is a great deal of data that needs to be sent around the home network, depending on the activities in question. My first choice was .NET, because that's my default for all things cool, but after just a few iterations I had a truckload of source code for very basic tasks – and I hadn't even started on the fancy stuff.


After much research I found an open source platform built on top of node called Node RED, by IBM. It's an event processing engine that excels at orchestrating multiple data sources and consumers.


This seemed to provide just the right amount of abstraction, allowing me to think in terms of what I wanted to achieve, rather than getting bogged down in hundreds of lines of code. It uses a graphical drag and drop approach to writing software, making it very easy to mix and match multiple data sources.


While I still needed to write a bit of JavaScript, it was fairly minimal and easily managed. I believe this approach to building software will catch on more as the internet of things (IoT) becomes more widespread. I have also used it to great effect while teaching absolute beginners how to code. You can check some of the nodes I wrote on my Github page.


How I made my Smart House


Within a short time, I had my basic infrastructure set up, and the house was happily sending and receiving data via multiple online services. With a few drags I could wire up a Twitter feed to update me on the current temperature, push that data to mongo for storage or update my mobile phone when there was any unexpected movement inside. It's pretty liberating and fun to use.


The only drawback to this platform is node itself. Many of the packages I relied on for low-level tasks turned out to be surprisingly buggy, and my smart house would crash very often, too often to actually be useful. The best I managed was three days of continuous use, and this was on very good hardware. I expect stability will come with maturity, but for now, a healthy dose of patience is required.


The other challenge I faced was the availability of sensors and other IoT hardware. The South African market appears to be oblivious to this need, and the few shops on the web that sell sensors are way behind the state of the art, and their devices require a lot of electronic skills to use. Your only choice is to import these gadgets from overseas, and pay more than the cost of the device in shipping and duty costs.


I'm sure this will be resolved once businesses get on board and demand makes it profitable for people to sell devices. For now, you'll have to either cough up or pull out your soldering iron. On a more positive note, it seems that the capabilities of the devices being released are increasing at a much faster rate than when I started, and the costs are going down.


As with any software project, the last and most important aspect was testing. Testing a smart house is not like testing a website or mobile app. Unit tests do nothing to verify the overall correctness or robustness of the system, and actually increase the amount of code you have to maintain. There is usually so much going on that I found it easier to just do manual testing. I haven't found a great way to test the resulting product as a whole, but the platform I used helped to simplify my code into tiny bits of functionality called nodes which I could easily test with mocha.


Today I have a fully functioning and working smart house, built on the same principles we use every day in our software development and testing projects. It may have taken a bit more elbow grease and creativity to get around the logistical challenges, but it's encouraging to know the model can be replicated with great success beyond the web and smartphone.