johntwomey

At Emutex, we create and sell great software to professional companies building solutions. From time to time, we also build proofs of concept, prototypes and demos. We do this to educate, to promote awareness, to enable hobbyists and to demonstrate what we can achieve.

 

John Twomey - CEO.

 

How Emutex's CTO made his house smarter through ubiworx™.

 

 

Mark Burkley, our CTO, describes how he finally made his home smarter using our ubiworx™ IoT software framework. From securing his garage door through to controlling his home’s internal and external lighting, Mark explains how he implemented the entire solution and encourages readers to try build similar smart solutions.

How it all began

If you are like me then you also have a garage that has a vast collection of tools and other bits and pieces that are carefully arranged in a way that looks like a complete mess to the untrained eye. But in fact we know exactly where everything is, and restricting access to only those who won’t rearrange everything in a misguided attempt to help you is a must. I decided an interesting use case for ubiworx™ would be to control a magnetic door lock to my half of the garage.

Once I started building the access control I thought wouldn’t it be good to incorporate some PIR sensors to also control the lights. And maybe include a temperature sensor to check if the temperature drops below freezing. While I’m at it, why not get rid of those mechanical socket timers that we use to turn on and off lights while we’re away and at the same time save me from having to switch on all the lamps every evening and off every morning. Finally, wouldn’t it be nice if I could control all this over the internet but more importantly keep an audit trail of exactly what was activated and at what time. And just because it’s Halloween let’s incorporate some outdoor Halloween decorations and lighting too.

While this project is a bit of fun, I am using it to demonstrate some key advantages of using ubiworx™. A key aspect is of course having to write zero lines of code. ubiworx™ is very modular and extensible, and you can add on support for any sensor you want, but for most use cases you just can configure it out of the box which is a great way to rapidly develop an IoT solution. In addition, the web UI allows dynamic creation and tuning of logic rules to be executed by the gateway without ever having to physically access the gateway.

Hardware Setup

Setting it all up was fairly straightforward. I used a standard Intel® Atom® based gateway running the ubilinux™ operating system and the ubiworx™ IoT framework with peripherals connected via USB (I would have used an UP board but I will have to wait a few more months for it to be available). I used an RFXCOM RFXtrx433E USB 433MHz radio receiver to be the base of a radio control network. For motion detection, I used a couple of Home Easy HE861 Passive Infra-Red (PIR) sensors. These devices are battery powered and weather proof. For environmental sensing, I used Oregon Scientific THGR810 temperature and humidity sensors, also battery powered and also 433MHz. An Xbee USB controller connected to another USB port acted as the Zigbee coordinator which allowed me to control my lights using a TOSR04 relay board with an Xbee ZigBee Pro receiver.

Software

The software is a release candidate 1 of ubiworx™ 0.8.3, which will be publically available in December. No new devices types were introduced so I didn't have to write any code - just configure existing blocks using the cloud management interface. The first two devices I set up were the RFXCOM and Xbee devices. I set both to discover mode to find the other devices for me. The Xbee module reported it had found a device with description RELAY_001 which is the standard for the TOSR04 relay so I set up two relay devices on node RELAY_001 called XBeeRelay1 and XBeeRelay2. Walking in front of the home easy PIR caused it to send a command signal which the RFXCOM received and announced to ubiworx™ that it had discovered a home easy device. This creates a bunch of new sensors including signal level and battery level but for now I am only interested in the command sensor. I renamed this sensor to “driveway” to help me find it easily. Cloud reporting is of course vital to any IoT solution and I figured gathering statistics on usage patterns is a unique way to demonstrate this. The THGR810 temperature sensor reports about once a minute so after a short wait it appeared as well and various new sensors appeared on the ubiworx™ dashboard telling me about its capabilities. Again, I am not terribly interested in battery levels, etc, at the moment, though in time generating an email alert when batteries need to be changed would be very useful.

Outside Lighting

I want to use the PIR sensors for occupancy sensing in the garage. Both to detect when someone is attempting to borrow my previous tools but also to activate the lights to save me fumbling in the dark for the light switch. However, SWMBO decided that an outside light where she parks was more important so that took priority. I used the home easy HE861 wireless battery powered all weather sensor to detect motion. Because this unit has no wires, it offers great flexibility in its location and doesn’t need to be mounted near the actual light it is controlling. So I put it on the opposite wall to the house so it can “see” motion from either the back of the house or the front.

To control the outside light, one of the simplest methods is to use a WiFi controlled Smart Plug from Kankun. These are available from Aliexpress for about US$17. Because the Kankun plugs also run Linux (openWRT to be precise) you can install ubiworx™ on these plugs and make them into fully fledged ubiworx™ gateways. Detailed instructions on how to do this will follow soon. The socket are very small and accept any plug but have themselves Chinese mains pins. The vendor I used kindly included Chinese to UK adapters though. Since they are gateways in their own right, they can be independently managed and monitored. Also, we can use their relay functionality as a remote actuator in our logic which is a good demonstration of how we can create interactions between gateways that are running ubiworx™. We can even create interactions at different locations and in different WiFi zones if we want to so long as each location is connected to the internet.

The outside light is a 400W halogen bulb with a mains cord attached. I ran the mains cord in through a window and plugged into the Kankun Smartplug. If this light stays here permanently, I’ll drill a hole through the wall for the mains cable, but as this is just a trial run, using the Window is fine. Using ubiworx™ logic, I created a rule to activate the light for 30 seconds after any activation of the PIR. I used a one shot timer to create the 30-second time. This seems to be adequate for now to let me get from the car to the back door.

