• Ei tuloksia

3.1. Wireless Sensor Node

A wireless sensor node is an electronic device that consists of one or more sensors, a transceiver, and a battery. The sensors are used for collecting data from the surrounding environment depending on the sensor type. Some examples would be temperature, humidity, acceleration, orientation, light and proximity sensors. The battery powered transceiver then passes the measured information to another wireless sensor node that is connected to a central computer. Wireless sensor nodes are usually referred as 'nodes'.

A wireless sensor network (WSN) is a group of nodes organized as a cooperative network where nodes can talk and listen to each other. This communication organization can be used to circulate commands inside the network. For instance, a node which is located far away can receive a command from another node to measure the temperature, and send that measurement to a central computer as shown in Figure 4.

Figure 4. Wireless sensor network architecture example (Vieira, Cunha & Silva 2006).

These networks were firstly developed for military applications but today the applications are extended to industry as well as for environment monitoring (Dargie &

Poellabauer 2010: 8). One important usage of wireless sensor networks is the natural

disaster monitoring. In case of a forest fire, the wireless sensor node that detects a fire and smoke, can send an alarm to the fire departments in advance.

3.2. Home Automation

Home automation is one of the fastest growing industries capable of altering the way that the human beings live. Some of those home automation systems target the needs for seeking more comfortable, sophisticated and luxury products. In addition it provides advantages for disabled or old people who may have special needs.

The category of the home automation applications is still evolving and thus there are multiple standards incompatible with each other. In order to get these systems work together may require deeper knowledge today, but once everything is standardized the setup times, costs and maintenance efforts are expected to reduce to much smaller amounts compared to today's systems. (Derene 2009.)

Home automation allows remote and automatic control of wide range of devices. These systems can also send alert messages to the mobile devices whenever there is something that needs attention at home such as water leaks of thievery. It is also capable of providing a control screen to the user that allows taking actions over the secure communication protocols. The application level can also control how a device should react and when. The users may be able to set schedules to specific events like watering the plants. The main advantages of home automation can be listed as convenience, safety and security, energy savings and entertainment.

Providing a remote control system and automating the home appliances have advantages in terms of time and convenience. The user can dim the lights inside the house while still sitting on the couch (Rand 2013), adjust the temperature from the bed, control the sound level of the audio devices and can set schedules for bathroom heating.

The safety advantages of these systems are also great. For example a water sensor can detect a possible water leak as soon as something goes wrong and can prevent costly damage repairs. A motion sensor can be connected to a lighting system so that the lights may go on immediately in case there is a movement detected within the house. In this situation it is also possible to alert the police, if desired.

The ability to set the personal preferences, using voice recognition to control the entertainment systems at home enhances the entertainment experience of the residents.

From the previous examples it can be seen that home automation technologies offer many solutions for controlled systems, such as; lighting, cameras, security systems and access control, home theater and entertainment, phone systems, thermostats, irrigation and cable and structured wiring (Harper 2003). This work provides a way to control the lighting, heating, and irrigation systems.

Lighting control:

This application allows the user to control the home lighting over the network independently from wherever he or she is located inside the house. The control is done with speech recognition by using external microphones located within the house. In this work, the lighting is represented by a light bulb, and the microphone is represented by an external microphone connected to a PC.

Heating:

A heating system inside the house can be controlled by a motor which is capable of receiving commands over the wireless sensor network. The wireless sensor device eZ430-RF2500 of the Texas Instruments already has an in-built temperature sensor on its microcontroller MSP430F2274. This sensor can be used to apply a closed loop heating control algorithm. Such an application has also a potential to be used for greenhouse and animal shelter heating systems in addition to automated homes.

Irrigation:

Home automation is not constrained to indoors. It can also be used in gardens for a more efficient plant life. The user may program a schedule and the rest can be handled by the irrigation system. Adding a rain sensor would provide a way to halt the system in case the weather is rainy. This leads to the advantage that tap water can be saved. In addition to those, irrigation systems can be combined with motion sensors to protect the garden from wild animals.

