2015年3月6日星期五

Week 5 (6th Mar 2015)

Week 5.1 (6th Mar 2015)
This is the fifth week of our group project. Our progresses are listed below:
First of all, the circuit was built out by connecting the temperature and pressure sensor to the FRDM-KL46Z through conducting wires. The pins of MPL 115A2 are ensured to be connected to corresponding pins on FRDM-KL46Z correctly. The microprocessors FRDM-KL46Z and LPC1768 are separately connected to two computers through USB wires.


After that, we continue with programming work. The basic flowchart of outdoor and indoor code is shown below:
Outdoor


Indoor


The outdoor part of code we utilize is an example code offered on http://developer.mbed.org/users/joeh/code/mpl115a2_example/ 
We change several specific pin names to make sure that this code suits FRDM-KL46Z successfully. 

The detailed indoor part of code we write is:

#include "mbed.h"
//#include "C12832.h"

Serial device(p9, p10);
Serial pc(USBTX, USBRX);
//C12832 lcd(p5, p7, p6, p8, p11);

int get_message(char  array[]);
int decode_message(char array[]);
float convertdata(char array[]);
int test(void);
float ws=0, wd=0, rg=0, tp=0, ps=0;

int main()
{
    int length;;
   
    int ok;
    char n[100];
   
    for(;;)
    {
    length = get_message(n);
    ok = decode_message(n);
                 
    //lcd.locate(0,4);
    pc.printf("wind speed is: %5.1f\n\r", ws);
    //lcd.locate(0,16);
    pc.printf("wind direction is: %5.1f\n\r", wd);
    //lcd.cls();
    //lcd.locate(0,4);
    pc.printf("rain guage is: %5.1f\n\r", rg);
    //lcd.locate(0,16);
    pc.printf("temperature is: %5.1f\n\r", tp);
    //lcd.cls();
    //lcd.locate(0,4);
    pc.printf("pressure is: %5.1f\n\r", ps);
    //lcd.cls();
    }                          
   
}
           
int get_message(char  array[])
{
bool gotheader = false;
bool gotend = false;
char read;
int  i;

// testing
//    printf("In get message\n\r");
    do
    {
        //printf("Waiting\n\r");
        if (device.readable())
        {
            //printf("Device Readable\n\r");
            read=device.getc();
            if(read == '@') gotheader = true;
            //pc.putc(read);            
        }
    }    while(gotheader == false);

//    printf("Got Header\n\r");

    i = 0;
    do
    {
        if (device.readable())
        {
            read=device.getc();
            array[i] = read;  
            i = i + 1;
            if (read == '\n') gotend = true;            
        }
    }    while(gotend == false);
   
//    printf("Got end\n\r");
//    printf("%c %c %c %c %c %c\n\r", array[0], array[1],array[2],array[3],array[4],array[5]);
   
    return (i);
}

int decode_message(char array[])
{
    if ((array[0] == 'W') && (array[1] == 'S'))
    {
        ws = convertdata(array);
    }
    if ((array[0] == 'W') && (array[1] == 'D'))
    {
        wd = convertdata(array);
    }
    if ((array[0] == 'R') && (array[1] == 'G'))
    {
        rg = convertdata(array);
    }
    if ((array[0] == 'T') && (array[1] == 'P'))
    {
        tp = convertdata(array);
    }
    if ((array[0] == 'P') && (array[1] == 'S'))
    {
        ps = convertdata(array);
    }    
}

float convertdata(char array[])
{
float value;
int R;

    R = sscanf(&array[2], "%f", &value);
 //   printf("Value read is %f  \n\r", value);
    return value;
}


/*
int test(void)
{
    int read;
    int gotheader = false;
    pc.printf("Started\n\r");
    pc.printf("In get message\n\r");
    do
    {
       //pc.printf("Waiting\n\r");
        if (device.readable())
        {
            pc.printf("Device Readable\n\r");
            read=device.getc();
            pc.putc(read);            
        }
    }    while(gotheader == false);

}
*/

To test the function of those codes, simulated data for wind speed, wind direction and rainfall are artificially generated out which are incremented automatically. In terms of the data for temperature and pressure, they are sent from the sensor MLP 115A2. All of those data are displayed through PuTTY which are shown as below:




Having completed this, it shows that the data of temperature and pressure can be detected by sensor MLP 115A2, passed from FRDM-KL46Z to LPC1768 wirelessly and then displayed on the screen successfully. 
What remains to do is mainly processing the signal sensed by the outside wind and rain sensor and replacing the artificially generated data. 














2015年3月1日星期日

