Home Automation refers to the automatic and electronic control of household features, activity, and appliances. It can also be seen as the use of one or more computers to control basic home functions and features automatically and sometimes remotely. Different professional solutions to home automation have been proffered by many giant bodies such as Samsung, Google and Apple HomeKit etc.
Why Home Automation?
Regardless of the technology used, home automation provides numerous benefits and importance. Outlined are some of the benefits:
- It reduces Energy Consumption
- Security and safety
- Emergency Aids to aged
So, let’s get started!
A Raspberry Pi will act as primary controller. Each room will have its own one Arduino UNO which act as slave of Raspberry Pi. Communication between Raspberry Pi and Arduino UNO will be done using I2C.
Arduino UNO Device:
There are several makes of Arduino device such as Arduino Nano, Arduino Mega, Arduino Mini and Arduino YÙn etc. In this project, Arduino UNO will be used because it has all the functionalities required for the project work. Arduino UNO has an onboard microcontroller that is based on ATmega328P which is A high performance, low power AVR 8-Bit microcontroller.
The Arduino board can be powered by three basic ways:
1) Through USB connected to a computer
2) Using a voltage adapter that converter AC to DC voltage. A DC voltage of 7 – 12V is recommended but it has a limit of 6 – 20V.
3) It can be powered by a battery.
The Arduino IDE contains the menu bar, tool bar and the editor. The sketch is written in the editor, verified and uploaded to the board.
Raspberry Pi 2 Device:
This is the latest make of Raspberry device, it was released in February 2015. It has some added functionalities that are not included in the first one Raspberry Pi 1 Model B+. It is around a BCM2835 system-on-a-chip (SoC) ARMv7 processor running at 700MHz microprocessor, hence it can run the full range of ARM GNU/Linux distributions, including Snappy Ubuntu 17 Core, as well as Microsoft Windows 10 IoT Core. In order to use Raspberry Pi 2 conveniently, it is very important that the various systematic and sequential steps in setting it up should be followed carefully. The steps are provided at the implementation section.
Configuration of Room:
Now considering room scenario, an Arduino UNO will control devices and reads sensor data. Periodically, Raspberry Pi requests for the sensor data collected by Arduino UNO. Each room have multiple controllable devices (i.e. Light(s), Fan, Wall Socket(s), etc.), one PassiveIR (to detect human presence in the room), one temperature sensor (LM35 to collect room temperature) and LDR (to detect light intensity near room window).
Device Address Mapping
The most important part is how we will identify devices? It’s simple. We will make device address by combining room number with device number.
Room Number 1 having three devices.
Device address will be:
To make it more easy, let’s start implementing for first room.
I2C address for Room 1’s Arduino is 0x40. I2C stripe can be used to connect more than one Arduino.
The relay are operated by 5VDC.
Our project consists of a Raspberry Pi 2 and Arduino UNO. Raspberry Pi 2 software is developed in QT framework using C++.
Let’s understand software in following formation:
- Protocol (How Raspberry Pi 2 and Arduino talks)
- Class Structure (How Raspberry Pi 2 maintains such complicate devices and rooms)
- User Interface (Wire-frame)
Protocol (How Raspberry Pi 2 and Arduino Talks over I2C)
Before going further, lets first decide how Raspberry Pi and Arduino talks. To make a reliable protocol, we must first have clear objectives or goals for the communication. In consideration of this project, goals are:
- Read sensors
- Read device’s state
- Set device state
Let’s start defining protocol first. Protocol defines rules to communicate over the bus. Protocol is nothing more than byte sequence. We have defined protocol for sending and receiving bytes. Sending bytes are fixed of three while receiving byte array is of fourteen bytes.
Now, we have defined a proper communication scheme that is able to give status and values of sensors, devices and also provides accessibility to set device state.
Class Structure (How Raspberry Pi 2 Maintain Objects)
As discussed first, this project considered whole home. Home consists of multiple rooms and room consists of multiple devices. Thus the OOP structure of such configuration is to be prepared.
Primary class “Home” consists of multiple room objects as generic list of room (List<Room>). Home class provides static method to load and save home object on the Pi to use them later.
Room consists of devices as generic list of devices (List<Device>) and sensor structure to encapsulate all sensors into one.
Device consists of details of them and functions to turn on and off them using protocol Mode – 2. AmbientLight, PassiveIR and Temperature class provides access to the room’s environmental data. Room object maintain sensor data and periodically refresh them using protocol Mode – 0.
Any application must be user-friendly. To make user-friendly application, start with wire-frame. Assume that you are going to use your own application and find out the main objectives and how to integrate them in such way that they will be most easy to end-user.
Hence, a UI is created for access to rooms and devices inside the rooms.
In future, we can add capability to communicate over remote devices using RadioFrequency or InfraRed instead of I2C bus. Web-management portal using Azure can be integrated for mobile devices. Further the real automation will be integrated like event based operation, timed operation with RTC chip. For example, turn on backyard lights at 7:00 P.M. and turn back them off at 10:00 P.M. So there is no limitation for this new Windows 10 IoT Core platform for Raspberry Pi 2.