Final Report - Winsteon

advertisement
WINSTEON
HOME AUTOMATED WINDOW
Members:
Paul Aldana
Miguel Medina
Taylor Nguyen
Jolan Santiaguel
Date: May 10, 2015
Website:
http://winsteon.weebly.com/
CONTENTS
I.TEAM MEMBERS
Paul Aldana……………………………………………………………
Miguel Medina…………………………………………………………
Taylor Nguyen…………………………………………………………
Jolan Santiaguel………………………………………………………
3
3
3
3
II.INTRODUCTION
Winsteon………………………………….………….…………………
4
III.PROJECT OVERVIEW
Technology Considerations…..……………………………………
Technology Used………..……………………………………………
5
6
IV.EXISTING PRODUCTS
Swabon…………………………………………………………………
Automatic Open/Close Window……………………………………
7
8
V.PROJECT OBECTIVES
Objectives………………………………………………………………
9
VI.SPECIFICATIONS
Specifications…………………………………………………………
10
VII.USER INTERFACE
Winsteon U.I………………………………………….………….……
11
VIII.THEORY
Winsteon Theory………..……………………………………………
12
IX.HARDWARE DESIGN
H-Bridge……………………………………………………………….
Current Sensing…………………...…………………………………
Temp. Sensors..…………………...…………………………………
13
14
15
X.BLOCK DIAGRAM
Winsteon Hardware Block Diagrams…………………………….
16
XI.SCHEMATIC OF HARDWARE DESIGN
Winsteon Full Schematic ………………………………………….
17
XII.HARDWARE TASKLIST
Hardware Task List……………………………………………………
18
1
CONTENTS
XIII.SOFTWARE DESIGN
Overview…………...……………………………………………………
Main Code…………...………………………………………………….
User Input Interrupt…………...………………………………………
Temperature Sensors Interrupt…………...………………………..
23
24
25
25
XIV.SOFTWARE FLOWCHART
Major Software Flowchart……………………………………………
Minor Software Flowcharts ………………………………………….
Minor Software Description………………………………………….
26
27
32
XV.SOFTWARE TASK LIST
Software Task List………………………………….………….……..
34
XVI.GNATT DIAGRAM
Software GNATT…..………………………………………………….
Hardware GNATT…..………………………………………………….
37
38
XVII.COST
Components…………………………………………………………
Total Costs.…………………………………………………………,
Hours…………………….……………………………………………
Production Costs…………………………………………………..
39
49
49
49
XVIII.PROJECT SUCCESS SUMMARY
Capabilities…………………………………………………………..
Critical Specification……………………………………………….
50
51
CONCLUSIONS
Winsteon…….…………………………………………………………
52
APPENDIX
Appendix A……………………………………………………………
Appendix B…………………...……………………………………….
53
54
2
TEAM MEMBERS
WINSTEON MEMBERS
Paul Aldana
Paul Aldana is one of the lead designers and engineers for Winsteon. He is receiving his Bachelor of
Science in Computer Engineering from California State University, Long Beach in December 2015. He
has worked within a variety of hardware and software design environments most notably the Digilent's
Nexys2, ARM LPC2148 and the 8051 microcontroller.
Miguel Medina
Miguel Medina will be receiving his Bachelor of Science in Computer Engineering from California State
University, Long Beach in Spring 2015. His knowledge for hardware design has put him in charge of
making sure all hardware components are fully functional and ready to use alongside Jolan
Santiaguel. This task has been divided equally among the two of them to ensure that the hardware
portion of the project be completed on time. Our goal is to finish the project with a little extra time
left in order to fix any bug that may arise.
Taylor Nguyen
Taylor Nguyen is a student at California State University, Long Beach receiving his Bachelor of Science
in Computer Engineering in May 2015. He tries to pursue a career in software/hardware engineering
position. He tries to specialize in both the hardware and the software design. Taylor has been put in
charge to do the software task for the Winsteon project alongside Paul Aldana.
Jolan Santiaguel
Jolan Santiaguel is one of the lead designers and engineers for Winsteon and is currently pursuing his
Bachelor of Science in Computer Engineering from California State University, Long Beach. Due to his
great knowledge and skills of circuitry design and embedded systems, he has been put in charge of the
hardware design of the current Winsteon project. Along with Miguel Medina, they have been task of
ensuring that the hardware portion of the project is working at all times.
3
INTRODUCTION
WINSTEON
With the use of any smart phone or any other device connected to the web, users can adjust all their
windows at their home. The window would also have other useful functionality such as the ability to
automatically open when it gets too hot or automatically close when the temperature gets too cold.
The user, of course, has the option to turn this option on or off with the use of any smart phone or
device which has a Wi-Fi connection. In doing this project, we would use a small sliding window that
would be integrated in our product. We are implementing a linear actuator that would be used to slide
the window open or close. The motorized linear slide is then connected to a raspberry pi and our own
circuit. A software application website would also be created in order to communicate with the
window which would enable user to check if the window is open or closed and to operate the window
from wherever network connectivity permits.
4
PROJECT OVERVIEW
TECHNOLOGY CONSIDERATIONS
The technology we used would be incorporated to a window that will be able to open and close by
itself based on the user preferences. The operations would depend on various elements surrounding
the window. It will be able to measure the temperature indoors and outdoors and the technology
would make the window open or close based on that. The user would be able to communicate with
the window at home within the web which can be accessed by the phone or computer. The user would
have the control whether they would want the window to open/close automatically or set it in manual
where they can open or close the window within their command. The other feature they would be
able to get is inputting their custom indoor temperature range. The custom input temperature will
take the max and min temperature for indoors, if the temperature goes outside of the range, the
window will open/close.
5
PROJECT OVERVIEW
TECHNOLOGY USED
We had several options of what motors we wanted to use to open/close the window. After thorough
research, we decided to go with the Linear Actuator sponsored by Firgelli. This was a very difficult
choice because we were not sure how much force the window would require in order to open and
close. The reason why we want this actuator is because of the force (35 pound) it can be able to
handle as said from their Specification sheet.
The user interface with this automated window will consist of a web application that can be accessed
by any web browser. We decided to change and do this rather than doing this on an Android
Application because we wanted to attract as many users as possible. Not everyone has access to an
Android phone, but one thing for sure is that most people have phones that are capable of accessing
the web, so that is why we decided to make this change. The user would be able to use the web to
close/open the window along with checking the status of the window.
The temperature would be measured based on the data sent by Dallas DS18B20. We decided to use
this as our temperature sensor since it is relatively cheap and can measure a wide range of
temperature. This chip would be able to send the data to the thermostat and it would take any
necessary action based on the user preferences. The way how it works is based on the user based
temperature. For example, if the user decided to choose the setting open window if temperature is
warmer outside than inside, we would need two temperature data. The temperature sensor would be
sent to the thermometer to compare the two temperatures and would operate based on that.
The raspberry pi is the main processor of this design. It will communicate with all the major
components of this project. The raspberry pi would also be connected to the custom H- Bridge circuit
which will control the movement of the window: opening or closing. The pi would also communicate
with the temperature sensors, so it would be able to take those data and will program the window to
open or close according to the data. Finally, the Pi would be able to communicate with the web
application, which would enable the user to communicate back to the processor. The raspberry pi
needs 5 volts to operate.
6
EXISTING PRODUCTS
SWABON
This is an automatic window by group of students at Louisiana Tech. The materials they used were
Arduino, breadboard, battery, servo, and a switch. The switch is used as to close and open the
window. The window is powered by 6 AA batteries. The servo motors are used to move the window
up and down. The water sensor at the bottom determines whether the window should open or close.
Pros:
●
●
Cons
●
●
●
Open and close very fast
Can detect water
Does not have any detection of any object in the way
No temperature sensor, just because it is wet does not mean it is too cold
No communication with the user
How we will make it better:
 Obviously we will have the user be allowed to communicate with the window through the