Week 4 (27th Feb 2015)

Week 4 (27th Feb 2015)
This is the forth week of the wireless weather station project.
The main progress of the lab day was divided into two parts. One was on detecting the signal types of the wind direction and wind speed and the other was programming.

  • Detect signal types

To achieve this task, the outside sensor from WH1081 is taken apart as photo shown below:

According to the photo, the above one is wind speed sensor whose inside chip is as:

There are 8 switches connected with 8 resistors in the circuits whose resistor values are measured and specified by group members. The representing circuit is shown in figure below:

In terms of the signal type that wind speed sensor sends, it has been clarified that every 120 degrees the outside jacket rotates, it would generate a digital pulse signal. It means that every time the sensor makes a round, three digital pulses will be sent.

Seen from the first photo, the sensor below is the one for wind direction whose inside chip is like:

It has been found out that there is a magnet in the shell.  Due to the magnetic connection between the shell and chip, the direction sensor has the ability to sense changes of wind direction and then generates analog signals.

  • Programming

One of the group member focused on writing the code, especially the signal receiving function. The present code is shown as below:






2015年2月21日星期六

Week 3 (20th Feb 2015)

Week 3 (20th Feb 2015)
This is the third week of our weather station project. Continuing with the task completed during the last two weeks, this week we focused on realizing XBee connection between two microcontrollers.
By following the steps listed in the reference book, one of the XBee has been configured as ZIGBEE COORDINATOR AT and the other as ZIGBEE ROUTER AT through the software of X-CTU.
Having tested with the AT commands in Tera Term, both coordinator radio and router radio have been set and checked successfully.


Then the most important feature that we have already realized is the chat between two XBees. It shows that the text which is typed in the serial terminal program on the first Tera Term display window will appear on the serial terminal screen of the second radio.

During this process, we have met several troubles. One XBee on the FRDM-KL46Z did not work for many times. Thanks to the trouble shooting steps and multiple times of tries, we have finally debugged the function and completed the task left for two weeks.
The following tasks include:
First, the signal types of the wind speed, wind direction, rainfall and temperature should be specified.
Second, the most significant task is programming.

2015年2月13日星期五

Week 2 (13th Feb 2015)

This is the second week of our weather station project. The main progress during this week include:

On Monday, we contacted our professor and realized function of letting the LPC1768 talk to XBee.

As for the following three days, we continued with testing to let FDRM-KL46Z talk to XBee. During this process, we met several difficulties in finding corresponding and efficient pins which should be wired together. We three group members got to know about software of X-CTU which is a quite useful application designed to enable developers to interact with Digi RF modules through a simple-to-use graphical interface. Moreover, what worth to be mentioned was that the reference book that we referred to is 

Building Wireless Sensor Networks: with ZigBee, XBee, Arduino, and Processing

Considering the following task of achieving data sending and receiving between FDRM-KL46Z and LPC1768 by XBees, it seems essential to consult that book as well.

On the lab day, we started with programming the overall code. Having tested several example codes, group members got command of method of displaying on the LPC1768.

In order to write the main part of the code, we planned to connect the outdoor wind and rain gauge sensor together with the FDRM-KL46Z. What we needed are 2 sockets with which the sensor can be plugged onto the breadboard.

To sum up, during this week, we mainly focused on testing and learning. Although the visible programming progress is limited, we have the confidence and determination that in the following weeks, we will be more active and efficient in the designing project.

2015年2月8日星期日

Week 1 (6th Feb 2015)


This is the first lab day of our Year 2 Project. We three group members are researching project of wireless weather station under the guidance of Professor Jeremy Smith. The project aims at designing a weather system which can detect the wind speed, wind direction, rain gauge and temperature through the sensors and then processed the data through mbed microcontrollers and then display the weather information.
During the lab day, first, we three students discussed about the general design and work out a block diagram to represent our basic idea:

We collected the required equipment including:

  • WH1081 which offers the wind and rain gauge sensors
  • Temperature and Pressure sensor
  • Mbed microcontroller FRDM-KL46Z connected with Xbee kit
  • LPC1768 with display
We started with assembling the wind and rain gauge, it has been completed as shown below:


After that, we did a little bit soldering work to realize combination of FRDM-KL46Z, XBee and SD Shield:

The most important task of our first lab day was getting familiar with the XBee and programming to realize data transferred between microcontrollers. However, because we haven't contacted to this field, we met several problems with programming. There are still a lot of research work to do about the XBee. 

In addition, we started to get familiar with the FRDM-KL46Z and LPC1768 about their functions and characteristics. We will continue our work and update our progress in time.