Home automation system design: the basics - Embedded.com

Home automation system design: the basics

Home automation is a method of controlling home appliances automatically for the convenience of users. This technology makes life easier for the user, and saves energy by utilizing devices according to strict requirements. Controls can be as basic as dimming lights with a remote or as complex as setting up a network of items in the home that can be programmed using a main controller or even via cell phone from anywhere in the world.

A home automation system can involve switching off electrical appliances like air-conditioners or refrigerators when a desired temperature has been reached, then switching on again when the temperature has crossed a certain value. A home automation system can also be used to secure a house from burglars by sending alerts to the nearest police station and the homeowner in case a trespasser is sensed.

Figure 1: A basic home automation system

Apart from algorithmic automation, devices can be controlled by the user to suit personal requirements using direct buttons, cell phones, the internet, or infrared remotes. A network of appliances and sensors can interact with each other and make decisions for operation.

This article provides a framework for designing a cost-effective and functional home automation system, first discussing the general design considerations that should be evaluated before starting, followed by a review of the trade-offs amongst various architectural approaches, and then how to implement that design using system-on-chip technology.

Figure 2: Control unit examples

Design considerations

There are several design challenges and considerations involved while developing a home automation system, many of which are determined by user needs. Once those have been determined, the designer can choose the appropriate processor, sensors, and communication protocol for the system, keeping the following parameters in mind:

Type of Interface:
The most basic and crucial requirement in a home automation system, the interface is the basic communication protocol and hardware combination used for sending and receiving messages between devices and the user. Designers have many options for executing communication between devices, the user, and the overall system, depending upon the system, range, size of house, ease of use, etc. If a user wants to control the home appliances through the Internet, the designer needs to add an Ethernet/Wi-Fi interface to connect the system to the home network. If the user wants to control the system using Bluetooth from a cell phone, the designer needs to add a Bluetooth interface to communicate with the device.

The choice of communications interface also depends upon the topology used between the central control unit (CCU) and room control units (RCU). These units will be discussed in more detail later in this article.

Sensing Requirements: The designer needs to determine the sensing requirements of the user and decide upon the required sensor to perform the task. He or she also needs to assess the sensor specifications required for different needs and usability in different environments. The range of sensors that should be considered include:

  • Thermistors can be used to control air conditioners, refrigerators, geysers, heating system, or in case of fire.
  • Humidity sensors sense the moisture level in the environment.
  • Gas sensors can be used to detect gas leaks.
  • Light sensors can be used to detect the luminous intensity in the house.

The information provided by these sensors (after signal conditioning) is used by the processor to make several important decisions regarding the appliances and when to switch them ON or OFF.

Security level: Another major requirement while designing the home automation system is to make the entire system secure so that it can’t be easily altered to give control of the house to unauthorized users. It should be able to prevent most types of intrusion. Even if the system is broken into, it should be able to send signals to the user and the nearest police station. It also necessary to hide as many components as possible from direct access via the main control panel, preventing it from being turned into a black box. It should also be able to send and comprehend encoded data while communicating with other devices. This will prevent intruders from tapping into the system and using the same interface to hack devices.

Topology: Topology defines the way home automation control units interact with each other. A star type topology is the most commonly used as it makes use of a central control unit (CCU) interacting with all the available remote control units (RCUs) and taking over decision making responsibilities. The role of the RCUs is to send data fetched from the sensors back to the CCU. After it has assessed the input from the sensors and made any necessary decisions, the CCU sends the command back to the RCU to take a specific action.

Another topology to be considered is a mesh topology, which has no CCU and makes use of a constellation of control units of roughly equal intelligence and capability connected with each other. Each unit sends information on the network which is shared by all the units. Each Unit is independent and makes its own decisions based on the shared information.

The choice of system topology governs the selection of communication interfaces such as ZigBee, RF, Bluetooth, etc.

Depth of automation: System design is affected by the requirements ranging from simple control of lights in the house to controlling all appliances and the security system. Each requirement affects the overall design, and developers need to determine the most optimized way to perform all the tasks with the lowest cost and complexity. Despite the internal system complexity, the system should be easy to use and not pose barriers to its operation by a household user.

Cost: This is the most important aspect of system design as system complexity and depth of automation determine the cost. A highly complex – and thus costly – system can deter customers from purchasing and installing it in their house.