raspberry pi. User will be allowed to have an option if they want to override the option to
close/open the window
 There would be temperature sensors both outside and inside of the window
7
EXISTING PRODUCTS
AUTOMATIC WINDOW OPENER
This was an automated window created by the IED group at the Prestige WorldWide. Unfortunately, they did
not release their whole documentation about what materials they used to the public. However, the
functionalities they revealed is that the window moves up and down based on the temperature. They have the
bar in the middle that would make sure the window moves straight. The bar is connected to the top
sensors. The other feature they have is touching sensor. The window will stop moving if anything is in the way.
Pros:
● Open and Closes automatically
● It straightens the closing with an actuator
● Detects whether anything is in the way and stops
Cons
● Too slow. Nobody have time to wait for a window to open and close. There are some
who are not very patient.
● No interaction with the user.
● Very noisy. Not everybody can stand noisy movements
● The design is not very attractive and makes the window structure look ugly especially if
guests visits their house
How we will make it better:
● Our window movement would be faster
● The user would be able to communicate with the window through the raspberry pi with
their mobile.
● We will try to make it less noisy
● We will try to make the appearance not ugly.
8
PROJECT OBJECTIVES
OBJECTIVES
● Will able to be close and open automatically based on the user based temperature
● User will be asked if they want to override the opening/closing of the window
● The jamming sensor would help adjust the movement of the movement if anything were to
interfere with the movement.
● There will be temperature sensors on the outside of the window
● The movement of the window should be quiet, but move fast enough for everyone
9
SPECIFICATION
WINSTEON SPECIFICATIONS.
*Added Specifications
Note: We do not have enough items to test since our project is very limited in its functionalities.












The whole window is powered by 12 volts.
There are batteries attached to the window just in case if the power goes out.
The user would be notified if there is an object impeding the movement of the window by
having a notification sent to their mobile device
The user would be able to communicate with the window with their mobile phone
anywhere through the raspberry pi.
The movement would be triggered based on the user set temperature
o There would be temperature sensors measuring from outside and inside the window
o The user would be asked if they want to close or open the window if set to give user
notification otherwise it would close by itself
The motor control unit design created may only take 12 volts of input voltage to be able to
supply power to the linear actuator in use. It may also take GPIO signals of 3.3 volts so it
may be controlled by any microcontroller with a 3.3v GPIO signal.*
The window opens and closes at a rate of 1.45 inches per second.*(2)
Window extracts/expands for 10.55 seconds*(1)
Temperature settings would be defaulted to reasonable temperature so it would not open
at odd temperatures.*(5)
The DS18B20 temperature sensors can measure -55°C to +125°C (-67°F to +257°F) and has
an accuracy of about ±0.5℃ from−10℃ 𝑡𝑜 + 125℃.*(3)
Current Sensors would be to detect reasonable pressure to stop the motor from operating if
it detects a jam.*
The motor control unit design created may only take 12 volts of input voltage to be able to
supply power to the linear actuator in use. It may also take GPIO signals of 3.3 volts so it
may be controlled by any microcontroller with a 3.3v GPIO signal.*(4)
CRITICAL SPECIFICATIONS LIST
The specifications listed below are critical parts of operating our project. These key specifications must be
properly tested and be working in order to provide a fully working, finished, product.