Indoor Lamps

I used a couple of more Kankun plugs to control some lamps in the landing. These just have a simple time comparison to come up at 17:15 which is about when it starts to get dark. If I wanted to get really clever I could incorporate a sunrise and sunset table into the logic! Of course, just being able to control the lights from the web UI is in itself a huge advantage.

Garage Control

After the outside light was working, it was back to the garage. Because I can never find my keys, I wanted to make a keypad entry system. Because keypads aren’t cheap, I just mounted a USB keyboard and drilled a hole to push the USB plug through to the gateway. A simple ubiworx™ device called “keybarrel” implements a barrel shifting keyboard reader that returns you the last “n” keys pressed. This allows you to compare the keyboard entry to a pre-programmed PIN number without having to worry about resetting state if you mistype your PIN and so on. There is no feedback to say PIN right (except that the door opens) or wrong so if you get it wrong, just type it again. Also it means I can type a load of junk with my PIN in the middle and the door will unlock and anyone watching doesn’t know the junk isn’t part of the PIN.

The doorlock wasn’t as cheap but it is a strong electromagnet that will hold the door closed with any pressure that I could apply. It needs a 12V 400mA power supply which I happened to have lying around. To avoid wiring mains voltages I cut the plug off the DC side of the power supply and wired this through a relay and a light switch to the electromagnet. The light switch allows me to get out, or disable the doorlock completely, from the inside. The relay is under ubiworx™ control.

The relay board is a TOSR08 connected to the gateway by USB. ubiworx™ has device scripts for TOSR08 boards so I just needed to specify the USB port and relay number. It is shown here before I wired it up. I could also have used one of the Kankun plugs or even a 433MHz remote socket. That would have been slightly easier as I could have just plugged the 12V wall wart directly into it. This door opens if the mains fails – this isn’t unintentional as it lets me have a back door if I misconfigure anything. A cheap UPS could be added if I wanted to make it more secure.

Halloween

Because it’s Halloween (and because I can) I also set up some last minute Halloween lighting in the garden. My kids have pretty much grown out of the trick or treat phase so it's left up to the big kids like me to have the fun. I hung a plastic skeleton from a tree with another home easy PIR sensor in his ribs to detect anyone approaching. Then I wired up two GU10 LED lights to illuminate the skeleton whenever I wanted. A couple of cheap pudding bowls protected the lights from the elements and a weather proof box protected the relays and mains plugs.

I used another relay board but this time used the Xbee option since we are out in the garden now, well away from the gateway. A double socket provides power for the relay board (5V) and for the lights. They are controlled through relays 1 and 2.

For the timing I just used two one shots. There is an adjustable timer on the home easy so I could have tweaked that and connected it directly, but being an all weather unit you have to open it to make adjustments. It's far easier to use the ubiworx™ web UI change the value in the one shot timer than it is to travel outside and take apart the PIR unit.

Rules Logic

The first image below shows the logic I finally ended up with. I kept my inputs on the left and the outputs on the right. Some local intermediate tags such as “north-house” and “driveway” make the logic self-explanatory, but also because nodes are limited to having one output, so to perform more than one action from the same event requires creation of an intermediate tag.

Of course the whole point of IoT is big data aggregation and analytics so I created a couple of virtual sensors including one called activity which counts how many time site her our sensor is activated. I can also count how long each of the lights are active for, sum them up and multiplayer against a known wattage or introduce a supported energy meter into the mix, you never know maybe my Christmas lighting display will be big enough for me to have to worry about my energy bills.

 

Ubiworx Logic

The rules logic that I used for this project for both the driveway and the garage control.

marks local logic

Relay Board

This is the relay board that was used for the garage control system.

relay board

The Garage Control

This is how the keyboard looked mounted on the wall of the garage.

USB keyboard

 

Summary

Total setup time was about 2 hours, and most of that was wiring. Setting up the logic in ubiworx™ took 10 minutes. Many IoT frameworks require significant amounts of Python other scripting language code to be developed. This is ok for a prototype but clearly needs to be redeveloped and carefully validate before production. ubiworx™ has been carefully validated and is maintained by a team of professional software engineers so no need for that here.

The wired aspects of the system worked perfectly but the wireless parts were not without their hiccups. The Xbee modules did not have enough range to communicate with TOSR04 board when the gateway was in the garage, so I had to move it into the house temporarily. I could have add a Zigbee router node and created a mesh but I wanted to keep the setup simple for now. ubiworx™ does not have the capability to configure Zigbee meshes so this would also have necessitated using other third party software. The RFXCOM worked better but there was some interference with my existing heating controls. Possibly changing the channels on the PIR sensors would have helped.

I have a few enhancements in mind when I get time. One is to create overlapping pools of lights so that one sensor brings in a number of lights near it. This would allow me to move through zones around the house and ensure I the area I am in is always lit as I move around. This is only possible with inter connected lighting and sensors so is another interesting use case. Using the accumulator block in the graphical logic will allow me to count the total number of hours of use each light has. I can use this to calculate the running cost and see if I can justify swapping the halogens for LEDs. Or I can see if some lights get a lot more usage than others. I can even check how many hours I get from a single bulb to see if the manufacturers claims are accurate.

And of course, it's only seven weeks to Christmas, so best get planning for that one next.

 

Go To Top