The cost of the system is directly linked with the number of components, interface used, and complexity of design of firmware and hardware. While there should be no compromise on the quality of hardware and software, the number of components in the system can be decreased to reduce the overall cost and system size as well. Rather than the traditional component-based approach, lower cost can be achieved using System-on-Chips (SoC) that integrate multiple peripherals and a processor into the same IC.

The architecture of a home automation system

While there are several topologies to choose from, for the sake of simplicity we focus in this article on a star topology-based home automation system and its two types of control units, the CCU and multiple RCUs (Figure 3 ).

Figure 3: Star topology system architecture

Central Control Unit: The Central Control Unit is the hub and brain of a home automation system. Common features of a central control unit are:

  • Measuring the current environmental conditions using the various sensors and control the lights and fans of rooms accordingly
  • Receiving instructions from a remote user over GSM or Ethernet and controling an appliance in a specific room as per the received instructions
  • Controlling appliances based on time, such as automatically switching off a television at a specific time
  • Monitoring the current state of power and switch off appliances to protect them when a power fault is detected
  • Informing remote users when an intrusion is detected or when some fault is detected in the system

Room Control Unit: A Room Control Unit controls the appliances in a particular room. It has a set of sensors to sense the surrounding environment. Based on the current conditions, it can decide upon a course of action. Common features of a room control unit are:

  • Monitor the current environmental conditions using the various sensors and communicate this data to the CCU
  • Receive instructions from the CCU and control appliances in the room as per the received instructions
  • Control appliances based on inputs from a hand-held remote
  • Control appliances based on inputs from user buttons

Let’s look at the architectures of both of these units separately:

Central Control Unit
This is the main unit responsible for monitoring the complete home automation system. It interfaces with other system blocks to perform required tasks. The most common interfaces on a CCU are shown in Figure 4 . Some of these interfaces are optional and are used as per the system and user requirements.

Figure 4: Central control unit block level architecture

Different blocks found in a typical central control unit are:

Sensors: Sensors are the eyes of a home automation system. They “see” the environment and convert what they find into an electrical quantity that can be measured by a microcontroller or system processor. Basic home automation sensors include temperature sensors, humidity sensors, light sensors, and gas sensors. Data in the form of signals from these sensors can be used to control the various appliances directly without any human intervention. For example, lights can be automatically switched on upon sunset, an air conditioner can be switched off automatically when no movement is detected in the house for a half hour, or an alarm can be raised when the system detects a LPG leakage event.

Analog Front End (AFE): Each sensor converts the change in a physical parameter such as temperature or light intensity to a similar change in electrical parameters such as resistance or capacitance. These physical quantities must be converted to a voltage equivalent so that the microcontroller can identify the variation in environment. For this purpose, an analog front end (AFE) is interfaced with analog sensors. The AFE preconditions output signals coming from the sensors by filtering out noise and providing required gain to the signals. AFEs are also required to calibrate the system for sensor readings, thus providing a base value for the system to identify any changes in the environment.

Remote Connectivity: Depending on need and various design considerations, users may need to be able to control the system and appliances remotely. The two most common ways of doing this are using GSM-based mobile telephony and the Internet. GSM, Ethernet, or both interfaces can be used to communicate with the system from a remote location. The system can also send or “push” useful information to users such as periodic updates, faults, intrusions, etc. These connectivity options generally require a serial communication protocol like SPI or I2C to communicate with the host processor.

Local Connectivity: The Central Control Unit and Room Control Units need to communicate with each other periodically as well as when events occur. There are multiple options available to establish communication between the CCU and RCUs that can be decided upon based on system cost and topology, including Bluetooth, RF transceivers, and XBEEs, among others. Each of these interfaces has its own pros and cons, hence system designers need to consider all of a system’s requirements before selecting a particular interface.

Manual Control: In a typical home automation system, there are situations when the user needs to manually control one or more appliances. Keypads and/or infrared remotes are most commonly used to provide system control to users. Manual user control should be authorized by the system to prevent control of the system by an intruder and the shutting down of intrusion alerts.

Real Time Clock (RTC): Home automation systems must be able to control appliances based on time. An accurate time source is required to control appliances using time-based settings. An external RTC can be used to maintain time for the system and the central controller can access it to receive current time related information.