10
Window extracts/expands for 10.55 seconds*(1)
The window opens and closes at a rate of 1.45 inches per second*(2)
The DS18B20 temperature sensors can measure -55°C to +125°C (-67°F to +257°F) and has
an accuracy of about ±0.5℃ from−10℃ 𝑡𝑜 + 125℃*(3)
The motor control unit design created may only take 12 volts of input voltage to be able to
supply power to the linear actuator in use. It may also take GPIO signals of 3.3 volts so it
may be controlled by any microcontroller with a 3.3v GPIO signal.*(4)
Temperature settings would be defaulted to reasonable temperature so it would not open
at odd temperatures.*(5)
USER INTERFACE
WINSTEON U.I
The Automated Window will be receiving power from the outlet which will power all components in
the device. The sliding door should be removed carefully in order to place the linear actuator at the
bottom of the window frame. This will allow the window to open/close automatically. The linear
actuator will calibrate and send its position to a circuit board. This allows the device to know exactly
where it lies and avoids over running the linear actuator which might cause the motor to malfunction.
The user will need to connect the raspberry pi to the internet modem/router via Ethernet cable. By
connecting the raspberry pi to the internet with the Ethernet cable, it will avoid any confusion that
may arise from Wi-Fi, such as not knowing which Wi-Fi signal to connect to. The raspberry pi needs to
be connected to the internet in order to have all functions for the automated window be available to
the user. Once connected to the internet, the user would then need open up the browser and enter
the I.P address that corresponds to the raspberry pi. The user will be able to choose a specific
temperature requirement or simply choose default. The default settings for the temperature
requirements will be the following: the minimum temperature of 65 degrees Fahrenheit in order to
close the window and a maximum temperature of 75 degrees Fahrenheit to open the window.
Once the device has be set up correctly, the user will also have the option to open/close the window
by simply going onto the website provided by the raspberry pi and choose whether they want the
window open or closed. They will also be given the option to have the window open automatically or
manually depending on their preference. If the user chooses to have the window open/close
automatically, then the window will open or close depending on the temperature sensors. A specific
high and low temperature requirement will be up to the user to decide.
The inputs the automated window will be receiving will be coming from the website, temperature
sensors, or current sensor. The website allows the user to open or close the window depending on
their preference. The temperature sensors will be the default inputs unless the user chooses to either
open or close the window from the website. The user will also be able to change how cold or hot the
room would need to be in order for the window to open or close automatically.
In case there is something in the way of the windows path that does not allow it to open/close
properly, then the linear actuator will stop to prevent it from burning out or malfunctioning. It will be
the responsibility of the user to remove any objects blocking the path of the window in order for the
window to open/close properly. If for any reason, the user does not respond to the jam then the
device will switch from automatic mode to manual.
11
THEORY
WINSTEON THEORY
The motor control unit which will control the movement of our linear actuator will make use of an Hbridge design which allows us to supply the 12-volt needed by the motor. In designing the H-bridge, we
used two different types of transistors; the NTE196 and PN2222 transistors, both NPN, and the NTE197
PNP transistor. The whole circuit design will be discussed more in depth in the hardware design part of
this report. We changed our motor control unit design from using 2 pairs of optocoupler relay and
SPDT relay design to the H-bridge since Professor Ward find it too simple for this project, although we
have it working already. Changing our design from relays to H-bridge was not easy since we never used
PNP transistors before.
In using the Dallas DB120 temperature sensor, we would be able to get data based on I2C. The way it
is done is by powering the power and ground pins of each of the sensor temperature. The data would
be retrieved to the PI by opening up the text files from each of the sensors based on the serial number.
To make it easier for the user, the industry temperature would be converted to Fahrenheit’s. It would
be used to compare the indoor and outdoor temperatures and the window will open/close
accordingly. If the window had finished opening/closing, there would be a while loop where we would
keep getting temperature and not go out of the while loop until the other is higher, so we would not
be wasting power by opening/closing the window when it is already done.
12
HARDWARE DESIGN
H-BRIDGE DESIGN
The new motor control unit design makes use of an H-bridge design which consists of two different
kinds of NPN transistors and a PNP transistor. Switching from using the optocoupler and SPDT relay
motor control unit design to the H-bridge design in the middle of the semester was not easy and very
stressful. We encountered a lot of problems in designing this motor control unit design, but we
ultimately managed to get it to work. The voltage and current readings that we have obtained when
we connected the 12-volt power supply to the linear actuator alone were 10.8 volts and 1.25 Amperes,
while when the whole circuit is connected to the H-bridge design, we readings of 9.9 volts with 1.2
Amperes. The slight voltage and current drop may be caused by the transistors in use as we think we
are not saturating the PNP transistors enough to supply the motor to power supply’s full potential.
We encountered a lot of problems in trying to figure out how to saturate the PNP transistor as the
transistors either heats up because there is too much voltage drop across the collector and emitter of
the transistor, or not powering up the motor at all when we are using typical resistors which has about
1/4 wattage rating. The problem comes when we use a lower resistance with low wattage rating
between the base of the NTE197 and the collector of the PN2222 transistors; it burns the resistor
immediately since it cannot handle the high current passing through it. But, when we use a higher
resistance with the same wattage rating, we manage to get the motor running but we are not getting
the desired values to move the motor fast enough. We then thought of using a 33 Ohm, 2-watt resistor
which will be able to sustain the high current passing through the resistor. Using this, we were finally
able to get decent values we were looking for to be able to open and close the window at an
acceptable speed.
13
HARDWARE DESIGN
CURRENT SENSING
The AD8210 is a single-supply, difference amplifier which can amplify small differential voltages in the
presence of large common-mode voltages. The AD8210 is placed in the middle of the H-bridge so that
it can accurately measure current in both directions by using the shunt resistor placed near the motor.
The AD8210 measures current in both directions as the H-bridge switches and the motor changes
directions. The output of the AD820 is configured so both Vref pins are tied to an external reference
which produces an output offset. The Vref pins would be connected to the Raspberry pi for the proper
output voltage. When the input is negative, the output moves down from the reference voltage. When
the input is positive, the output increases. Since the Raspberry Pi does not have an Analog to digital
convertor, we used MCP3008 10-bit, 8 channels ADC. The MCP3008 uses SPI bus protocol which is
supported by the PI’s GPIO Header.
14
HARDWARE DESIGN
TEMPERATURE SENSORS
The two Dallas D1S8B20 contains three wires: red (positive), yellow (data), and black (ground). The
way the temperature sensors are implemented is by having the red connected to the 3.3V GPIO of the
raspberry pi and black be connected to ground, so the temperature sensors would be powered up.
There would be a 4.7K pull up resistor in parallel with the positive and ground connections, so we
would be able to have a proper power flow in case if there was a disconnection from the Pi. The data
pins from both temperature sensors would be connected to the GPIO 4 of the raspberry pi. It is
possible to have the data pins from both of the temperature sensors to share a GPIO since each of
them contains a unique serial number from their manufacture. The data pins from each of the
temperature sensors would give the data when the serial number is called and opened. When that
happens, the sensor would feed the data to the raspberry pi that would actually be 1000 times more
than the actual temperature (Celsius). The conversions would be done in the software design by
coding in Python to obtain the two temperature data by obtaining the serial numbers and extracting
each digit into a variable and divide by 1000 after obtaining all the digits which is calculated into
Celsius. However, for this project we put it into Fahrenheit.
15
BLOCK DIAGRAM
16
SCHEMATIC
17
TASK LIST
HARDWARE TASK LIST
HARDWARE TASK MEMBERS
The hardware tasks group composes of four people. Each member has a very strong background in
hardware and has shown great knowledge when it comes to dealing with circuitry and electronics.
These members are in charge with anything that deals with components and connections in the project
and they must ensure that all parts are properly working and communicating with one another.
Hardware Team Members:




Jolan Santiaguel
Miguel Medina
Taylor Nguyen
Paul Aldana
The hardware task members are in charge of connecting and properly testing each component on the
automated window. The components that each member must take in account for include the
raspberry pi, the linear actuator, the current sensors, the two temperature sensors, and the custom Hbridge circuit. The team members must ensure that the whole system can function as a whole without
problems and errors. Below are some of the tasks that the hardware members are in charge of
completing.
18
HARDWARE TASK LIST
HARDWARE TASK LIST
Task Table
Task
Description
Raspberry Pi
Make sure the microcontroller is functioning
properly with the correct connects and correct
voltages.
Linear actuator
The linear actuator must be connected to the
raspberry pi and must send be able to receive
proper signals to and from the microcontroller.
The H-bridge must connect to the linear actuator
and must get proper signals from the raspberry
pi.
H-Bridge
Temperature
sensors(inside)
Temperature
Sensors(outside)
Current Sensor
The temperature sensors must be properly
connect to the raspberry pi. It must also correctly
gather the current temperature and sends the
current signals to and from the microcontroller
The temperature sensors must be properly
connect to the raspberry pi. It must also correctly
gather the current temperature and sends the
current signals to and from the microcontroller
The Ad8210 must be properly connected to the
raspberry pi. It must receive current data from
the linear actuator when the actuator is in the
process of moving the window
Team
Member(s) in
charge
Miguel
Medina,
Jolan
Santiaguel
Paul Aldana,
Miguel
Medina
Paul Aldana,
Miguel
Medina,
Taylor Nguyen
Taylor Nguyen
Paul Aldana
Progress
Status
Completed
Completed
Completed
Completed
Taylor Nguyen Completed
Paul Aldana
Paul Aldana,
Jolan
Santiaguel
Incomplete
19
TASK LIST
HARDWARE TASK LIST
Raspberry Pi
Team Member in charge: Miguel Medina
Team Member(s) support: Jolan Santiaguel
Status: Completed
Details: The hardware task members must ensure that the raspberry pi is correctly functioning. The
microcontroller is the heart of the project and must be properly operating at all times or the project
will not function or work properly. The controller must be connected to a suitable power source and
must have the correct voltages and currents flowing throughout the systems. All the other components
must be properly connected to the raspberry pi. The raspberry pi then has to make sure that it can
send out and receive signals to each individual component. The raspberry pi must also be encased to
protect it from outside influences such as the harsh weather conditions, falls, and other miscellaneous
forces that can potentially harm the system. Another thing that the hardware team must do is to
ensure that the custom printed circuit board is able support the raspberry pi and the other
components. If the custom printed circuit board cannot fit all the components then we cannot have all
the features we desire and the project will not work at a 100 percent
Linear Actuator
Team Member in charge: Miguel Medina
Team Member (s) support: Paul Aldana
Status: Completed
Details: The task member must make sure the actuator attached to the project correctly. The team
member must attach the actuator to the bottom of the window so that it can be opened or closed. It
must be able to support the weight and size of the window. The actuator must be able to move at a
decent pace and must not go too fast or too slow. The actuator must also be correctly connected to
the raspberry pi microcontroller and be able to send the proper signals to the system. The task
member must make sure that proper voltages and currents flow to the linear actuator.
20
TASK LIST
HARDWARE TASK LIST
Temperature Sensors (inside)
Team Member in charge: Taylor Nguyen
Team Member(s) support: Paul Aldana
Status: Completed
Details: There are two temperature sensors that detect the outside and inside temperatures of the
user’s house. The task member in charge of this assignment must make sure that the temperature
sensor inside the user’s house is correctly issuing the current data to the raspberry pi. The sensor must
continuously monitor the inside temperature and send that data to the raspberry pi. The sensor needs
to be correctly placed inside the user’s house to make sure that it does not capture the outside
temperature or both the outside and inside will have the same temperature and the window will not
open correctly when the user sets the window to automatically open when the inside temperature
reaches 76 degrees. The task member must make sure that the inside sensors are provided the proper
voltage and current to ensure that the component will properly function without errors or
malfunctions.
Temperature Sensors (outside)
Team Member in charge: Taylor Nguyen
Team Member(s) support: Paul Aldana
Status: Completed
Details: There are two temperature sensors that detect the outside and inside temperatures of the
user’s house. The task member in charge of this assignment must make sure that the temperature
sensor outside the user’s house is correctly issuing the current data to the raspberry pi. The sensor
must continuously monitor the outside temperature and send that data to the raspberry pi. The sensor
needs to be correctly placed outside the user’s house to make sure that it does not capture the inside
temperature or both the outside and inside will have the same temperature and the window will not
open correctly when the user sets the window to automatically open when the inside temperature
reaches 76 degrees .The task member must make sure that the outside sensors are provided the
proper voltage and current to ensure that the component will properly function without errors or
malfunctions. Like all the other components, the outside temperature sensors must also be able to
endure outside influences such as the harsh weather conditions, falls, and other miscellaneous forces
that can potentially harm the component.
21
TASK LIST
HARDWARE TASK LIST
Custom H-Bridge Circuit
Team Member in charge: Paul Aldana,
Team Member(s) support: Miguel Medina, Taylor Nguyen, Jolan Santiaguel
Status: Completed
Details: The window needs to have the capabilities of going forward and backward. However, we
cannot have both of the forward/backward functionalities go at the same time. The way we would
handle that is by creating the H-bridge which would control the movement of the window depending
on the GPIO from the Raspberry Pi. The team members responsible for this assignment must make
sure to build a custom design circuit that would be able to take the 3.3v power from the raspberry pi to
each side of the H-bridge and have two GPIO from the raspberry pi be the chip select controlling each
side of the H-bridge. The team members must also make sure the whole H-bridge will work without
having any component burning off which will mess up the control of the window functionality.
Current Sensor
Team Member(s) in charge: Jolan Santiaguel
Team Member(s) support: Paul Aldana
Time of Completion: Incomplete
Details: The AD8210 sensor must able to detect current spikes from the linear actuator when the
window is being blocked or stopped by an object or reached the end of the frame. The task members
in charge must place the sensor at the appropriate place so that the system can read currents at 100%
accuracy. The current sensor must be provided the correct current and it is the task member’s
responsibility to make sure it does not go above or below the allowable current limits. The sensor also
needs to be connected to the raspberry pi controller and it must be able to correctly send out proper
signals when the window is being blocked or stopped.
22
SOFTWARE DESIGN
OVERVIEW
The automated window will be interacting with the raspberry pi that will be connected directly to the
home internet modem/router via Ethernet cable. Once the automated window has access to the
internet, it would communicate with the online web application we have developed. The internet will
allow the user to know if the window is open or closed. It will also allow for the user to decide
whether or not they want the window to open/close automatically or manually. The software will be
uploaded onto the raspberry pi which will allow it to communicate with the window through internet
The window will open or close by sending a pulse signal to the circuit board which controls the amount
of current that will go to the linear actuator.
23
SOFTWARE DESIGN
MAIN CODE
The main code will be programmed onto the raspberry pi which it will wait for what mode the user
decides to choose. The code initializes the Raspberry Pi and the temperature sensors. It will at first be
in idle state at startup. When the user chooses automatic mode or manual mode, it will jump to that
code and execute accordingly. If the user were to change their mind, the current code would be
interrupted and jump to the location of the interrupt depending which interrupt it was. The types of
interrupt that the software will have are as followed: user input interrupt and temperature sensor
interrupt.
24
SOFTWARE DESIGN
USER INPUT AND TEMPERATURE INTERRUPTS
In the user input interrupt, the user has clicked on the button from the web to manually choose to
open or close the window. They will be able to control how cold or hot the room would need to be for
the window to open or close. The program will then wait for an input from the user to open or close
the window.
The temperature sensors interrupt will remain in a loop until the temperature requirements have been
met. The program will retrieve the inputs from the temperature sensors. If the window is open and
the temperature requirements (previously set by the user) have been met to close the window, then
the window will automatically close. If the window is closed and the temperature requirements
(previously set by the user) to open the window have been met, then the window will automatically
open.
25
SOFTWARE FLOWCHART
MAJOR SOFTWARE FLOWCHART
Raspberry Pi
Software
Application
(Website)
Temperature
Sensors
Motor Control Unit
Raspberry Pi
The Raspberry Pi would be the main processor of this design which will control the movement of the window
through the motor control unit. It will be connected to the internet so it will be able to receive commands from
the Android application.
Website
The Website will act as the remote controller of our design. The user will have the option to set the indoor
temperature which will be processed by the Raspberry Pi to either open or close the window accordingly. The
user may also activate or deactivate the automatic operation mode of the window and may manually open or
close it.
Temperature Sensors
There will be two temperature sensors in use for this design in order to measure the outdoor and indoor
temperature to be compared by the Pi. The two sensors will be using only one GPIO pin of the Raspberry Pi since
they have unique IP addresses. The sensor sends the temperature measurement in Fahrenheit.
Motor Control Unit
The motor control unit is the main circuit that controls the linear track actuator. It is based on an H-bridge
design which will be talked about in the hardware part of this design report. This MCU also contains the current
sensor which will detect any current spikes going through the motor which will then send a signal to the
raspberry pi to stop the motor to avoid potential damage to the motor.
26
SOFTWARE FLOWCHART
MINOR SOFTWARE FLOWCHART – MAIN CODE
Note: The code will idle
until one of the interrupt
occurs.
27
SOFTWARE FLOWCHART
MINOR SOFTWARE FLOWCHART – USER INPUT
28
SOFTWARE FLOWCHART
MINOR SOFTWARE FLOWCHART – TEMP SENSORS
Note: Temp sensors’ requirements
have been set up from android app to
determine its limits.
29
SOFTWARE FLOWCHART
MINOR SOFTWARE FLOWCHART – CURRENT
30
SOFTWARE FLOWCHART
MINOR SOFTWARE FLOWCHART – WEBSITE.
31
SOFTWARE FLOWCHART
MINOR SOFTWARE DESCRIPTION
Overview
The automated window will be interacting with the raspberry pi that will be connected directly to the
home internet modem/router via Ethernet cable. Once the automated window has access to the
internet, it would communicate with the online application we have developed. The internet will allow
the user to know if the window is open or closed. It will also allow for the user to decide whether or
not they want the window to open/close automatically or manually. The software will be uploaded
onto the raspberry pi which will allow it to communicate with the internet. The window will open or
close by sending a pulse signal to the circuit board which controls the amount of current that will go to
the linear actuator.
Main Code
The main code will be programmed onto the raspberry pi from which it will wait for any interface to
occur. The code initializes the raspberry pi and the sensors. It will be in an idle state in which it waits
for an interface to occur. Once the interface occurs, it will jump to the location of the interface
depending which interface it was. The types of interface that the software will have are as followed:
user input interface, temperature sensor interface, and current sensor interface.
User input interface
In this interface, the user has gone into the web application to manually choose to open or close the
window. They will also be able to control how cold or hot the room would need to be for the window
to open or close. The program will then wait for an input from the user to open or close the window.
Temperature sensors interface
This interface will remain in a loop until the temperature requirements have been met. The program
will retrieve the inputs from the temperature sensors. If the window is open and the temperature
requirements (previously set by the user) have been met to close the window, then the window will
automatically close. If the window is closed and the temperature requirements (previously set by the
user) to open the window have been met, then the window will automatically open. If the user has not
yet set up custom temperature requirements, then it will default to 80 degrees and 65 degrees. This
means that if the room temperature goes above 80 degrees and outside temperature is below 80, the
window will begin to open (if it’s not already open). If the room temperature falls below 65 degrees,
then the window will close (if it’s not already closed).
32
SOFTWARE FLOWCHART
MINOR SOFTWARE DESCRIPTION - CONTINUED
Current sensor interrupt
The current sensor interface will occur throughout the software. Every time the window opens and
closes, the current sensor will be detecting any force that’s coming from the opposite direction of the
window. For example, if any object is in the way of the window and has a hard time closing or opening
completely then the motor will be forced to stop. The program will then wait for approximately 2
minutes. If it has not been taken care of after a certain that time, then the device will switch from
automatic mode to manual.
33
TASK LIST
SOFTWARE TASK LIST
SOFTWARE TASK MEMBERS
The software tasks group composes of four people. Each member has a very strong background in
software and has shown great knowledge when it comes to coding and algorithms. These members are
in charge with anything that deals with software related issues and problems and they are tasked with
writing routines for each working component.
Software Team Members:




Paul Aldana
Miguel Medina
Taylor Nguyen
Jolan Santiaguel
The software group is in charge of creating software that allows the window to be fully automated.
Temperature sensors, apps, jamming sensors, and errors must be accounted for and the window must
be functioning at all times. Below are some of the tasks that the software members are in charge of
completing.
Task Table
Task
Description
Website HTML
and JavaScript
Check for access to input from Winsteon Control
Website
Temperature
Sensors
Ensure that the temperature sensor is correctly
collecting and storing data for the window.
Actuators
The actuator must be opening and closing the
windows properly. The members in charge have to
make sure that actuators are correctly opening and
closing the window
The actuator at times will encounter jams by an object
or will eventually reach the end of the frame. The
member in charge will be responsible for
programming
Current Sensor
Team
Member(s) in
charge
Miguel
Medina,
Jolan
Santiaguel
Miguel
Medina,
Taylor Nguyen
Paul Aldana,
Taylor Nguyen
Paul Aldana,
Jolan
Santiaguel
Status
Completed
Completed
Completed
Incomplete
34
TASK LIST
SOFTWARE TASK LIST
WEBSITE HTML AND JAVASCRIPT
Team Member(s) in charge: Jolan Santiaguel
Team Member(s) support: Miguel Medina
Status: Complete
Details: The software group member in charge must create a Website that has several functionalities
that the user can use. The first option must be to turn the automatic feature of the window off. This is
very convenient when the user decides to leave their place and does not want the window to
automatically open when they’re not home. The second option is to allow the user to set an indoor
temperature range in which the window would open or close. For example, if the user sets the
temperature at 75 degrees to open then the window would open when the temperature is 75 degrees.
Likewise, if the user sets the temperature at 65 degrees close then the window would automatically
close at 65 degrees. A possible option would be to notify the user if the window is being jammed or
when the window is closed.
Temperature sensors
Team Member(s) in charge: Taylor Nguyen
Team Member(s) support: Miguel Medina
Status: Complete
Details: The software task group members must take the incoming temperature data from the sensors
so that the window would be able to close or open when the temperature hits the temperature mark
set by the user. The software group must create a code that takes the current temperature data and
compare it with the temperature mark set by the user. If the mark and data match, then there would
be a signal that would be sent to the actuators to either open or close the window depending on which
mode the user has selected. If the mark and data do not match, the program will keep checking the
current temperature data until it matches the marked temperature. The other functionality the team
member is responsible for is comparing the indoor and outdoor temperature. This functionality will
only work if the feature of user imputing temperature is turned off. The window will open/close when
the outside temperature is warmer/cooler. This functionally can be coded in a polling method or by
using interrupts. Both methods would work, but interrupts would seem the best to avoid overhead.
35
TASK LIST
SOFTWARE TASK LIST
Actuators
Team Member in charge: Paul Aldana
Team Member(s) support: Taylor Nguyen
Status: Complete
Detail: The software task members must be able to turn and turn off the actuators at the appropriate
time. They must write a routine to gather inputs from the temperature sensors, current sensors, and
user inputs. If the temperature sensors send a signal to open the window then the software task team
must be able to write a routine to activate the actuators and open the window. The same would go if
the actuators have gotten a signal from the jamming sensors. The actuators would also have to
respond to the user commands of opening or closing the window.
Current Sensor
Team Member in charge: Jolan Santiaguel
Team Member(s) support: Paul Aldana
Status: In Progress
Detail: The software task members must be able to turn and turn off the actuators at the appropriate
time. For this part, the member in charge must write a program to detect any jam or signs of the
window reaching to the end. By that, it would be done by using the current sensor detecting current
spike. The current spike would indicate that the window has reached the end or is stuck. When the
raspberry pi receives that data, the GPIO going to the H-bridge, would be off, so the linear actuator
would stop wasting power.
36
GNATT GRAPH
HARDWARE
37
GNATT GRAPH
SOFTWARE
38
COSTS
CAPACITOR
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
COM08375
Spark Fun
Electronics
Spark Fun
Electronics
Common 0.1uF
capacitor. 0.1”
spaced leads for
easy breadboarding
and perf boarding
$0.25
Spring
2015
X5
Illustration
A capacitor is a passive two-terminal electrical component used to store energy electrostatically in
an electric field. The forms of practical capacitors vary widely, but all contain at least two electrical
conductors (plates) separated by a dielectric (i.e. insulator).
39
COSTS
CURRENT SENSE AMPLIFIER
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
AD8210
Analog Devices
Inc.
Mouser
The AD8210 is a
single-supply,
difference amplifier
ideal for amplifying
small differential
voltages in the
presence of large
common-mode
voltages.
$4.56
Spring
2015
X2
Illustration
The AD8210 is a single-supply, difference amplifier ideal for amplifying small differential voltages
in the presence of large common-mode voltages. The operating input common-mode voltage
range extends from −2 V to +65 V. The typical supply voltage is 5 V
40
COSTS
DC POWER ADAPTOR
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
N/A
Firgelli
Firgelli
 12VDC
 12 Amp supply
 100-240V, 50/60 hz