4. HARDWARE

4.1. System Overview

The home automation system provided in this thesis can be divided into two main parts.

One of those parts is PC controlled and acts as a command center. This part receives the input speech. After the speech command is recognized it forwards a one byte command via USB to the wireless node which is connected the PC. From these, the single byte command will be transmitted to the wireless node belonging to the second part. The other part consists of a wireless sensor device with a battery box that controls various devices and acts as an actuator part.

Figure 5. Command center of the home automation system.

The command center part can be seen in Figure 5. Here there is a PC, an external microphone, and a wireless node. The microphone and the wireless sensor node are both

connected to the PC via USB interfaces. All the home automation systems are controlled over this PC by the software applications installed on it. The devices and the software applications used in this system are shortly explained further in this section regarding to their functionalities.

Logitech USB Desktop Microphone is used for passing the voice commands to the PC in digital format. The pure audio signal that is captured with the microphone is converted to digital format inside this microphone and the data is sent to the PC over the USB interface. On the PC, there is a speech recognition application which directly receives the data. The speech recognition application used in this work is 'Sphinx4'. This software is entirely written in Java and applies 'Hidden Markov Model' concept for converting the speech to a computer understandable form (Derbali, Jarrah & Wahid 2012).

Sphinx4 project is an open source software project developed by Carnegie Mellon University. This software and the speech recognition process is explained in detail in section 5.1 of this thesis. In the system shown in Figure 5, the voice command that arrives to the PC are best matched regarding to the words contained inside the word pool of the dictionary defined in the Java application. After the matching process, the estimated result is converted to a text. The steps after this point become easier since the command in a text format will only be processed. In this thesis it was decided to just send one character that represents the command ID to the wireless sensor node over the USB. The UART receiver of the MSP430F2274 immediately stores this value inside the memory.

In this thesis, the eZ430-RF2500T target board of the Texas Instruments is used as a wireless sensor node. One of those nodes is connected to PC via USB debugging interface and it is called the access point node. The function of this access point node is to forward the incoming PC commands to the other nodes over the RF connection. The node on the receiving side is called end device. Texas Instrument's Code Composer Studio is used as a development environment for embedded application development.

At the same time, it is used for downloading and debugging the applications for both

nodes.

The information coming to the access point is immediately forwarded to the RF chip from the SPI interface. Detailed information about the SPI is provided in section 2.1 of the thesis. According to the settings in the software, the bytes received on the UART are sent via the radio to the end device. This explains how the command center part of the home automation system in this thesis works.

The actuator part of the system takes physical action based on the transmitted information over the wireless network. As illustrated in Figure 6, this part is generally a wireless sensor node connected to a servo motor, a lighting control board with a light bulb, and a battery for power requirements.

Figure 6. Actuator part of the home automation system.

As soon as the wireless data is received on the radio transceiver of the end device, it is directed to the MSP430F2274 microcontroller over the SPI interface. At this point the microcontroller checks if the received information is a valid command and if it is correct, it will take an action defined in the software.

The servo motor used in this work is Hitec HS-422 - Standard Deluxe Servo Motor.

Combining this motor with wireless devices, a heating system or an irrigation system of a house can be controlled in a wireless manner. When the correct byte arrives to the microcontroller, the timer counter value is updated and the duty cycle of the servo motor is changed and the motor turns to the desired direction.

The lighting control board consists of a LTV4N35 optocoupler, a GS-SH-205T relay and a LED. The end device is attached to this board it has the capability to turn the light on or off with the wireless commands coming from the access point. In fact, the relay can switch much higher voltages and current as required from a LED. This means that a LED can easily be replaced by a home light. This summarizes the second part of the automation system.