NFC Interface: Near Field Communication (NFC) is used for close proximity communication. This technology is quickly gaining traction in embedded applications for communications and information sharing. It can be used to at the main door to lock or unlock the door using the homeowner’s NFC-enabled smartphone.

Power Monitor: In any house there are many electrical appliances that are sensitive to voltage fluctuations and need a reliable supply voltage within a specific range to work as expected. A power monitor block can be added to the Central Control Unit to check the instantaneous power supply voltage. This block brings down the voltage level of power supply to a level where the system can monitor it using an ADC. Using input from this block, the controller can detect low voltage, high voltage, and voltage fluctuation situations. In extreme cases, this block can instruct RCUs to switch off sensitive appliances to prevent damage. An example of a simple power monitor circuit is given in Figure 5 and can be easily implemented into automation systems.

Figure 5: Power monitor circuit

In the power monitor circuit, the potential divider circuit brings down the mains voltage to a lower voltage which can be safely measured by a microcontroller ADC. The peak detector circuit creates an envelope on the scaled down voltage that gets measured. The protection diode protects the microcontroller by limiting the maximum voltage to its Zener Voltage (Vz).

Room Control Unit (RCU)
The room control unit (Figure 6 )is responsible for controlling the appliances installed in a particularroom. This unit receives control commands from the central control unitand also from user buttons that can directly control appliances. Theroom control unit can also have various types of sensors built in tolocally monitor the appliances in the respective room. If the RCU has anIrDA interface, the user can control appliances using an infraredremote. Optionally, if Bluetooth is used for local communication, thenthe user can control the system using a smart phone.

An RCU is anauxiliary unit responsible for monitoring local environmentalconditions and controlling local appliances connected to the unit. RCUsare essential for a large house with multiple rooms. These unitscommunicate the local environmental conditions to the central controlunit, and also control the local appliances based on commands from theCCU. This unit interfaces with other blocks in the system to perform therequired tasks. A block level diagram and description of a RCU is givenin Figure 6 .

Figure 6: Block level architecture of Room Control Unit

Buttons: These buttons are provided to directly control the appliances, enablingthe user to directly switch on or off any appliance using aswitchboard. These buttons also serve as an emergency control panel incase the CCU system fails.

Infrared sensor & decoder: These blocks provide an interface for commonly used, handheld infrared remotes.

Relay drivers: Therelays needs ~100mA of current to activate, so relay drivers must havethe required drive strength to power the relays. These also protect thecontroller from the inductive kick generated in the relays.

Building your system: the programmable SoC approach
SoCarchitectures can integrate most of the functionality of a system into asingle chip, reducing both time-to-market and bill of materials (BOM)costs. Integrating in this manner also makes the system more difficultto reverse engineer as the implementation is hidden within the chip.

In addition to accelerating design, SoCs provide several business-level advantages:

Lower Cost: The total cost of integrated components can be substantially more than that of a single SoC.

Faster time-to-market: An SoC reduces the time required for a product to reach market giventhat designers are able to work with a smaller system with fewerexternal components.

Simplifed system modification: Multiplehome automation systems can be designed based on the same SoC becauseof the availability of different interfaces and features. This increasesthe benefit of using an SoC in a system as the architecture can remainthe same, enabling design to become more plug-and-play. Using a singledevice can reduce component count to provide a more compact solution.

SoCsoffer different levels of integration. For example, the PSoC family ofMCUs from Cypress integrate most of the components a home automationsystem needs, requiring only the external sensors and a limited numberof passive components. In addition, Universal Digital Blocks (UDBs)within the PSoC architecture provide programmable hardware logic foreven greater integration by enabling designers to integrate customdigital logic in Programmable Logic Blocks (PLD).

Requirements for the system

  • ADC to sample multiple sensors
  • SPI communication interface to various peripherals
  • I2C communication interface to RTC
  • Hex keypad Interface
  • IrDA interface for infrared remotes
  • Output pin to drive the driver circuitry

System-level design
Toaid in developing with SoC architectures, silicon manufacturers offerspecialized tools to facilitate managing communication and data flowthroughout the SoC as well as create reliable firmware and configureprogrammable logic resources. For example, Cypress’ PSoC Creatorprovides a graphical design interface that allows developers to quicklyutilize pre-qualified, production-ready components with simplifiedconfiguration and easy-to-use APIs.

