methodology
DESCRIPTION
methTRANSCRIPT
KENYATTA UNIVERSITY
SCHOOL OF ENGINEERING AND TECHNOLOGY
DEPARTMENT: ELECTRICAL AND ELECTRONICS ENGINEERING
AUTOMATED LIGHT CONTROL SYSTEM
NAME REG NO
MOSES WEKESA MTENDE J174/5620/2011
ENOCK MABONGA WABULE J174/4113/2011
ROSE MUKHWANA WAWIRE J174/1150/2011
MOSOBO DANIEL NGEYWO J174/4259/2011
UNIT NAME: PROJECT 1
UNIT CODE: EEE 408
LECTURER: DR. JUNE MADETE
DATE: 21ST APRIL, 2015
1
ABSTRACT
This study is about creating a web based light control system which further will be controlled by
android phone. The purpose of creating this system is to enhance proper use of light in houses,
homes, offices, industries and factories. One will be able to check whether the lights are on or off
using the phone and decide to switch off or on regardless of where one is. This will help in
cutting down of the unnecessary electricity cost and in so doing it will factor in cutting down the
cost of living. The button on the android phone will be able to control a web server which will be
able to communicate with the Socket directly using the Heyu software. The proposed system
aims to make all these operations more effective and the tasks to be more efficient.
Chapter one gives a brief description of the project including the problem statement, the
background study, scope, justification and limitation. Chapter two gives the literature review of
the system and chapter three covers the methodology used, tools for collecting, analyzing and
implementing the data.
2
ContentsCHAPTER ONE..........................................................................................................................................6
1.1 Project Brief......................................................................................................................................6
1.2 Background of study..........................................................................................................................7
1.3 Statement of the problem...................................................................................................................8
1.4 Objectives of the study......................................................................................................................9
1.5 Scope and limitations of the study.....................................................................................................9
1.5.1 Scope..........................................................................................................................................9
1.5.2 Limitations..................................................................................................................................9
1.6 Justification.....................................................................................................................................10
CHAPTER TWO.......................................................................................................................................11
2.0 Literature Review and Conceptual Frame Work..............................................................................11
CHAPTER 3..............................................................................................................................................20
METHODOLOGY................................................................................................................................20
3.1 SSADM methodology.....................................................................................................................20
3.2. Reasons for using SSADM.............................................................................................................21
3.3 Techniques used to collect facts and data........................................................................................21
Observation..............................................................................................................................21
Interviews..........................................................................................................................................22
WATER AND LIGHT CONTROL SYSTEM INTERVIEW GUIDE..............................................22
CHAPTER 4..............................................................................................................................................24
Data Analysis Methods..............................................................................................................................24
GEDA AND SIMULIDE simulations.................................................................................................24
Tools to Implement and Test the system............................................................................................24
4.1 Software tools.............................................................................................................................24
4.2 Hardware tools.................................................................................................................................24
CHAPTER 5..............................................................................................................................................26
SYSTEM DESIGN................................................................................................................................26
5.2 Light control apparatus....................................................................................................................27
5.3 User Interface Web Design..............................................................................................................28
3
5.31 Registration Form......................................................................................................................28
5.4 Automated Mobile Control..............................................................................................................31
5.42 Light and water tank inlet are off...............................................................................................32
Conclusions and Recommendation............................................................................................................33
Bibliography..............................................................................................................................................34
Appendices................................................................................................................................................36
Appendix A: User Manual.....................................................................................................................36
Requirements.........................................................................................................................................36
Appendix B: Sample code.....................................................................................................................36
Appendix C: Gantt chart........................................................................................................................39
3.7 Time schedule: Gantt chart..............................................................................................................40
3.8 Proposed System Budget.................................................................................................................41
4
DECLARATION
Student Declaration
This report is our original work and has not been presented for award in any other University.
Moses Mtende: Signature___________________ Date______________________
Enock Wabule: Signature___________________ Date______________________
Rose Wawire: Signature___________________ Date______________________
Mosobo Daniel: Signature___________________ Date______________________
Supervisor Declaration
This report has been submitted for review with my approval as university supervisor.
Signature____________________ Date___________________________
Dr. June Madete
Department of Electrical and Electronics.
5
CHAPTER ONE
1.1 Project BriefThis project involves dealing with the design of a control system for control of water spillage and
lighting usage. There are various control system available for reading the water rate usage and
the power consumed by the companies that provide the services and they don’t package their
products with the control system for their clients. For instance there is a lot of water wastage due
to spillage. This occurs when there is shortage of water and you don’t know whether your water
tap is off. When water is back for instance at night and the tap is far there will be lots of water
wastage.
Another instance is the lighting system in various homes, hotels and factory. The lighting goes
on even when not in use and even during the day unless it is switched off manually. In case it is
not switched off it add unnecessary cost to the bills.
This control system will cut down the cost on water and electricity bills due to unnecessary cost
added due to water spillage and lighting not switched off. This controlled system will benefit all
people connected to the grid and in water supply areas. It will also benefit most factories, hotels,
homes.
The project will performance well because most people will have not to worry about how water
tap will be closed in case there is spillage and also the lighting will automatically turn off in case
no person is using it and during the day. The system should be able to detect the presence of the
person in the room and automatically switches off when no one is inside the room.
6
The control system project will be implemented using the available technology of control
system, microprocessor systems and the micro-controllers for instance testing will be done using
the arduino controller board.
The project will be implemented using the little available resources and capital for the micro-
controller systems. This little cost involved in implementing it will see reduction in the cost of
living by cutting down on the bills and when fully implemented it will be able to inject taxes into
the economy therefore contributing to the GDP of the country.
We are going to selective use of available technology and resources to implement the system.
There are no such systems available for our people and this is the main reason why we came up
with this creative idea.
The potential of our project for commercialization is very high because once implemented it will
directly to adopted by many factories, homes, offices, hotels e.t.c
1.2 Background of studyIn every economic environment, cutting down on expenditure has become the
outstanding strategy in ensuring the pragma growth. This goes alongside application of systems
that limit on the possible wastage of the accessible resources. However, it is worth noting that the
updated control systems go alongside the technological advancements aimed at satisfying the
ever dynamic demand characterized by human desire. Technology avails the pragmatic platform
where innovation and invention found the application ground in implementing new techniques,
which targets at improving the proficiency and efficiency of the functionality of a given system.
Water lighting control system is a new technology aimed at substantially cutting down on
unnecessary expenses encountered in leaving running taps and lights on when not in use. The
7
technique narrows down to application of relevant technology, which goes alongside the most
updated control systems, utilization of sensors, the wide use of microcontrollers as well as
making use of automation technique. The literature review, however, concentrates on the already
discovered ideas, which are relevant to the focal development of the water lighting control
system, as well as sampled cases where application of related systems has led to a substantial
reduction of costs to be met on monthly basis.
1.3 Statement of the problemControlling of water spillage and lighting usage is so crucial in helping the community cut down
the cost of living by automatically avoiding the added cost to their water and electricity bills due
to water spillage and lighting of bulbs when not needed during the day in case they are not
manually switched off.
The companies that offer the services never include these automated control system with their
package hence the people continue to suffer as they strive to meet their other needs.
The manual way of switching off the electrical sockets is also dangerous especially in rural areas
where people are not well educated on handling the electrical apparatus and can cause electrical
shock in case the socket is handled with watery hand.
The proposed control system aims at solving these challenges for the people as they will never
get worried about water spillage which is not only a wastage of resources but also a source of
soil pollution due to erosion. People will also be assured of automatically bulbs switched off
when they are not in use especially during the day when no one is around.
8
1.4 Objectives of the studyThe following are the objectives of this project:
I. To develop a system that;
Controls water spillage and lighting misuse
Cuts down the cost of living that rises due to water spillage and lighting misuse.
Facilitates home automation.
II. To implement the system
III. To validate the system
III. To apply the chosen methodology in the development of the system.
1.5 Scope and limitations of the study
1.5.1 ScopeWater and lighting control system manages home automation of controlling water spillage and
misuse of lighting. The system will not be able to detect water spillage and automatically switch
off the water tap to prevent further spillage but will also be able to detect the absence of persons
in the house or office and automatically switch off the bulbs.
1.5.2 LimitationsHowever The Student Counseling System has the following limitations;
Detection of water spillage and differentiating it from the normal water fetching is a bit
difficult. This will allow a little spillage before detection and correction.
9
Detection of absence of persons in a house due analyzing of temperature changes can be
confused by the weather conditions.
1.6 JustificationThe increase in the cost of living that faces everyone calls for the availability of an automated
system that will enhance cutting down the cost of living but ensuring no more payment of
unnecessary bills which can be avoided.
Individuals, Companies and institutions will benefit from the proposed system because they will
not have to worry anymore about the extra costs incurred due to water and lighting wastage.
10
CHAPTER TWO
2.0 Literature Review and Conceptual Frame WorkTechnology proves to be a reliable source of invention and innovation especially when it comes
to development of the IT products and automized systems. Cawson et al (1995) is of the opinion
that lands on technology as the facilitator of the innovation process aimed at shaping things for
consumers. The innovation process narrows down to the way new IT products suppliers
incorporate the knowledge of consumers in designing the appropriate products and systems.
This means that the consumer and consumer market analysis is significant especially when it
comes to making decision on the ultimate design before coming up with the final product or
system that will realistically win the market. Currently, the IT producers are strongly compelled
to design products and systems that are automated such that the manual operation costs can
significantly be reduced. Relevant case studies and reliable documented researches provide the
new demand, which revolves around home automation, electronic messaging as well as
interactive media. In their research, Cawson and his colleagues deduced a trend of demand that is
almost uncertain. They realized that the prior demand involved such products like automatic cash
dispensers, microwave ovens and CD players, which have now lost their value in the market.
Apparently, home automation captures the attention of the designers because the aspect touches a
wider market, given the fact it primarily involves the control of the house resources, which forms
the immediate interactive environment of consumers. Home automation is significantly a
network dependent that is present and operational within the house and at the same time, serves
as the focal point for the communication potential with the remote locations. Cawson and his
colleagues deduced the significance of the technology of intelligent wiring in developing smart
house. The technology entails making use of the mains as a carrier for signaling, or making
11
relevant use of the D2B circuit in facilitating home automation. The entire need to standardize
network places provides great opportunities for suppliers, who can offer several products with
gain added value. The products should therefore enhance utility from their connection to other
products through available home network. In most cases, the utility of the products is not
governed by the number of consumers purchasing the home networks. Instead, the utility is
governed by the extent of expense reduction at home. Other related cases entail the consumers
move towards the distributed intelligence in home automation systems, which involve building
the network from bottom up, compared to the installation of the network as a whole. Postulation
of the consumer market speculation reveal a heavy consumption of the home automation systems
due to the fact that the systems cost less compared to the subsequent expenses met at home.
The ultimate discussion of marketability and credit worthiness of the home automation systems
should go alongside the design process and the application of other elated principles.
Development of the home automation systems can be facilitated by the wide use of wireless
sensor network that essentially reduces the number of sensors used in automizing the system
(Reza Mohamaddoust, 2011). Mohamaddoust and his colleagues revealed the significance of
directing greater efforts towards optimizing electrical energy utilization through the relevant use
of the wireless sensor networks. Application of such sensors revolves around energy
conservation applications such as light control. Outstanding factors on which the sensors rely on
entails the daylight intensity that is essentially measured by the light-sensitive sensors. The
authors intended to make use of light adjustments in minimizing the total cost of the energy
supplied.
Mohamaddoust and his colleagues proposed the absolute use of lighting control system known as
the lighting automatic control system (LACS). The LACS system architecture is composed of
12
both the management system and the zones of operation. Each zone has a local control unit
(LCU) having an activity selector, lighting units and sensors. Every sensor in each zone monitors
the illumination over a certain area referred to as the work plane. The essential components of
LACS entail the management system, which is software installed in a personal computer. It
controls the functional components of the system, constructs the reports of the system and further
records the usage logs. Secondly, the LCU module controls the information flow between the
lighting units, sensors and activity selector within the entire LAC system. The modules further
receives instructions from and reports to the established management system.
Additionally, the facilitation of the decision process for setting the local light intensity is
normally validated by the LCU. The activity selector, on the other hand, serves as a physical user
interface, which facilitates communications with the LAC system through the validated selection
of the requirements. The sensors play a primary role of measuring the light intensity while the
illumination filed is significantly a set of lights that illuminate each work plane. The wireless
sensor network management system can be organized in distributed or centralized architectures.
In centralized management network, a single manager is required to collect information from all
the agents and plays a core role of controlling the network. A distributed management network
involves several mangers. Every manager is absolutely responsible for a sub network and
communicates with other managers. Below is a sampled scheme showing both the centralized
and distributed lighting automatic control system (LACS) architecture.
13
Figure 1. LAC architecture
Figure 2. LAC SYSTEM
The system performance begins with choosing an activity from the activity selector. The
activated illuminance on the relevant work plane is sent to the LCU, courtesy of the work plane’s
sensor. The LCU further compares the reported illuminance with the standardized illuminance of
14
the selected activity. In case of insufficient light, a decision process is run in the LCU activity.
The output of the decision process is the dimmer level that is significantly sent by the LCU to the
light ballast. Setting the appropriate amount of the field light dims triggers the provision of the
selected activity.
The efficiency of the sensors and their wide use can be achieved by an extended use of the
microcontrollers. Mustafa et al (2010) developed an embedded system for energy saving of street
lights. The central use of the microcontrollers plays a focal role of automizing the functionality
of the street light control system. Incorporation of the microcontrollers in designing the new
streetlight system aims at cutting down on the huge consumption of electricity. The authors saw
the need to eliminate manual control of the streetlight management system and embraced the
efficiency of remote management solutions in controlling the street lighting. They further opted
for various control strategies such as the implementation of the CPLD based solar power saving
system as well as the automatic traffic controller. Other control strategies that widened the gap
choice included the automatic street light intensity control, the safety module embedded system,
automatic lighting system with a wireless sensor network and the intelligent street lighting
control system.
Out of a wide bracket of selection, the authors opted for two types of sensors in developing their
project. These included the light sensor and the photoelectric sensor. The light sensor facilitates a
reliable detection of the darkness that further activates the ON/OFF switch. On the other hand,
the photoelectric sensor detects the movement thereby activating the streetlights. The light
dependent resistor (LDR) varies according to the amount of light falling on it thereby giving
inductions for whether it is a day-night time. The aforementioned photoelectric sensors are
conspicuously placed on the side of the road and they are controlled by the microcontroller of the
15
type PIC16f877A. The photoelectric will essentially be activated during the night. In case any
object crosses the present photoelectric beam, a certain light will automatically be ON. It must be
noted the significant elements in developing the project include the LDR, microcontroller and
photoelectric sensor. The system operation entails making use of the LDR, which involves the
OFF state when light is available and ON state with the absence of light. When light falls on the
LDR, it sends a command to the microcontroller which will eventually instruct it to be in the
OFF state. The photoelectric sensor will be used in turning ON or OFF depending on the
presence or absence of the object. Making use of relay makes it easier in facilitating the effective
ON or OFF switching action. The following diagrams show the schematic flow of the operations
as well as the streetlight circuit.
Figure 3. Photoelectric sensor and LDR
16
Figure 4. Schematic circuit for street lighting
The subsequent use of the microcontrollers is further seen in the development of the
microcontroller based automatic water level control system, a project developed by Ejiofor and
Oladipo (2013), based on the principle of inter-operability. In their project, the two considered
the joint operation of the sensors, microcontroller, comparator circuit, display unit and the pump.
Copper conductors are therefore used as water level sensors given the fact that water poses the
electrical conductivity property. When the water touches the copper sensor, voltage is transferred
to the comparator circuit for further processing. The comparator may either give a LOW or a
HIGH depending on the level of water in the tank. This is further fed in the microcontroller,
which further uses the information in controlling the water pump. The LCD screen serves as an
output unit while the functionality of the entire system is controlled by the programmed
assembly language in the Atmel 89C52 microcontroller. Further operations were based on the
17
control system and LEED (Alissa Cooperman, Dieckmann, Member ASHRAE &Broderick,
2009). The flow charts below give the clear outline of the system used in this case.
Figure 5. Automatic water monitoring flow chart
Figure 6: Operation of the system
18
The development of any project should be accompanied by its significance or the major role
played by the project. After a conceptual review of the probable design as revealed in the
discussion above, it is also important to recognize the value of the wireless lighting control as
well as the need to save energy as it will be seen in some quoted cases revolving around the
United States environs (Daintree Networks Inc., 2010). The lighting control system functionality
include the on/off and dimming controls, occupancy sensing, photo sensing, scheduling the turns
on and off, centralizing the control system interface, establishing a communication system
between the lighting equipment and the control system as well as settling on an outstanding
method of displaying, measuring and responding to lighting energy usage. An argument on
energy monitoring settles on the idea of a better data equals a better saving and this begins with
advanced water lighting control systems. A reduction on the costs goes alongside the
implementation of the wireless systems that significantly lead to a reduction of labor and wiring
requirements.
Rao & Seitle (2010) establish the computer application in the accessible water distribution
system control. The reliability and the economic operation have eventually resulted in the wide
use of digital computers for the ultimate supervisory control as well as data acquisition. The
importance of software requirements can be realized in computer control. Subsequently,
residential lighting and water control has led to a pragmatic reduction of energy consumption by
15% in United States. The Consortium for Energy Efficiency, CEE, initiates the energy savings
potential through the ultimate usage of the automized and control system. It is evident that water
lighting control system has a wide application with a primary goal of reducing the house
expenses. Extended application considers commercial economic satisfaction whereby the control
system is incorporated in saving the energy and avoiding water losses.
19
CHAPTER 3
METHODOLOGYThere are several methodologies that can be used to design and develop a system for example
scram, prototyping and Structured Systems Analysis and Design
Prototyping methodology
In prototyping methodology, analysis, design and implementation phases are performed
concurrently, and all the three phases are repeatedly in a cycle until the system is completed. In
this methodology, the basics of analysis and design are performed and work immediately starts
on a system prototype. The prototype is a quick and dirty program that provides minimal amount
of features. The first prototype is the first that the user will use, and provide comments, which
are often used to reanalyze, redesign and reemployment. A second prototype provides a few
more features. Then the cycle continues till the system is accepted. The major disadvantages of
prototyping are that the fast paced system releases challenge to careful methodological analysis,
which makes the initial designs very poor
3.1 SSADM methodology This method is based on iterative and incremental software development where requirements
and solutions evolve through collaboration between collaboration between self organized cross
functional teams. It allows project participants to adjust themselves and their activities in
response to situations that arise during the project development process, requirements are
implemented into system functionalities as soon as they are identified, the necessary tests carried
out and this is repeated until the whole system is developed.
20
The development of the proposed system will be in Structured Systems Analysis and
Development Methodology (SSADM).
3.2. Reasons for using SSADM It ensures separation of logical and physical aspects. Therefore the new design is not
affected by existing methods
It uses well defined techniques and documentation.
It takes into concern user involvement.
Every stage is terminated by a quality review which is staffed by people with mixed
experience, some of whom are not directly connected with the project.
3.3 Techniques used to collect facts and dataThe following are the techniques used to gather data for the proposed system
Observation
From our observations as an individual group, we found out that the electricity and water bills in
households and institutions in Kenya are high and unaccounted for in most cases. For instance,
in the case of water, we found out that water spillage was due to ignorance of the consumers and
unavoidable cases like children interfering with the water discharge .Moreover, energy is also
wasted by the lights and other appliances being left on while not in use.Our major observation
was inside the university where the students intentionally leave the lights on during daytime
when not really needed.
21
InterviewsInterviews were conducted to some students within and outside Kenyatta university, parents
living within the area. The aim of the interview was to establish the major challenges the above
named face in terms of the electricity and water bills in their respective residing areas and
homes. Most of them expressed their desire for to acquire a system that could help them to cut
down on the costs given the hard economic times we are living in.
WATER AND LIGHT CONTROL SYSTEM INTERVIEW GUIDE1. How much is your electricity and water bills monthly?
…………………………………………………………………………………………………
….
2. Do u think that it is what u really consume or there is some amount that you can’t account
for?
………………………………………………………………………………………………
…………………………………………..
3. What do you propose concerning your bills?
………………………………………………………………………………………………
……………………………………………
4. If a system that controls water spillage and electricity wastage was to be proposed, would
u endorse it and why?
………………………………………………………………………………………………
…..
Questionnaire
22
A questionnaire was developed for students, and residents outside the campus for them to answer
concerning their electricity and water consumption and how it can be improved to cut down on
their monthly costs.
23
CHAPTER 4
Data Analysis MethodsGEDA AND SIMULIDE simulations
This will involve the following:
i) Simulation of level of water using HEX display
ii) IC 74148 control for water level control system
Tools to Implement and Test the system
4.1 Software tools
Ruby on Rails 3.0 or higher
The Eclipse IDE7
The Android SDK 1.5 or higher
The Android Development Tools (ADK) Plugin for Eclipse
Heyu
4.2 Hardware tools1. X10 CM11A computer interface
2. X10 PLW01 standard toggle wall switch and Serial to USB interface cable
24
4. An Android OS phone(will be using android emulator)
5. A computer (not shown), preferably Linux or Mac-based, with Ruby 1.8.7 or higher installed
6.LM 555 timer, Relay and DC motor.
25
CHAPTER 5
SYSTEM DESIGN5.1 Water control circuit design
Figure 7: Water control circuit design
26
5.2 Light control apparatus
Figure 8: Light control System apparatus
27
5.3 User Interface Web Design
5.31 Registration Form
Figure 9: User registration
5.32 User Login
28
Figure 10: user login
29
30
5.4 Automated Mobile Control5.41 Light and water tank inlet on
Fig 11: Mobile control
31
5.42 Light and water tank inlet are off
Figure 12: mobile app control
32
Conclusions and RecommendationLight and water control system is an essential to all people who pay electricity and water bills..
Its services must be adopted to cut down on the cost of the bills hence the living cost also goes
down. Therefore, the proposed system seeks to ensure that persons connected to the grid get the
best in terms of efficiency in usability and adaptability. The literature review has touched much
on automation of systems that indicates the wide application of microcontrollers and the local
control units. Details on the architecture facilitate enough information on how the design of the
project should be achieved. The accompaniment of the ultimate necessity for programming paves
way for the combination of both the water and light control accommodated in the same local
control unit. The LAC system opens for the ultimate idea of the entire design that is significantly
covered under methodology. Under methodology, the SSDAM paradigm explicitly gives the
outline followed that will be used in reaching the final design. The collection methods include
observation, interviews and questionnaires. Utilization of simulation tools facilitated the
pragmatic analysis of the collected data. Finally, the design which is web-based and android
automated control shows the materialized idea that will avail the absolute prototype. Considering
knowledge gain in control and automation, the project is believed to serve other functions apart
from automated water and lighting control.
33
BibliographyCawson, A., Haddon, L & Miles, I. (1995). Delivering information technology into home. The
shape of things to consume, 1(4), pg 227-313.
Cooperman, A., Dieckmann, Member ASHRAE & Broderick, J. (2009). Control Systems &
LEED: Emerging Technologies. ASHRAE journals, pg 96-99.
Daintree Networks Inc. (2010). The value of wireless lighting control. White paper.
Retrieved from: http//www.daintree.com
Ejiofor, V. E & Oladipo, O. F. (2013). Microcontroller based Automatic Water level Control
System. International Journal of Innovative Research in Computer and Communication
Engineering, 1(6), pg 1390-1396.
Mohamaddoust, R., Hagighat, T. A., Mohamad, J. M. S. & Capanni, N. (2011). A Novel Design
of an Automatic Lighting Control System for a Wireless Sensor Network with Increased Sensor
Lifetime and Reduced Sensor Numbers. Sensors, 11, pg 8933-8952.
Mustafa, S., Abdalhalim, F., Ahamed, S. & Abdalroof, A. (2010). Automatic Street Light
Control System Using Microcontroller. Mathematical Methods and Optimization Techniques in
Engineering, pg 92-96.
Andersson B., Baruah S. and Jonsson J., Static-priority scheduling on multiprocessors,
inProceedings of IEEE Real-Time Systems Symposium, London, pp. 193–202, December 2001.
Aras C., Kurose J.F., Reeves D.S. and Schulzrinne H., Real-time communication in pack
34
Rao, H. S & Seitle, R. A. (2010). Computer Applications in Urban Water Distribution System
Control. Journal of Dynamic Systems, measurement and control, 97(2), pg. 117-125.
35
Appendices
Appendix A: User Manual
Requirements 1. X10 CM11A computer interface
2. X10 PLW01 standard toggle wall switch
3. Serial to USB interface cable
4. An Android OS phone or tablet device
5. A computer (not shown), preferably Linux or Mac-based, with Ruby 1.9.3 and above
Additionally, you will need the following software:
• Heyu >=2.9.3
• Ruby on Rails >=3.0
• The Eclipse IDE7
• The Android SDK 1.5 or higher.
• The Android Studio.
Appendix B: Sample code
package com.example.root.LWCS;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
36
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.net.URL;
import java.io.InputStream;
public class MainActivity extends Activity {
private ToggleButton toggleBtn1, toggleBtn2;
private Button btResult;
final String my_server_ip_address_and_port_number =
"127.0.0.1:3030";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnToggleButton();
}
private void addListenerOnToggleButton() {
37
toggleBtn1 = (ToggleButton) findViewById
(R.id.toggleButton1);
toggleBtn2 = (ToggleButton) findViewById
(R.id.toggleButton2);
btResult = (Button) findViewById(R.id.button1);
btResult.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (toggleBtn1.isChecked()) {
try {
final InputStream is = new URL("http://"+
my_server_ip_address_and_port_number
+"/command/on").openStream();
}
catch (Exception e) {
}
} else {
try {
final InputStream is = new URL("http://"+
my_server_ip_address_and_port_number
+"/command/off").openStream();
}
38
catch (Exception e) {
}
}
StringBuffer result = new StringBuffer();
result.append("LIGHTS ARE NOW- .").append
(toggleBtn1.getText());
result.append("\n WATER TANK INLET- " ).append
(toggleBtn2.getText());
Toast.makeText(MainActivity.this, result.toString(),
Toast.LENGTH_SHORT).show() } });
}
}
Appendix C: Gantt chart
39
3.7 Time schedule: Gantt chart
Figure 12: Gantt chart
40
Appendix D: Budget
3.8 Proposed System Budget
ITEM TOTAL COST IN KSHS
1 Laptop Computer 30000
2 Internet 12500
3 X10 CM11A computer interface 1000
4 An Android OS phone 5000
5 X10 PLW01 standard toggle wall
switch
800
6 Serial to USB interface cable 500
7 Flash disk 800
Total 50600
Figure 13: Budget
41
42