It is now possible to describe how an example application implemented in this thesis works in reality. In order to test the functionality of the whole system several tests have been done. One of the tests has been done so that the user speaks to an external microphone saying "Motor Left". Then the speech recognition program processes the word as described further in section 5.1. The PC then sends the command byte '0x47' to the wireless node connected with the PC. From these the command will be sent over radio to the wireless node that controls several devices such as motor and light. After the reception the command is evaluated with a switch case statement which changes the duty cycle of the pulse width modulation (PWM) signal. Finally the motor turns to left independently from its previous position. In case this motor would be connected to a valve, it would switch the irrigation system on and off.

4.2. eZ430-RF2500 Wireless Development Tool

The eZ430-RF2500 development tool that is produced by Texas Instruments was used for the wireless communication between the command center part and the actuator part. The development tool includes two eZ430-RF2500T target boards, one eZ430-RF USB debugging interface and one AAA battery pack with expansion board, as shown in the Figure 7. The eZ430-RF2500 also features 21 available development pins, two general purpose digital input/output (GPIO) pins connected to green and red LEDs for visual feedback and an interruptible push button for user feedback.

Figure 7. eZ430-RF2500 Wireless Development Tool (Texas Instruments Incorporated 2009).

The target board which was connected to the PC with the USB debugging interface is named as access point. It sends and receives data from PC using MSP430 application

UART as an out-of-the box wireless system. The other target board is named end device and it is connected with the battery board. End device is also connected with the motor and light control board.

Each target board has its own MSP430F2274 microcontroller and CC2500 2.4-GHz wireless transceiver. Also, most of MSP430F2274's pins can be accessible with pinouts on the boards. The functionalities of those pins are given in appendix 1.

MSP430F2274 microcontroller has been developed for ultra-low power applications and supports many low power operating modes. These modes allow the microcontroller to activate only the necessary hardware blocks inside it so that it can save power.

Various clock sources can be used for many clocking hardware blocks so that user application can select which one suits his/her requirements the best. A good example applied in this thesis is the PWM usage and the RF communication. Here the clocking system is used so efficiently that the minimum power is used to generate the PWM using the timer. The experimental results about the current consumption are represented further in section 6.1. In the application, the microcontoller is always in sleep mode until an interrupt occurs in the SPI module. When a byte is received on the RF chip, the microcontroller wakes up, processes the command, updates the timer counter and goes back to sleep mode. All these things happen in a very short duration to maximize the battery life. While the microcontroller is in sleep mode, PWM is continuously generated to keep the motor position. The possible low power modes and the corresponding clocking information of the microcontroller are represented in the Table 3.

Table 3. Low power modes for MSP430F2274.

Mode CPU and Clocks Status

Active CPU is active, all enabled clocks are active.

LPM0 CPU, MCLK are disabled, SMCLK, ACLK are active.

LPM1 CPU, MCLK are disabled. DCO and DC generator are disabled if the DCO is not used for SMCLK. ACLK is active.

LPM2 CPU, MCLK, SMCLK, DCO are disabled. DC generator remains enabled. ACLK is active.

LPM3 CPU, MCLK, SMCLK, DCO are disabled. DC generator disabled.

ACLK is active.

LPM4 CPU and all clocks disabled.

4.2.1. CC2500

CC2500 is a low power transceiver chip. It means that, the chip acts like both transmitter and receiver with low current consumption. It is a part of the eZ430-RF2500 wireless development kit and communicates with MSP430F2274 chip via SPI interface.

The frequency range is from 2400MHz to 2483.5MHz.

Furthermore, the data rate is configurable between 1.2 and 500kBaud. Thus, the current consumption can be reduced for applications which do not require a high speed transmission by reducing the data rate. In addition, the packet error rate is maximum 1%

when using a baudrate of 2.4 kBaud.

CC2500 supports easy packet handling, data buffering, burst transmission, clear channel assessment, link quality indication, and wake-on-radio. It has 64 byte transmission (Tx) and reception (Rx) first in first out (FIFO). Additional information can be found in

appendix 2.