Click on image to enlarge.

Figure 7: Architecture for home automation system as shown in PSoC Creator

Figure 7 shows a complete home automation system design. The various components used include:
ADC:The ADC is used to take the readings from the temperature and gassensors, sample the sensors, and provide a digital value which the CPUcan use to make intelligent control decisions.

Thermistor: This component provides an API to convert the digital reading of the temperature sensor into temperature.

SPI: The SPI component directly interfaces with the various peripherals likeNFC, Ethernet, etc. This interface uses an additional de-multiplexer toaddress multiple communication modules using a single host.

I2C: The I2C component interfaces to an RTC and can be expanded to connect to any I2C slave device.

Hex keypad: This is a custom component implemented inside the design environment.This component reads a key press detected in a 4×4 keypad using a statemachine designed with UDBs.

IrDA Decoder: Thiscomponent takes the signal from an IrDA receiver, decodes the signal,and provides the decoded result to the CPU for evaluation and action. (Figure 8)

Click on image to enlarge.

Figure 8: IrDA decoder circuit diagram

Internal circuit of custom components: SoC design tools provide developers with the flexibility to designcustom components using common system blocks as well as hide the complexof circuits behind a simple-to-use block. The above design uses twocustom components:

IrDA Decoder (Figure 8 above):This block decodes infrared signals encoded using the RC5 protocol. AnRC5 data packet normally has 14 bits, which are sent in the Manchesterencoded format (Figure 9 ).

Figure 9: Manchester encoded remote output

TheBit Extractor block shown in Figure 8 recovers the bit and the clockfrom the incoming signal from the TSOP IrDA receiver in the followingmanner: The first XOR gate recovers the buried clock from the signal.This signal triggers the PWM component with a period that is ¾ of theserial clock. When the PWM reaches the terminal count it triggers thesecond DFF to sample the inverted signal. This inverted DFF outputsignal is inverted once again before being transferred to the shiftregister. A Lookup Table (LUT) is used to count the number of bitsreceived, and once the 14th bit is received, an interrupt is triggered.In this interrupt, the CPU reads the received data stored in the shiftregister.

Hex keypad: A Hex Keypad (Figure 10 )is a 16-button input divided into four columns and four rows to give (4x 4 =) 16 unique keys. In the given component, one of the column pinsis driven low and the rows are read.

Figure 10: Hex keypad decoder circuit diagram

Ifa key press is not detected, then the next column pin is driven low andthe previous pin is driven high. A key press is detected when a row pingoes low when the corresponding column pin is pulled low. Key pressdetection makes the ‘valid’ line go high. This valid terminal is used togenerate an interrupt. Inside this interrupt, the CPU will read the‘Key Reg’ register to get information about the pressed key.

Rahul Raj Sharma is an Applications Engineer at Cypress Semiconductors on USB devices.He has worked on PSoC applications and loves doing analog and mixedsignal designs. He can be reached at .

Tushar Rastogi is an Applications Engineer at Cypress Semiconductors and has worked onPSoC based applications since 2012. His responsibilities include PSoCfirmware programming, application development, technical support tocustomers with programming, boundary scan related issues, and technicalwriting. He can be reached at .

6 thoughts on “Home automation system design: the basics

  1. “Home Automation saves energy? I have shortly visited a highly automated sample apartment in a research institute. And I wonder how this kind of home automation might ever save energy with all these computers, sensors, touch panels, and actuators which con

    Log in to Reply
  2. “Home automation could help user optimize the energy usage, like turn off device when you are not around. nnI think there is a more important aspect of home automation, that is create a comfort environment for people. Flipping light switch, clicking remo

    Log in to Reply
  3. “Increasing efficiency does not reduce energy consumption – if anything it increases it.nnWith the ultimate home automation system I can use my phone to turn on the heat (or AC) while I'm travelling. With a normal system I'd have to wait until I was home

    Log in to Reply
  4. “i remember reading this about lighting, increased efficiency over time has led to the skyrocketing use of ever more lighting. governments efforts for ever greater efficiency, therefore, seem to backfire…”

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.