remote weather station

Upload: rnprnp

Post on 03-Jun-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Remote Weather Station

    1/32

    1 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Remote Weather Station

    Using XBee Wireless Transceivers

    Christopher McCoy

    CEN 4935

    Dr. Janusz Zalewski

    Florida Gulf Coast University

    April 29, 2011

  • 8/12/2019 Remote Weather Station

    2/32

    2 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 1: Introduction

    Throughout the centuries, attempts have been made to produce forecasts based on

    weather lore and personal observations (Earth Observatory).

    People have always been fascinated with weather and its effect on their lives. This

    fascination naturally led to a desire for prediction. With all the ways we are affected this

    prediction would make life much easier. The NASA Earth Observatory claims Around 650

    B.C., the Babylonians tried to predict short-term weather changes based on the appearance of

    clouds and optical phenomena such as haloes. All throughout history there are examples of

    people predicting the weather. The most basic of these predictions would temperature.

    Benedetton Castelli wrote in 1638 about a device he had seen in Galileo's hands around1603 (Middleton). Galileos design incorporated a container to hold water as well as a glass

    tube. When the water temperature changes the water rises or falls accordingly. Over the next

    few hundred years the design was refined and liquid changed to more accurately judge the

    temperature. These refinements resulted in the thermometer we know today.

    To truly predict the weather the barometer was invented.

    Evangelista Torricelli invented the mercury barometer in 1643 and today's mercury barometers

    are much like those of the 17th century (Palmer).

    A barometer measures the air pressure. Low pressure tends to produce cloudy, rainy conditions

    while higher pressure tends to have fewer clouds and results in a fair weather trend. Granted this

    only gives us a few hours or at most a day or two but this was a giant step forward from what

    was available previously.

    Another term that is commonly associated with the weather is humidity. Humidity is the

    measure of the amount of water vapor in the air. The higher the humidity, the heavier the air

    feels. When the temperature is higher humidity actually make it feel hotter than it really is. To

    measure humidity an instrument called a hygrometer is used.

  • 8/12/2019 Remote Weather Station

    3/32

    3 RemoteWeatherStationUsingXBeeWirelessTransceivers

    A hygrometer is an instrument used to measure the moisture content or the humidity of

    air or any gas (Bellis).There are numerous types ranging from ones that use hair (the hair extends

    or contracts depending on the moisture content) to more complicated ones that use two

    thermometers. One thermometer is exposed to the air while the other is submerged in water.

    Based on the readings from each thermometer a table is then used to compute the humidity.

  • 8/12/2019 Remote Weather Station

    4/32

    4 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 2: Problem Description

    This project is a continuation of one started in fall of 2009 by Bradd Konert. He first

    built a wireless weather station consisting of a Arduino weather microcontroller, XBee wireless

    transceiver, LED display and a small solar panel to run the station and charge a series of AA

    batteries.

    My goal is to expand upon the work that he completed and gain a complete

    understanding of the hardware used. In addition I will create a software based user interface to

    display the incoming sensor data.

    However, the weather station is not in working condition. Several of the connections

    have been removed or disconnected. The batteries are currently dead. The documentation on theway the station was constructed is available but the markings are somewhat unclear.

    Numerous attempts to repair these problems failed completely. As a result, a new

    Arduino 2560 Mega board and SHT15 Temperature and Humidity sensor were ordered. These

    items have then been used to complete this project instead of the original components. As a

    result of these unforeseeable failures the updated goal is to connect, program and verify the

    wireless network using these new parts.

  • 8/12/2019 Remote Weather Station

    5/32

    5 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 3: Design Solution

    Section 3.1: Original Design Solution

    The original solution is outlined below. The images show the weather station, weather

    sensors, XBee transceiver mounted to Arduino 2560 Mega board, solar panel and rechargeable

    battery pack.

    Figure 3.1: Current state of the interior of the weather station.

    As you can see from the above picture most of the wires are disconnected or not in their proper

    location. Some of the soldering also looks to be bad and in need of repair.

  • 8/12/2019 Remote Weather Station

    6/32

    6 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 3.2: Exterior view of weather station. February 10, 2011

    Inspecting the outside there doesnt appear to be any physical damage. However, until

    the station is functioning there is really no way to know if the LED display and switches are in

    working order. There are no cracks or scratches on the solar panel so it appears to be structurally

    intact.

    The system was also tested using a volt meter to ensure the solar panel was generating

    enough electricity to power the system. Test results showed the power generated was more than

    sufficient for our needs.

  • 8/12/2019 Remote Weather Station

    7/32

    7 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 3.3:Wiring diagram provided by Dr. Zalewski. Obtained originally

    from Bradd Konert.

    Above is the provided wiring diagram that I am in the process of trying to use to rewire the

    weather station.

  • 8/12/2019 Remote Weather Station

    8/32

    8 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 3.2: Modified Design Solution

    As a result of the problems found with the original hardware I was forced to order

    replacement parts and modify the project. The revised solution implements a more basic version

    of the original. The components consist of:

    1. the Arduino 2560 Mega microcontroller board (Figure 3.2.1)2. XBee shield mounted (Figure 3.2.2)3. SHT15 Temperature/Humidity sensor (Figure 3.2.3)4. XBee Pro transceiver mounted on a host development board (Figure 3.2.4)

    The assembled components are shown in figure 3.2.5.

    Figure 3.2.1: Arduino Mega 2560

  • 8/12/2019 Remote Weather Station

    9/32

    9 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Firgure 3.2.2: XBee on shield

    Figure 3.2.3: SHT15 Temperature and Humidity Sensor

  • 8/12/2019 Remote Weather Station

    10/32

    10 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 3.2.4: XBee Pro on development board

    Figure 3.2.5: Assembled Components

  • 8/12/2019 Remote Weather Station

    11/32

    11 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 4: Implementation

    Section 4.1: Hardware Assembly Attaching Sensor and XBee Shield to Arduino

    Connecting the sensor to the microcontroller is a simple and straightforward process (see figure

    4.1.1).

    1. Begin by connecting the VCC pin on the sensor board to the 5V pin on the Arduinomicrocontroller. This provides power to the sensor. No soldering is required.

    2. Next connect the GND on the sensor board to the GND port on the microcontroller, nextto the 5V pin.

    3. Connect the DATA pin on the sensor to pin 9 on the microcontroller.4. Connect the SCK (System Clock) pin to pin 8 on the microcontroller.

    The actual sensor connected is shown in Figure 4.1.2 and the connected XBee is shown in Figure

    4.1.3.

    5. Figure 4.1.1: Wiring Diagram

  • 8/12/2019 Remote Weather Station

    12/32

    12 RemoteWeatherStationUsingXBeeWirelessTransceivers

    The XBee shield communicates with microcontroller through 6 pins in the center of the

    microcontroller. Simply line up the pins and gently press the shield onto the microcontroller.

    Due to the alignment of the ports and pins on both the shield and microcontroller there is only

    one way for these to connect.

    This is all that is required to interface the sensor and the Arduino microcontroller.

    Figure 4.1.2: Sensor connected to microcontroller

  • 8/12/2019 Remote Weather Station

    13/32

    13 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 4.1.3: Sensor and XBee shield connected to microcontroller

  • 8/12/2019 Remote Weather Station

    14/32

    14 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 4.2: Software Implementation

    This implementation is written in C and uploaded to the Arduino microcontroller using

    an IDE provided by Arduino. An explanation of loading this code is located in the testing

    section. The operation of the software is illustrated in the flowchart shown in Figure 4.2.1.

    Figure 4.2.1: software operating flowchart

    Below is the software implementation that is loaded on the Arduino microcontroller.

    int dataPin = 9;

    int sckPin = 8;

    void resetSHT()

    {

  • 8/12/2019 Remote Weather Station

    15/32

    15 RemoteWeatherStationUsingXBeeWirelessTransceivers

    pinMode(dataPin,OUTPUT);

    pinMode(sckPin,OUTPUT);

    shiftOut(dataPin, sckPin, LSBFIRST, 255);

    shiftOut(dataPin, sckPin, LSBFIRST, 255);

    digitalWrite(dataPin,HIGH);

    for(int i = 0; i < 15; i++){

    digitalWrite(sckPin, LOW);

    digitalWrite(sckPin, HIGH);

    }

    }

    //Specific SHT start command

    void startSHT()

    {

    pinMode(sckPin,OUTPUT);

    pinMode(dataPin,OUTPUT);

    digitalWrite(dataPin,HIGH);

    digitalWrite(sckPin,HIGH);

    digitalWrite(dataPin,LOW);

    digitalWrite(sckPin,LOW);

    digitalWrite(sckPin,HIGH);

    digitalWrite(dataPin,HIGH);

    digitalWrite(sckPin,LOW);

    }

    void writeByteSHT(byte data)

    {

    pinMode(sckPin,OUTPUT);

    pinMode(dataPin,OUTPUT);

  • 8/12/2019 Remote Weather Station

    16/32

    16 RemoteWeatherStationUsingXBeeWirelessTransceivers

    // digitalWrite(dataPin,LOW);

    shiftOut(dataPin,sckPin,MSBFIRST,data);

    pinMode(dataPin,INPUT);

    //Wait for SHT15 to acknowledge by pulling line low

    while(digitalRead(dataPin) == 1);

    digitalWrite(sckPin,HIGH);

    digitalWrite(sckPin,LOW); //Falling edge of 9th clock

    //wait for SHT to release line

    while(digitalRead(dataPin) == 0 );

    //wait for SHT to pull data line low to signal measurement completion

    int i = 0;

    while(digitalRead(dataPin) == 1 )

    {

    i++;

    if (i == 255) break;

    delay(10);

    }

    }

    //Read 16 bits from the SHT sensor

    int readByte16SHT()

    {

    int cwt = 0;

  • 8/12/2019 Remote Weather Station

    17/32

    17 RemoteWeatherStationUsingXBeeWirelessTransceivers

    unsigned int bitmask = 32768;

    int temp;

    pinMode(dataPin,INPUT);

    pinMode(sckPin,OUTPUT);

    digitalWrite(sckPin,LOW);

    for(int i = 0; i < 17; i++) {

    if(i != 8) {

    digitalWrite(sckPin,HIGH);

    temp = digitalRead(dataPin);

    // Serial.print(temp,BIN);

    cwt = cwt + bitmask * temp;

    digitalWrite(sckPin,LOW);

    bitmask=bitmask/2;

    }

    else {

    pinMode(dataPin,OUTPUT);

    digitalWrite(dataPin,LOW);

    digitalWrite(sckPin,HIGH);

    digitalWrite(sckPin,LOW);

    pinMode(dataPin,INPUT);

    }

    }

    //leave clock high??

    digitalWrite(sckPin,HIGH);

    return cwt;

    }

  • 8/12/2019 Remote Weather Station

    18/32

    18 RemoteWeatherStationUsingXBeeWirelessTransceivers

    int getTempSHT()

    {

    startSHT();

    writeByteSHT(B0000011);

    return readByte16SHT();

    }

    int getHumidSHT()

    {

    startSHT();

    writeByteSHT(B00000101);

    return readByte16SHT();

    }

    void setup() {

    pinMode(dataPin,OUTPUT);

    pinMode(sckPin,OUTPUT);

    // connect to the serial port, sends data to the XBee

    Serial.begin(9600);

    Serial.println("Resetting SHT...");

    resetSHT();

    }

    void loop () {

    delay(2000);

    Serial.println("Starting Temperature/Humidity reading...");

    int temp = getTempSHT()*0.018-40;

  • 8/12/2019 Remote Weather Station

    19/32

    19 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Serial.print("Temprature(F):");

    Serial.println(temp);

    temp = -4.0 + 0.0405 * getHumidSHT()+ -0.0000028 * getHumidSHT()* getHumidSHT();

    Serial.print("Humidity:");

    Serial.print(temp);

    Serial.println("%");

    }

  • 8/12/2019 Remote Weather Station

    20/32

    20 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 5: Testing

    Section 5.1: XBee Configuration (***Optional***)

    This section is only relevant if you are using older XBee transceivers. By default each

    should communicate with no additional configuration.

    1. With the sensor disconnected mount the XBee shield to the Arduino microcontroller.2. The two transceivers should work with no configuration. If they do not continue on to

    step 3.

    The following steps were obtained from http://antipastohw.blogspot.com/2009/01/xbee-

    shield-to-xbee-shield.html.

    3. Download X-CTU from Digis website:http://www.digi.com/support/productdetl.jsp?pid=3352&osvid=57&tp=4&s=316

    4. Put both Arduinos in Reset.5. Attach a USB cable from one arduino to Computer "A". Attach the other USB cable to

    the other arduino and Computer "B". Open X-CTU.

    6. Go to the "Modem Configuration" tab... set the Modem: XBEE to "XB24-B" AND setthe Function Set to "ZNET 2.5 ROUTER/END DEVICE AT"

    7. Next is the Networking and Addressing Parameters...8. PAN ID = 1111 (Figure 5.1.1)

  • 8/12/2019 Remote Weather Station

    21/32

    21 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure5.1.1:Step8

    9. Destination Address High = 13A200 (I found this out by typing "AT" commands into aterminal program... first type in "+++" the xbee will return an "OK" you are now in

    command mode... if you type "ATSH" then "" (enter), the xbee will give you it's own

    high address (source address) ) (Figure 5.1.2)

  • 8/12/2019 Remote Weather Station

    22/32

    22 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure5.1.2: Step9

    10.Destination Address Low = 403E2502 (I found this out by typing "AT" commands into aterminal program) (Figure 5.1.3)

  • 8/12/2019 Remote Weather Station

    23/32

    23 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure5.1.3:Step10

    11.Click the "Write" button on the Modem Configuration tab and wait for the XBee toprogram

    12.If some funny error comes up... click the button on the xbee shield and try to program itagain

    13.Go to the "Modem Configuration" tab on computer B... set the Modem: XBEE to "XB24-B" AND set the Function Set to "ZNET 2.5 COORDINATOR AT (Figure 5.1.3)

  • 8/12/2019 Remote Weather Station

    24/32

    24 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure5.1.3:Step1314.Next is the Networking and Addressing Parameters for the other XBee.15.PAN ID = 111116.Scan Channels = 15 (not sure if this is even needed)17.Channel Verification = 018.Destination Address High = 13A200 (I found this out by typing "AT" commands into a

    terminal program... first type in "+++" the xbee will return an "OK" you are now in

    command mode... if you type "ATSH" then "" (enter), the xbee will give you it's own

    high address (source address) )

    19.Destination Address Low = 404A4FC4 (I found this out by typing "AT" commands into aterminal program)

    20.Broadcast Radius = 0

  • 8/12/2019 Remote Weather Station

    25/32

  • 8/12/2019 Remote Weather Station

    26/32

    26 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 5.2: Arduino, Sensor and XBee Testing

    1. Assemble the components as shown in section 4.2. Download Maxstream development board drivers from

    http://www.digi.com/support/kbase/kbaseresultdetl.jsp?id=2138

    3. IftheArduinoIDEisnotcurrentlyinstalled,downloadfromhttp://arduino.cc/en/Main/Softwareselectingthecorrectoperatingsystemfromthelist.

    4. Once assembled go to the computer and open the Arduino software.5. Create a new sketch (Figure 5.2.1)

    Figure 5.2.1: New sketch creation

  • 8/12/2019 Remote Weather Station

    27/32

    27 RemoteWeatherStationUsingXBeeWirelessTransceivers

    6. Copy the code from section 4.2 to the sketch window.7. Once the code is copied choose go Tools, Board and ensure that the Mega 2560 is

    selected (Figure 5.2.2).

    Figure 5.2.2: Proper board selection.

  • 8/12/2019 Remote Weather Station

    28/32

    28 RemoteWeatherStationUsingXBeeWirelessTransceivers

    8. Lastly press the reset button on the microcontroller and then the upload button on theArduino IDE (Figure 5.2.3).

    Figure 5.2.3: Upload button.

    9. Once the upload is complete a message will print in the black section at the bottom. Ifthere is a problem it will also be listed here.

    10.Open the serial monitor (Figure 5.2.4) and you should see temperature and humidity databeing printed (Figure 5.2.5).

  • 8/12/2019 Remote Weather Station

    29/32

    29 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 5.2.4: Serial monitor button used to monitor results

  • 8/12/2019 Remote Weather Station

    30/32

    30 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Figure 5.2.5: Correct results.

    Section 5.3: Testing Comments

    One thing to note in this testing. It appears that the XBee shield attached to the Arduino

    microcontroller is failing. There are times where it is extremely difficult to get the transceiversto interface or the transmission stops for no apparent reason. Bradd Konert stated in his

    documentation that an overvoltage damaged the temperature sensor on the USB weather board in

    his station. This is likely the cause of this problem. At this time I would continue to monitor this

    situation and possibly obtain a new shield and transceiver before continuing this project.

  • 8/12/2019 Remote Weather Station

    31/32

    31 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 6: Conclusion

    This project has been eventful. I started off by attempting to reconstruct the original

    weather station created by Bradd Konert and encountering all the hardware components that

    ultimately were defective. I learned a great deal about connecting components using a

    breadboard and in turn testing them using a voltage meter. It was disappointing that the weather

    station was never restored to working order but in the same instance it was a great experience

    attempting to repair it.

    Once I ordered and received the replacement parts I was shocked at how powerful the

    Arduino microcontroller was. In researching the hardware the sheer number of uses these boards

    have is staggering. Connecting the sensor, programming the board and setting up the XBee

    network were challenging yet rewarding once it was complete.

    Arduino claims that the XBee adapters work with basically no setup. In my experience

    this was not the case. In speaking with Arduino I was told that these units are an older model

    and that it is the newer models that require little, if any, configuration.

    Future contributions to this project would be the ability to monitor this hardware

    configuration remotely through either a downloadable application or a dedicated webpage.

    Integrating a graph to plot previous sensor reading would also be desirable so that the user could

    use the past and present data to predict future developments.

    I would also advise looking into upgrading the weather sensors to the SHT15 USB

    Weather Board from Sparkfun (http://www.sparkfun.com/products/9800). This board features

    Absolute barometric pressure accurate within +/-150 Pascal, Relative humidity accurate within

    +/-2%, Temperature accurate within +/-0.3 degrees C and an Ambient light sensor (analog

    level). This would greatly increase the amount of data obtainable and give the user a much more

    detailed representation of the current environment.

  • 8/12/2019 Remote Weather Station

    32/32

    32 RemoteWeatherStationUsingXBeeWirelessTransceivers

    Section 7: References

    1. Earth Observatory. Weather Forecasting Through the Ages. NASA.Visited: Feb 10, 2011. http://earthobservatory.nasa.gov/Features/WxForecasting/wx2.php

    2. Albert Van Helden. The Thermometer.Visited: Feb 10, 2011. http://cnx.org/content/m11978/latest/

    3. Chad Palmer. How a Barometer Works. USA TodayVisited: Feb 10, 2011. http://www.usatoday.com/weather/wbaromtr.htm

    4. Severino. XBee Shield to XBee Shield Communication.Visited: April 5, 2011. http://antipastohw.blogspot.com/2009/01/xbee-shield-to-xbee-shield.html

    5. Arduino. Arduino XBee ShieldVisited: April 5, 2011. http://www.arduino.cc/en/Guide/ArduinoXbeeShield