Figure 8. Block Diagram of CC2500 (Texas Instruments Incorporated 2011).

Figure 8 shows the block diagram for the CC2500. The CC2500 features a low-intermediate frequency (IF) receiver. This received RF signal is then amplified by the low- noise amplifier (LNA). After that, it is down-converted to I and Q components to the intermediate frequency. At IF the I/Q signals are digitized by the ADCs. The automatic gain control (AGC), fine channel filtering, demodulation, bit/packet synchronization are performed on digital form of the signal.

The transmitter of the CC2500 is based on direct synthesis of the RF frequency. A crystal connected to XOSC_Q1 and XOSC_Q2 provides reference frequency for the synthesizer as well as the clocks of the receiver ADCs and the digital parts.

The SPI interface is used for chip's configuration and data buffer access. The CC2500 also includes support for channel configuration, packet handling, and data buffering configurations.

Modulation Formats

CC2500 supports amplitude, frequency and phase shift modulation formats as described in section 2.3. The desired modulation format is set in the MDMCFG2.MOD_FORMAT register.

4.2.2. SPI communication with CC2500

The CC2500 chip is the slave device of the SPI link. The background information about the SPI is given previously in section 2.1. The configurations for the wireless communication are loaded to the chip from the MSP430F2274 so that only one application software is required. For easy usage, Texas Instruments has provided a code library for the developers. This work takes advantage of this library and ready functions inside it. Each of those functions are explained briefly in the Table 4.

Table 4. SPI register functions provided by the CC2500 library.

Functions Descriptions

void TI_CC_SPISetup(void) Configures the assigned interface to function as a SPI port and initializes it.

void TI_CC_SPIWriteReg(char addr, 

char value) Writes "value" to a single configuration register at address "addr".

void TI_CC_SPIWriteBurstReg(char 

addr, char *buffer, char count) Writes values to multiple configuration registers, the first register being at address

"addr".

First data byte is at "buffer", and both addr and buffer are incremented sequentially (within the CC2500 and MSP430F2274, respectively) until "count" writes have been performed.

char TI_CC_SPIReadReg(char addr) Reads a single configuration register at address "addr" and returns the value read.

void TI_CC_SPIReadBurstReg(char 

addr, char *buffer, char count) Reads multiple configuration registers, the first register being at address "addr".

Values read are deposited sequentially starting at address "buffer", until "count"

registers have been read.

char TI_CC_SPIReadStatus(char 

addr) Special read function for reading status registers. Reads status register at register

"addr" and returns the value read.

void TI_CC_SPIStrobe(char strobe) Special write function for writing to command strobe registers. Writes to the strobe at address "addr".

For SPI connection, the RF chip has a clock input (SCLK), data output (SO), chip select (CSn) and data input (SI) pin. The pin connection between the CC2500 and MSP430F2274 is represented in the Figure 9. Also, in appendix 3 there is a schematic design of SPI link between MSP430F2274 and CC2500.

Figure 9. SPI and interrupt pin connections between the CC2500 and the MSP430F2274 (Texas Instruments Incorporated 2011).

In addition to the SPI connection, there are also interrupt pins connected between these two chips. These interrupt pins allow the ultra low power modes to be utilized. As soon as the CC2500 has some data to pass to the microcontroller, it sets an interrupt pin to logic high, so that the MSP430F2274 can enter directly to the interrupt service routine (ISR) while it was asleep.

4.3. Servo Motor Control

Hitec HS-422 - Standard Deluxe Servo Motor has been chosen as a servo motor that represent the heating and irrigation systems' motor. The motor operates with a voltage between 4.8V–6V. In Figure 10 the used servo motor is illustrated. The motor is

Hitec HS-422 - Standard Deluxe Servo Motor has been chosen as a servo motor that represent the heating and irrigation systems' motor. The motor operates with a voltage between 4.8V–6V. In Figure 10 the used servo motor is illustrated. The motor is