input
 2 wire config.
 Inductive load type
so ideal for high
current start-up
actuators.
$65.00
Spring
2015
X1
Illustration
The 12V DC adaptor is the most popular way to power home automation or custom prototype
application. Offering plug and play capabilities, the Firgelli Automations power adaptor is a simple and
easy approach to bringing 12 volt motion assemblies to life. Compatible with all 12 volt products
offered, including mini, light duty and heavy duty rod-style, high speed, deluxe, and sleep actuator
lines.
41
COSTS
DIODES
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
1N4004
Vishnay
Torrance
Electronics
 Diffused Junction
 High Current
Capability and Low
Forward Voltage
Drop
 Surge Overload
Rating to 30A Peak
 Low Reverse
Leakage Current
$1.00
Spring
2015
X 20
Illustration
In electronics, a diode is a two-terminal electronic component with asymmetric conductance; it has
low (ideally zero) resistance to current in one direction, and high (ideally infinite) resistance in the
other. The most common function of a diode is to allow an electric current to pass in one direction
(called the diode's forward direction), while blocking current in the opposite direction
(the reverse direction). Thus, the diode can be viewed as an electronic version of a check valve. This
unidirectional behavior is called rectification, and is used to convert alternating current to direct
current, including extraction of modulation from radio signals in radio receivers—these diodes are
forms of rectifiers.
42
COSTS
MINI TRACK LINE ACTUATOR
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
FA-35-TR12-XX
Firgelli
Automation
Firgelli
Automation
These actuators
have no rod that
slides in and out
instead they have a
slider that slides up
and down the main
body of the Actuator
$119
Spring
2015
X1
Illustration
The linear track actuator will be the motor used to open or close our window design. This window
will be controlled by the raspberry pi through a motor control unit. This actuator will extend if the
motor is energized and will retract if the polarity of the current is reversed. This is the motor we
have decided in using in this design since it would be much better and simpler for us to
implement. Our previous choice of using a linear actuator was scrapped since it would not open
the window as wide as we want it to and it would look unpleasant to the user. We also choose it
because of its ease of use.
43
COSTS
PNP & NPN TRANSISTORS
Part
Number
Manufacturer
Distributor
NTE196
NTE197
NTE
Electronics
INC.
Torrance
Electronics
Part Description
 DC Current Gain
specified to 7 amps
 Collector-Emitter
Sustaining Voltage:
 High Current – Gain
Bandwidth Product
Cost
Date
Received
Quantity
$1.90
Spring
2015
X4
X4
Illustration
The NTE196 (NPN) and NTE197 (PNP) are silicon complementary transistors in a TO220 type package
designed for use in general purpose amplifier and switching applications.
44
COSTS
RESISTORS
Part
Number
Manufacturer
Distributor
N/A
N/A
E.A.T
(CSULB)
Part Description






5.2k Ohms
4.7k Ohms
4.6k Ohms
2.5k Ohms
69 Ohms
33 Ohms(5 watt)
Cost
Date
Received
Quantity
$16.35
Spring
2013
X2
X2
X2
X2
X2
X2
Illustration
Resistors act to reduce current flow, and, at the same time, act to lower voltage levels within
circuits. In electronic circuits resistors are used to limit current flow, to adjust signal
levels, bias active elements, terminate transmission lines among other uses. High-power resistors
that can dissipate many watts of electrical power as heat may be used as part of motor controls,
in power distribution systems, or as test loads for generators.
45
COSTS
TEMPERATURE SENSORS
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
DS18B20
Vktech
Amazon
High quality stainless
steel tube
encapsulation
waterproof, moisture
proof, prevent rust
$11.00
Spring
2015
X5
Illustration
The Dallas DS18B20 temperature sensor is the one we choose since the raspberry pi doesn’t have
an ADC built-in which makes it very compatible and convenient. This temperature sensor is a
digital thermometer which provides 9-bit to 12-bit Celsius temperature measurements through its
data pin. The VDD is connected to the 3.3v power of the raspberry pi with a pull-up resistor of 4.7k
Ohms (see schematics for the temperature sensor setup). We will be using the waterproof
DS18B20 for the sensor we are going to put outdoor.
46
COSTS
TRANSISTORS
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
TPN22A
Generic
Transistors
Torrance
Electronic
 Silicon epitaxial
NPN transistor
 TO-92 Package
suitable for
through-hole PCB
assembly
$0.25
Spring
2015
X8
Illustration
The TPN22A is a common NPN bipolar junction transistor used for general purpose low
power amplifying or switching applications. It is designed for low current and power,
medium voltage, and can operate at moderately high speeds. This transistor is low cost, widely
available and sufficiently robust to be of use by experimenters. When looking at the flat side with
the leads pointed downward, the three wires emerging from the bottom are connected to, left to
right, the emitter, the base and the collector.
47
COSTS
WINDOW
Part
Number
Manufacturer
Distributor
Part Description
Cost
Date
Received
Quantity
605555
Lowes
Lowes
10 Series LeftOperable Vinyl Double
Pane Annealed Sliding
Window (Fits Rough
Opening: 36-in x 36-in;
Actual: 35.5-in x 35.5in)
$119
Spring
2015
X1
Illustration
10 Series Left-Operable Vinyl Double Pane Annealed Sliding Window (Fits Rough Opening: 36-in x
36-in; Actual: 35.5-in x 35.5-in)
48
COSTS
TOTAL
The numbers indicated below are the total component cost to produce one unit of the Winsteon Home
Automated Window. The total cost for 1000 units is also included as well as the total hours to produce
one unit and the total hours to produce 1000 units.
Note: The total hour to produce 1 unit of the Winsteon Home Automated Window is based on having
the production team have the knowledge to properly produce one unit and all they need to do is
assembly and ship the final product.
Total Costs for one Unit
Total Costs (Per 1000)
Total Hours to Produce One Unit
Total Hours to Produce (1000) Units
$ 339.06
$ 339,060
5~6
5000~6000
49
PROJECT SUCCESS SUMMARY
MAJOR CAPABILITIES

The Window will be able to open and close by itself without needing any human force
o It is open and closed by the Linear Actuator and has been always successful completing
its task

The window will open/close by itself on automatic mode based on user temperature input
o Yes, the window will keep opening and closing based on the temperature input
otherwise it will be set to default temperature of 65-80 if there are not any input from
the user

If the window function is set to manual, then the user has complete control of when to
open/close the window by the click of the open/close button.
o The window will do what is commanded by the user.

User will be asked if they want to override the opening/closing of the window.
o This feature was not added into the design due to time constraints.

The jamming sensor would help adjust the movement of the movement if anything were to
interfere with the movement.
o We could not complete the current sensing design in the project.

There will be temperature sensors on the outside of the window
o We could not complete the current sensing design in the project.

The movement of the window should be quiet, but move fast enough for everyone
o The window operates at a reasonable speed, but the sound was not as quiet as we
would like it to be.
50
PROJECT SUCCESS SUMMARY
CRITICAL SPECIFICATIONS

The window opens and closes at a rate of 1.45 inches per second
o The specification for the linear actuator indicates that it is able to expand and retract for
about 2 inches per second without any load attached to it, so having this much speed is
acceptable enough with the 3 pound sliding window piece including the friction.

The DS18B20 temperature sensors can measure -55°C to +125°C (-67°F to +257°F) and has an
accuracy of about ±0.5℃ from−10℃ 𝑡𝑜 + 125℃
o These specifications came straight from the DS18B20 specification sheets which we
have tried and tested that it functions as specified in the data sheet.

The motor control unit design created may only take 12 volts of input voltage to be able to
supply power to the linear actuator in use. It may also take GPIO signals of 3.3 volts so it may be
controlled by any microcontroller with a 3.3v GPIO signal.
o The H-bridge circuit is designed to power the 12-volt linear actuator we are using. A 12volt power supply from the same company (Firgelli) as the linear actuator is being used
to make sure that the linear actuator is powered properly.

Window extracts/expands for 10.55 seconds
o The H-bridge circuit allowed the window to operate between 10 and 11 seconds. Before
the design was implemented on a PCB, the window was extracting/expanding between
13-14 seconds.

Temperature settings would be defaulted to reasonable temperature so it would not open at
odd temperatures.
o The software design for the temperature sensors were adjusted to reasonable, default
settings. The window closes at 65 degrees and open at 80 degrees on default.
51
CONCLUSION
TEAM WINSTEON
This project was very challenging for us. We gotten most of our main goals. We were able to have the
window open/close by itself on the automatic feature. The user was able to open/close on manual
mode and able to input their own temperature range. On top of that, the user can communicate it
with any phone that has a web browser. Those were not done without the hard work we had to go
through. There were a lot of materials that we had to learn in a short amount of time during this
senior project. For the software design we had to learn different programming languages: Python and
JavaScript. This was challenging since none of had exposure to Python and especially web page design.
Debugging JavaScript language was the most difficult part of the software design because unlike other
compilers we had to figure out where the syntax error. Designing our own H-bridge which controlled
the motors was probably the most challenging part of our project. It took us a lot of failures for us to
finally build a successful H-bridge circuit. We did lots of research and gotten advices from Bob Ward
until we finally gotten it to work. Overall, we felt that we accomplished a lot by picking up new skills in
learning new programming languages, problem solving skills, and circuit designs.
During this project we had several changes. The major change that came was discontinuing the use of
the Insteon Hub. None of us really had a good understanding how to work with the Hub since the
Insteon Hub did not have a lot of open source tutorials. Instead we decided to just have the Pi
communicating the user’s phone instead of by remote. The other change we made was the Android
Application. We decided to change it to web based because we thought it would be better to be more
accessible since not everyone have an Android Phone. Most people have at least a phone that can
access the web browser, so that was the reason why we decided to change the interface to a web
application. The last change was removing the current sensor. Unfortunately, this current sensor
would not be able to work with the Pi since it had to be converted from Analog to Digital. The Pi does
not have an ADC, so we discarded that. Despite the removal of these features, we feel like this product
can be useful since it would be convenient for the window to open/close from the touch of their
phone.
52
APPENDIX
APPENDIX A
Raspberry Pi

http://www.raspberry-projects.com/pi/pi-hardware/raspberry-pi-model-b/hardware-generalspecifications
AD8210

http://www.analog.com/media/en/technical-documentation/data-sheets/AD8210.pdf
Firgelli Actuator and Power Supply

https://www.firgelliauto.com/products/dc-power-adaptor

https://www.firgelliauto.com/collections/mini-track-actuators/
NTE196 & 197

http://www.alldatasheet.com/datasheet-pdf/pdf/9860/NTE/NTE196.html
DS18B20

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Temp/DS18B20.pdf
TPN22A

http://www.datasheetarchive.com/TPN22-datasheet.html
53
APPENDIX
APPENDIX B
Sources
1. http://davstott.me.uk/index.php/2013/03/17/raspberry-pi-controlling-gpio-from-the-web/
2. http://www.reuk.co.uk/DS18B20-Temperature-Sensor-with-Raspberry-Pi.htm
54
Python code
#!/usr/bin/pythonRoot
# bring in the libraries
import RPi.GPIO as G
from flup.server.fcgi import WSGIServer
import sys, urlparse
import time
# set up our GPIO pins
G.setmode(G.BOARD)
G.setup(11,G.OUT) #outside
G.setup(13,G.OUT) #indoor
# all of our code now lives within the app() function which is called for
each http request we receive
def app(environ, start_response):
# start our http response
start_response("200 OK", [("Content-Type", "text/html")])
# look for inputs on the URL
i = urlparse.parse_qs(environ["QUERY_STRING"])
yield (' ') # flup expects a string to be returned from this function
# if there's a url variable named 'q'
if "q" in i:
if i["q"][0] == "w":
G.output(13, False) # Turn the closing off
time.sleep(3)
# Delay in between switching
G.output(11, True)
# Turn the open on
time.sleep(11)
# Approximate time it takes to open completely
G.output(11, False) # Turn off the open chip select to save power
elif i["q"][0] == "s":
G.output(11, False) # Turn the open off
time.sleep(3)
# Delay in between switching
G.output(13, True)
# Turn the closing on
time.sleep(11)
# Approximate time it takes to close completely
G.output(13, False) # Turn off the close Chip Select to save Power
elif i["q"][0] == "a":
while 1:
tempfile = open("/sys/bus/w1/devices/28-000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/28-00000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
55
#convert it to farenheit
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
if temperaturea>temperature:
G.output(11,False)
time.sleep(3)
G.output(13,True)
time.sleep(11)
while temperaturea>temperature:
G.output(11,False)
G.output(13,False)
tempfile = open("/sys/bus/w1/devices/28000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/2800000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
else:
G.output(13,False)
time.sleep(3)
G.output(11,True)
time.sleep(11)
while temperaturea<temperature:
G.output(11,False)
G.output(13,False)
tempfile = open("/sys/bus/w1/devices/28000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/2800000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
56
#by default, Flup works out how to bind to the web server for us, so just
call it with our app() function and let it get on with it
WSGIServer(app).run()
"""import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
while 1:
tempfile = open("/sys/bus/w1/devices/28-000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/28-00000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
#convert it to farenheit
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
print "Indoor Temperature: "
print temperature
print "Outdoor Temperature: "
print temperaturea
57
if temperaturea>temperature:
GPIO.output(11,False)
time.sleep(3)
GPIO.output(13,True)
time.sleep(12)
while temperaturea>temperature:
GPIO.output(11,False)
GPIO.output(13,False)
tempfile = open("/sys/bus/w1/devices/28-000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/28-00000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
print
print
print
print
"Indoor Temperature: "
temperature
"Outdoor Temperature: "
temperaturea
else:
GPIO.output(13,False)
time.sleep(3)
GPIO.output(11,True)
time.sleep(12)
while temperaturea<temperature:
GPIO.output(11,False)
GPIO.output(13,False)
tempfile = open("/sys/bus/w1/devices/28-000005ea7173/w1_slave")
tempfilea = open("/sys/bus/w1/devices/28-00000628c27f/w1_slave")
thetext = tempfile.read()
thetexta = tempfilea.read();
tempfile.close()
tempfilea.close()
tempdata = thetext.split("\n")[1].split(" ")[9]
tempdataa = thetexta.split("\n")[1].split(" ")[9]
temperature = float(tempdata[2:])
temperaturea = float(tempdataa[2:])
temperature = temperature /1000
temperaturea = temperaturea /1000
temperature = ((9.0/5.0) * temperature) + 32
temperaturea = ((9.0/5.0) * temperaturea) + 32
print "Indoor Temperature: "
print temperature
print "Outdoor Temperature: "
print temperaturea
time.sleep(1)"""
58
Code from http://davstott.me.uk/index.php/2013/03/17/raspberry-pi-controlling-gpio-from-theweb/
59
Code from http://www.reuk.co.uk/DS18B20-Temperature-Sensor-with-Raspberry-Pi.htm
60
JavaScript & HTML Code
<body>
<head>
<style>
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#nav {
line-height:15px;
background-color:#eeeeee;
height:300px;
width:125px;
float:left;
padding:5px;
}
#section {
width:400px;
float:left;
padding:10px;
}
#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
</head>
<body>
<div id="header">
<h1>Winsteon Control Center</h1>
</div>
<div id="nav">
<b><ins>Temperatures:<br><br></b></ins>
Gardena: <span id="atlanta"></span><br><br>
Long Beach:<span id="newyork"></span><br><br>
Carson: <span id="dc"></span><br>
</ul>
</div>
61
<div id="section">
<title>Winsteon Control Centeri</title>
<script src="//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
</head>
<body>
<form>
<p><b>Window Status: </b>
<input type="button" value="Open" onclick="go('w')" style="font-size:100%;">
<input type="button" value="Close" onclick="go('s')" style="font-size:100%;">
</p>
</form>
<form method="get" >
<b>Automatic Mode: </b>
<select name="select" id="select">
<option value=0>Disabled</option>
<option value=1>Enabled</option>
</select>
</form>
<b>Temperature1:</b> <input type="text" name="myText1" id='myText1' value="0 - 90">
<input type="button" value="Set Close" onclick="check1()" style="font-size:100%;">
<b>Temperature2:</b> <input type="text" name="myText2" value="0 - 90">
<input type="button" value="Set Open" onclick="check2()" style="font-size:100%;"> <br />
<input type="button" value="Default" onclick="check3()" style="font-size:100%;">
<script type="text/javascript">
var c = 0;
var t;
var timer_is_on = 0;
var lastrequest;
var i = 0;
var openflag = false;
var closeflag = false;
var okflag1 = false;
var okflag2 = false;
function go(qry) {
var option = document.getElementById('select').value;
if(qry == 'w'){
openflag = true;
closeflag = false;
}
if(qry == 's'){
closeflag = true;
openflag = false;
}
62
if( openflag == true && closeflag == false) {
okflag1 = true;
okflag2 = false;
}
else if ( closeflag == true && openflag == false) {
okflag2 = true;
okflag1 = false;
}
if(option == 0) {
if( okflag1 == true || okflag2 == true) {
new Ajax.Request('doStuff.py?q=' + qry,
{method: 'GET'}
);
okflag1 = false;
okflag2 = false;
openflag = false;
closeflag = false;
}
}
else {
alert('automode is enabled');
}
}
function check1() {
var tempclose = document.getElementsByName('myText1')[0].value;
alert('Close at ' + tempclose + ' degrees');
}
function check2() {
var tempopen = document.getElementsByName('myText2')[0].value;
alert('Open at ' + tempopen + ' degrees');
}
function check3() {
alert('Close at 65 degrees \nOpen at 80 degrees');
}
function timedCount() {
document.getElementById("txt").value = c;
c = c + 1;
var blah = 'a';
lastrequest = new Ajax.Request('doStuff.py?q=' + blah,
{method: 'GET'}
);
t = setTimeout(function(){ timedCount() }, 1000);
63
}
function startCount() {
if (!timer_is_on) {
timer_is_on = 1;
timedCount();
}
}
function stopCount() {
lastrequest.abort();
clearTimeout(t);
timer_is_on = 0;
}
</script>
</body>
</div>
<script type="text/javascript">
function temp( where, tempObj )
{
var f = tempObj.query.results.channel.item.condition.temp;
document.getElementById( where ).innerHTML =
f + "F, " + ( (f -32) * 5 / 9 ).toFixed(0) + "C";
}
function weatherAtlanta(o) { temp("atlanta",o); }
function weatherNY(o) { temp("newyork",o); }
function weatherDC(o) { temp("dc",o); }
</script>
<script type="text/javascript"
src="http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20loc
ation%3D%2290249%22&format=json&callback=weatherAtlanta"></script>
<script type="text/javascript"
src="http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20loc
ation%3D%2290802%22&format=json&callback=weatherNY"></script>
<script type="text/javascript"
src="http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20loc
ation%3D%2290248%22&format=json&callback=weatherDC"></script>
</body>
<div id="footer">
Copyright © Winsteon
</div>
</html>
64
Code from http://davstott.me.uk/index.php/2013/03/17/raspberry-pi-controlling-gpio-from-the-web/
65
Download