Embedded system is an intelligent system that has the capability of processing, monitoring and controlling. It may comprise of Sensors, Microcontrollers, FPGA, ASIC, etc. It typically has a specialized function with programs stored on ROM. Examples of embedded systems are automatic environmental systems, security systems, and entertainment systems. An added feature in any embedded system is its ability to communicate. The communication can be via Bluetooth, WI-FI, GSM, or Ethernet cables. The TCP/IP protocol is a widely used standard for modern digital communication. A weather station is a facility with instruments and equipment to make weather observations by monitoring atmospheric conditions. The project we have undertaken is “IP based Weather Station (Mausam Parisuchak)”. It includes the three concepts we discussed earlier viz. embedded systems, TCP/IP communication, and weather station. It provides real time data of weather in remote/inaccessible locations through a wireless /wired connection.

Nepal being a mountianous country it is difficult to build some development infrastructures. One of the biggest mountain ranges of the world, The Himalayas, lies in Nepal. Various organisation like ACAP, ICIMOD, and many other NGOs and GOs are working to solve this problem through sustainable tourism and natural disaster mitigation (eg:- bursting of glacier lakes, avalanche, etc). The existing weather data collection technology in Nepal is backward for example in Godawari ICIMOD is implementing data loggers which collect data and logged into the magnetic hard disk which is swept at a frequency of 48 hrs manually. Our National Meteorological Department (NMD) has manual data collection process. Sometimes this may result in the problem of unavailability of weather data at the time of necessity. Our project “IP based weather station” can play a vital by addressing to these problems and providing data which can be used for monitoring various activities. 2

Main objective of our project is to make internet/ip enabled embedded device serving as advanced remote data logger which can be accessed remotely via workstation. Our internet enabled device “alias: Mausam Parisuchak” will be interfaced with various sensors like temperature sensor, humidity sensor.

This project finds its application in various fields like Weather Forecasting Department, organizations like ICIMOD (International Center for Integrated Mountain Development), ACAP (Annapurna Conservation Area Project), etc which works on remote monitoring and development of the mountainous areas. Looking at the benefits of its technical efficiency and practical implementation along with its coverage of course materials like Telecommunication, Instrumentation, Electronic Circuits, we selected this project as our final year project. On completion of this project, our module will be used by ICIMOD at Godawari for its practical implementation.

The system designed in our project applied to monitor weather data from the remote field. The weather data is then communicated or transmitted to the central server through an Ethernet connection. The server is a web and database server which holds all the past data transmitted by the system and also servers web pages to the public internet users. The sensors we have decided to use are the Temperature and Light Dependent Sensors. They are connected to the PIC18F4620 microcontroller.


The PIC18F4620 microcontroller is used as a computer and the ENC28J60 is used to connect the microcontroller to a LAN. The LCD display and the serial port interface provide more functionality to the overall system. The LCD displays the current and any new IP address of the Ethernet chip. The serial connection is used rarely in our system like to configure our module (e.g. to change the IP address). It can also be used for debugging purposes. Thus serial connection is not so compulsory section in our project.

Fig1.1: Simplified Diagram of Component Interconnections 4



1 HARDWARE COMPONENT OVERVIEW Our project comprises of following hardware components: • Sensors o Temperature o LDR • • • • • • PIC18F4620 microcontroller ENC28J60 Ethernet chip Magnetic Ethernet jack RS232 Serial port LCD LAN connectivity 2.1. The LM35 generates a higher output voltage than thermocouples and may not require that the output voltage be amplified.1 Sensors 2. The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin.1.2. as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. and precise inherent calibration make interfacing to readout or control circuitry especially easy. etc. The sensor circuitry is sealed and not subject to oxidation. 6 .1. The LM35's low output impedance. linear output.1 Temperature sensor The LM35 is an integrated circuit sensor that can be used to measure temperature with an electrical output proportional to the temperature (in oC).

5°C accuracy guaranteeable (at +25°C) Rated for full -55° to +150°C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 µA current drain Low self-heating.1: LM35 connection circuit Features • • • • • • • • • • • Calibrated directly in ° Celsius (Centigrade) Linear + 10.08°C in still air Nonlinearity only ±¼°C typical Low impedance output.0 mV/°C scale factor 0. 0.1 Ohm for 1 mA load 7 . 0.Fig 2.

photons absorbed by the semiconductor give bound electrons enough energy to jump into the conduction band.1. It is made of a high-resistance semiconductor.2.2 LDR Fig2.4: Typical Application circuit 8 .3: Characterstics curve of LDR Fig2.2 LDR (Light Dependent Resistor) Light Dependent Resistor (LDR) also known as photoresistor is an electronic component whose resistance changes with the incident light intensity. Fig 2. The resulting free electron (and its hole partner) conduct electricity. If light falling on the device is of high enough frequency. thereby lowering resistance. The resistance of LDR may be 5000 ohm in daylight and 20000000 ohm in dark condition.1.

B. D. C.2 Microcontroller (PIC18f4620) We could have used different microcontroller such as 8051. D are of 8-bits in length but port E is of only 4-bits length. 2. E. AVR but we opted for PIC family of microcontroller. It has high memory space. C. It has built in ADC consumption during operation. It has 13 ten bits ADC channels which makes it easy for us to interface the sensors. They are A. It is developed using nanoWatt TECHNOLOGY that reduces power Fig2. It has large number of I/O pins. Port A. 2. It has the following advantages 1. We specifically choose PIC18f4620 because 1.2. B. 3.5: Pin Configuration of PIC18F4620 The PIC18f4620 has 5-ports. All these ports are in digital I/O besides A6 9 .1.

The data EEPROM. The serial data to the Ethernet chip is transmitted from C5 and received from C4.B1.D.B3.USART 13 channels 75 instruction Table 2. the data and program memories use separate busses. If pin no.A5.and A7.)4kb 1kb Ports A.E0.A1.E1. can be regarded as a peripheral device.B2.B0.A2. since it is addressed and accessed through a set of control registers.E2. for practical purposes. The serial port data to the computer is transmitted from C6 and received form C7. this allows for concurrent access of the two memory spaces.A3. The oscillator is connected to these pins. 1 is set to low the data memory of microcontroller will be reset. 10 . Features Operating frequency Program memory Temporary data memory(Ram) Permanent data memory(EEPROM) I/O Ports Serial communication 10-bits A/D Module Instruction sets PIC18F4620 DC upto 40MHz 64kb (Approx. The analog input pins are in A0.C.1: Features of PIC18f4620 There are three types of memory in PIC18 Enhanced microcontroller devices: •Program Memory •Data RAM •Data EEPROM As Harvard architecture devices.B.E MSSP.B4.

GPRs are used for data storage and scratchpad operations in the user’s application. The program memory cannot be accessed during the write or erase. allowing up to 4096 bytes of datamemory. Writing or erasing program memory will cease instruction fetches until the operation is complete. code cannot execute. Indirect or Indexed Addressing modes. 11 . therefore. These registers are implemented as static RAM. The memory space is divided into as many as 16 banks that contain 256 bytes each. which is capable of addressing a 2Mbyte program memory space. Program Memory PIC18 microcontrollers implement a 21-bit program counter.i. The data memory contains Special Function Registers (SFRs) and General Purpose Registers (GPRs). PIC18F4620 device implement all 16 banks. SFRs start at the top of data memory (FFFh) and extend downward to occupy the top half of Bank 15 (F80h to FFFh). Each Register in the data memory has a 12-bit address.6: Memory Organisation ii. The Reset vector address is at 0000h and the interrupt vector addresses are at 0008h and 0018h. An internal programming timer terminates program memory. Data Memory The data memory in PIC18 devices is implemented as static RAM. PIC18 devices have two interrupt vectors. Accessing a location between the upper boundary of the physically implemented memory and the 2-Mbyte address will return all ‘0’s (a NOP instruction). The Special Function Registers (SFRs) are registers used by the CPU and peripheral modules for controlling the desired operation of the device. PIC18F4620 have 64Kbytes of Flash memory and can store up to 32. Fig2. The entire data memory may be accessed by Direct.768 single-word instructions.

iii. The write time is controlled by an on-chip timer. Data EEPROM The data EEPROM is a nonvolatile memory array separate from the data RAM and program memory that is used for long-term storage of program data. with data rates of up to 10Mb/s. The EEPROM is readable and writable during normal operation. Communication with the host controller is implemented via two interrupt pins and the SPI. It is not directly mapped in either the register file or program memory space but is indirectly addressed through the Special Function Registers (SFRs). The ENC28J60 meets all of the IEEE 802. The ENC28J60 is a stand-alone Ethernet controller with an industry standard Serial Peripheral Interface (SPI). It is designed to serve as an Ethernet network interface for any controller equipped with SPI. With the ENC28J60. It incorporates a number of packet filtering schemes to limit incoming packets. The EEPROM data memory is rated for high erase/write cycle endurance. Thus it is easier for us to interface the two chips from microchip. The ENC28J60 does not support automatic duplex negotiation.3 Ethernet chip (ENC28J60) There are many Ethernet chip in the markets but we choose ENC28J60 because it is produced from the same manufacturer as the PIC.1.3 specifications. 2. two pulse transformers and a few passive components are all that is required to connect a microcontroller to a 10Mbps Ethernet network. If it is connected to an automatic duplex negotiation enabled network switch or Ethernet controller. it will vary with voltage and temperature as well as from chip to chip. A byte write automatically erases the location and writes the new data (erase-before-write). Two dedicated pins are used for LED link and network activity indication.The ENC28J60 is designed to operate at 25MHz with a crystal connected to the OSC1 and OSC2 pins. the 12 . It also provides an internal DMA module for fast data throughput and hardware assisted IP checksum calculations.

3.1. Supports Full and Half-Duplex modes 5.2 Ethernet Controller Block Diagram Fig2.7: Detail Overview of ENC28J60 13 . 2. Supports one 10BASE-T port with automatic polarity detection and correction 4.1 Ethernet Controller Features: 1.1. Programmable padding and CRC generation 7.3. SPI Interface with speeds up to 10Mb/s 2. To communicate in Full-Duplex mode. Programmable automatic rejection of erroneous packets 8.ENC28J60 will be detected as a half-duplex device. router or Ethernet controller) must be manually configured for full-duplex operation.3 compatible Ethernet controller 2. the ENC28J60 and the remote node (switch. Receiver and collision squelch circuit 3. Programmable automatic retransmit on collision 6. IEEE 802.

2. 5. The bus interface that interprets data and commands received via the SPI interface. 6. 7. transmit and receive blocks. 3. The device also contains other support blocks. An arbiter to control the access to the RAM buffer when requests are made from DMA. on-chip voltage regulator. Fig2. level translators to provide 5V tolerant I/Os and system control logic. such as the oscillator.8: Pin Configuration of ENC28J60 14 . The PHY (Physical Layer) module that encodes and decodes the analog data that is present on the twisted pair interface. The MAC (Medium Access Control) module that implements IEEE 802. 4. An SPI interface that serves as a communication channel between the host controller and the ENC28J60. A dual port RAM buffer for received and transmitted data packets. Control Registers which are used to control and monitor the ENC28J60.The ENC28J60 consists of seven major functional blocks: 1.3 compliant MAC logic.

The Ethernet buffer memory can only be accessed via the read buffer memory and write buffer memory. The PHY registers are used for configuration. The Control Registers are directly read and written to by the SPI interface.The Ethernet buffer contains transmit and receive memory used by the Ethernet controller in a single memory space. The sizes of the memory areas are programmable by the host controller using the SPI interface.Fig2. The registers are not directly accessible through the SPI interface. There are three types of memory in the ENC28J60: •Control Registers •Ethernet Buffer •PHY Registers The control registers’ memory contains Control Registers (CRs). 15 .9: Typical Application Circuit of Ethernet Chip All memory in the ENC28J60 is implemented as static RAM. control and status retrieval of the PHY module. control and status retrieval of the ENC28J60. These are used for configuration. they can only be accessed through the Media Independent Interface (MII) implemented in the MAC.

ESTAT. while reading the registers allows the host controller to monitor operations. The Control Register memory is partitioned into four banks. The last five locations (1Bh to 1Fh) of all banks point to a common set of registers: EIE. 16 . EIR. Control Registers The Control Registers provide the main interface between the host controller and the on-chip Ethernet controller logic. These are key registers used in controlling and monitoring the operation of the device.Fig 2. Each bank is 32bytes long and addressed by a 5-bit address value.10: Memory Organization of ENC28J60 i. ECON2 and ECON1. Writing to these registers controls the operation of the interface.

Writes to unimplemented locations are ignored and any attempts to read these locations will return ‘0’. the PHY registers are not directly accessible through the SPI control interface. access is accomplished through a special set of MAC control registers that implement a Media Independent Interface for Management (MIIM). The entire buffer is 8Kbytes. Unlike the control registers or the buffer memory. Ethernet Buffers The Ethernet buffer contains transmit and receive memory used by the Ethernet controller. divided into separate receive and transmit buffer spaces. PHY Registers The PHY registers provide configuration and control of he PHY module. There are a total of 32 PHY addresses. as well as status information about its operation.ii. The sizes and locations of ransmit and receive memory are fully programmable by the host controller using the SPI interface. only 9 locaions are implemented. iii. All reserved locations should be written as ‘0’. All PHY registers are 16 bits in width. however. their contents should be ignored when read. Instead. 17 .

2.4Magnetic Ethernet jack Magnetic Ethernet jack is a single port shielded RJ45 connector with integrated 10/100 magnetic.1. Fig 2.11: Magnetic Ethernet Jack Fig2.12: Schematics of Magnetic Ethernet Jack 18 .

FireWire.1.1. cheap and allow interoperability between devices. Serial ports are still used in these areas as they are simple.1 Serial (RS232) port interface pin out and signal RS232 DB9 pinout Fig 2. data transfer through serial ports connected the computer to devices such as terminals and various peripherals.5 Serial port interfacing A serial port is a serial communication physical interface through which information transfers in or out one bit at a time (contrast parallel port). Network equipment (such as routers and switches) often have serial ports for configuration.2.5.13: Serial (RS232) Port Interface Pin Out and Signal 19 . and some industrial and consumer products. the term "serial port" usually identifies hardware more or less compliant to the RS-232 standard. Serial ports can also be found in industrial automation systems. Such interfaces are Ethernet. Throughout most of the history of personal computers. and USB all send data as a serial stream. intended to interface with a modem or with a similar communication device. scientific analysis. 2.

one for the receive line and one for the transmit line is not required. Necessity of two chips. This is handy in many cases when we only want to use the Transmit and Receive data Lines.2 RS-232 Level Converters Almost all digital devices which we use require either TTL or CMOS logic levels. 20 .2: Showing the RS232 pin configuration and signals 2. Therefore the first step to connecting a device to the RS-232 port is to transform the RS232 levels back into 0 and 5 Volts.9 pin# Pin 3 Pin 2 Pin 7 Pin 8 Pin 6 Pin 5 Pin 1 Pin 4 Pin 9 Abbreviation TD RD RTS CTS ` DSR SG CD DTR RI Full Name Transmit Data Receive Data Request To Send Clear To Send Data Set Ready Signal Ground Carrier Detect Data Terminal Ready Ring Indicator Table 2. It includes a Charge Pump. this is done by RS-232 Level Converters.C. As we have already covered.5. also includes two receivers and two transmitters in the same package.1. This I. MAX232 is a RS232 level converter. which generates +10V and -10V from a single 5V supply.

but compared with the price of designing a new power supply it is very cheap.Fig 2. There are also many variations of these devices. 21 .15: Typical MAX-232 circuit However all this convenience comes at a price. but also expensive.14: Pin configuration of MAX232 Fig 2. The large values of capacitors are not only bulky. Therefore other devices are available which use smaller capacitors and even some with inbuilt capacitors.

2 SOFTWARE COMPONENT OVERVIEW Our project comprises of following software components: • TCP/IP Stack 22 .6 LCD A liquid crystal display (LCD) is a thin.1.3: Pin connections of LCD 2.1. flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector PIN NO.7 LAN connectivity Our device can be connected to a LAN either through a wired Ethernet cable or through a wireless Wi-Fi access point/transmitter. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 SYMBOL Vss Vcc Vee RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 LED + LED - FUNCTIONS 0 volts 5 volts Low=instruction code input High=data input High=data read Low=data write High to low =Enable signal Data bus line Table 2. 2.2.

1 TCP/IP STACK Many TCP/IP implementations follow a software architecture referred to as the “TCP/IP Reference model”. TCP/IP Reference Model Our TCP/IP Model Fig2.16: Comparing our TCP/IP Model with the TCP/IP Reference Model 23 .2. where layers are stacked on top of each other (thus the name “TCP/IP Stack”) and each layer accesses services from one or more layers directly below it. Internet Software based on this model is divided into multiple layers.• • • • C language Web/Database server PHP Proteus simulation software 2.

Like the TCP/IP reference model. is made primarily on the amount of overhead and whether a given service needs intelligent processing before it can be passed to the next layer or not.g. The size of these fields varies. many of the layers in our TCP/IP Stack directly access one or more layers which are not directly below it.2. 2. 1. MAC (Media Access Control Layer): The Ethernet hardware doesn't understand IP addresses. A network address.8).45. which identifies a subnet within that organization. but they must occupy a total of four bytes. 123. The code implementing each layer resides in a separate source file. A system address. (e.1 Stack Modules Following are some of the stack modules and API used. To identify an individual computer on the Internet. The current version of the Internet Protocol (IPv4) uses a four-byte number. 3. Unlike the TCP/IP reference model. while ARPTask manages the services of the Address Resolution Protocol (ARP) layer. 2. An additional major departure from traditional TCP/IP Stack implementation is the addition of two new modules: “StackTask” and “ARPTask”. while the services and APIs (Application Programming Interfaces) are defined through header/include files. 24 . which identifies a single node on that subnet. A decision as to when a layer would bypass its adjacent module for the services it needs. This address consists of three parts. a. depending on the size of the organization. it must have a unique address. which uniquely identifies an organization. A subnet address.1. this is generally called the media access and control (MAC) address. it has its own addressing scheme based on a unique six-byte address for each network adaptor manufactured.67.. our TCP/IP Stack divides the TCP/IP Stack into multiple layers. StackTask manages the operations of the stack and all of its modules. expressed in dotted decimal notation.

network datagram loss. there is a split: connection-oriented applications use transmission control protocol (TCP). A node sends a subnet broadcast containing the IP address that is to be resolved. Above these. It handles the network failure. It initiates a connection between two nodes and sends data bidirectionally between those two nodes. ARP & ARPTASK (Address Resolution Protocol) The IP-to-hardware address translation protocol is called address resolution protocol (ARP). TCP (Transmission Control Protocol) TCP helps to do several jobs at once. An IP packet is known as a "datagram”. and then uses HTTP to send a request. IP (Internet Protocol) The first software layer above the network drivers is IP and its partner ICMP. f. it will return an ICMP "destination unreachable" message. ICMP messages are contained within the data field of a IP datagram using IP protocol number. c. ICMP (Internet Control Message Protocol) ICMP is an adjunct to IP that gives all nodes on the network the ability to perform simple diagnostics and return error messages. HTTP (Hyper Text Transmission Protocol) HyperText Transfer Protocol (HTTP) simply involves an exchange of text messages followed by the transfer of Web data down a TCP connection. the browser opens a TCP connection to server port 80.b. To fetch a Web document. It closes the connection between those two nodes as well. and the node that matches that IP address sends a response with its hardware address. d. e. For example. Compared to TCP. if you ask a router to forward a datagram to an address it can't reach. HTTP is refreshingly simple: 25 . whereas connectionless applications use user datagram protocol (UDP).

4: Request For Comment The complete list of Internet RFCs and the associated documents are available on many Internet web sites. line feed) characters.rfc-editor. the information (document as starting points. Interested readers are referred to www. the one used to fetch documents is the get method. graphical data) is then sent down the same connection. which is closed on completion. Table2. 26 . HTTP commands are called methods.the request and response are one or more lines of text.faqs. each terminated by the newline (carriage return. If the request is and www.

5: Keywords of MCC18 The processor-specific library files contain definitions that may vary across individual members of the PIC18 family. function declaration. variable definition. 27 . and unions are similar to the ANSI C standards. pointers. strings. Software Peripheral Library.2 “C” language with MCC18 compiler The C language compiler/linker used by us was the MCC18 of microchip. constants definition. The functions included in the processor-specific libraries include Hardware Peripheral Functions and.2. structures. Some of the keywords used in the MCC18 language are shown in table. program control statements.2. arrays. The peripheral routines that are provided include both those designed to use the hardware peripherals and those that implement a peripheral interface using general purpose I/O lines. This includes all of the peripheral routines and the Special Function Register (SFR) definitions. operator’s usage. The IDE used by us was the MPLAB of microchip. _asm _endasm Auto Break Case Char Const Continue Default Do Double Return Extern Far Float For Goto If Int Long Near Ram Volatile While Short Signed Sizeof Static Struct Switch Typedef Union Unsigned Void Else Enum Table 2. Components of the C language such as comment definition.

such as ASP or ColdFusion. It is easier to code and requires less effort. Its popularity for use with web applications is closely tied to the popularity of PHP and Ruby on Rails. MySQL is popular for web applications and acts as the database component of the LAMP. and WAMP platforms (Linux/Mac/Windows-Apache-MySQLPHP/Perl/Python). 2. The MySQL server and official libraries are mostly implemented in ANSI C/ANSI C++. Web/Database server MySQL is a multithreaded. Libraries for accessing MySQL databases are available in all major programming languages with language-specific APIs. MAMP.3. an ODBC interface called MyODBC allows additional programming languages that support the ODBC interface to communicate with a MySQL database. In addition. The basic program runs as a server providing multi-user access to a number of databases. 2.2. It is inconvenient for time critical applications. It occupies more memory space. and for open-source bug tracking tools like Bugzilla. It has many built in functions Disadvantages of C language in embedded systems: 1. multi-user SQL database management system (DBMS).Advantages of C language in embedded systems: 1. 2. which is often combined with MySQL 28 .

CGI The Common Gateway Interface (CGI) is a standard protocol for interfacing external application software with an information server. Object.  if the request identifies an executable command and possibly arguments. and returns the appropriate output. Array. PHP primarily acts as a filter. run the command and return its output 29 . PHP can be deployed on most web servers and on almost every operating system and platform free of charge. it can also be used for command-line scripting and client-side GUI applications. The two simplest ways. return the contents of that file. Boolean. The PHP Group also provides the complete source code for users to build. commonly a web server. Resource PHP has a formal development manual that is maintained by the free software community. Null.2. Each time a request is received. The PHP program takes input from a file or stream containing text and special PHP instructions and outputs another stream of data for display. Double. customize and extend for their own use. String. The task of such an information server is to respond to requests (in the case of web servers. answers to many questions can often be found by doing a simple internet search. requests from client web browsers) by returning output. However. of doing this are the following:  if the request identifies a file stored on disk. for the server.4 PHP (PHP: Hypertext Preprocessor) PHP is a widely-used general-purpose server side scripting language that is especially suited for Dynamic Web development and can be embedded into HTML. In addition. the server analyzes what the request asks for. PHP generally runs on a web server.2. There are eight data types in PHP which facilitates the programmer are: Integer. taking PHP code as its input and creating Web pages as output.

The data are stored in the MySQL database. and how the command can pass back extra information about the output (such as the type) in the form of headers. It defines how information about the server and the request is passed to the command in the form of arguments and environment variables. The information regarding physical parameters is sensed from the sensor.CGI defines a standard way of doing the second. Whenever a request to a matching URL is received. and sent back to the client. Finally the required graphical representation of the data can be displayed interactively in the website. 30 . with any data that the client sent as input. This is received by microcontroller and is stored in CGI variables. augmented with appropriate headers as defined by the CGI spec. Output from the program is collected by the Web server. the corresponding program is called. These CGI variables can be accessed by CGI scripts running in web/database server.

If one person designs both the hardware and the software then that person benefits as the hardware design may be changed just as easily as the software for The Proteus Design Suite is wholly unique in offering the ability to co-simulate both high and low-level micro-controller code in the context of a mixed-mode SPICE circuit simulation. quality and flexibility throughout the design process.5 Proteus: Simulation Software Proteus is circuit simulation software. 31 . there is no need for them to wait until a physical prototype exists. In larger organisations where the two roles are seperated. The unique nature of schematic based microcontroller simulation with Proteus facilitates rapid. Proteus consists of 2 major software parts. They are ISIS and ARES. test and virtually prototype our embedded system designs based around the Microchip Technologies PIC18.2. Its demo version can be downloaded from www. the software designers can begin work as soon as the schematic is completed. In short. flexible and parallel development of both the system hardware and the system firmware. Proteus VSM improves efficiency.2. Proteus VSM for PIC18 contains everything we need to develop. ISIS is a simulation package whereas ARES is a PCB making package. In this software we simulated most of our project circuits and codes including the ENC28J60 and PIC18F4620 interconnection and the C language code.


1 HARDWARE DESIGN IMPLEMENTATION PIC Programmer Circuit Fig3. Then we started to deal with PIC18F4620.html) For loading the . etc. Then we stepped toward sensor interfacing and Ethernet interfacing. Finally we got above circuit. But all circuits failed.3.1: Complete Circuit Diagram of the PIC18 Programmer (Ref: http://www. We did some basic programs like LED blinking. which worked fine. LCD display. It was really great to find the programmer circuit working fine. 33 .HEX file in the PIC we used the provided P18 software.1. ADC port programming.ucapps. We searched for various programmers circuits and designed in breadboard.

2 Sensor interfacing Fig3. 34 . The PIC18F4620 then changes the analog data to 10 bits and stores it in it’s registers ADRESH:ADRESL which will contain the value of the last completed conversion.1. Only then is the data from the sensor considered to be valid. As we know the PIC18F4620 has 13 analog pins which can also function as digital I/O.3.2: Sensor Interfacing with PIC18F4620 LM 35 is connected to the analog port of the PIC18F4620 microcontroller. the PIC18F4620 must first be configured to accept analog data on the specified pins. Before the sensor is connected to one of these pins.

3. 35 . The LCD we used in this project was JHD162A series from ETC corporation.1.3: LCD Interfacing with PIC18F4620 The MCC18 functions are designed to allow the control of a Hitachi HD44780 LCD controller using I/O pins from a PIC18 microcontroller. The LCD could be used in 4 bit or 8 bit mode. The 4 bit mode saves pins in the microcontroller but requires more processing time and makes the pic18f4620 slower for other functions.3 LCD interfacing Fig3. We used the LCD to display the IP address of the microcontroller and the current sensor value. Thus we used the 8 bit mode.

} 36 .4: Serial Interfacing with PIC18F4620 The PIC18F4620 has 2 serial ports modules the USART (Universal synchronous and asynchronous receiver and transmitter) and the MSSP (master synchronous serial port) module. We used the USART module for interfacing with the RS232 port of the computer.h> void main(void) { // configure USART OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH. //wait for RA0 high WriteUSART( PORTD ). 25 ).RA0 ). while(1) { while( ! PORTAbits.h> #include <usart.1. //write value of PORTD if(PORTD == 0x80) // check for termination break. // value } CloseUSART().4 RS-232 interfacing Fig3. The computer is used only for debugging purposes and is not totally necessary for operation of the weather box.3. #include <p18f4620.

3.5 Ethernet chip interfacing Fig3. The INT pin of the ethernet chip is conencted to the INT0 of PIC18F4620 and the WOL pin is connected to the INT1 pin of PIC18F4620. 37 . with data rates of up to 10Mb/s. The following pins are also used: SCK = Serial Clock SI SO = Serial In = Serial Out INT = Interrupt (general) WOL = Interrupt (Wake On LAN) The INT and WOL pins are used to interrupt the microcontroller from the ethernet chip. Two dedicated pins are used for LED link and network activity indication.1.5: Interfacing ethernet chip Communication with the host controller is implemented via two interrupt pins and the SPI.

6: Schematic Diagram of PIC Interfacing (Designed using Proteus v. The LCD and the computer connected through the RS 232 is not needed for the operation of the device.1. The ethernet chip is connected to the ethernet cable by a RJ45 with magnetics included and a ferrite bead to reduce high frequency EM interference.6 Complete Circuit Design Fig3.1) The 2 LEDs are added in the ENC28J60 for debugging purposes.3V CMOS level. The green LED signifies that a network conenction is available and the red led indicates that the network is ready to accept and transmit messages and packets. The sensor is connected to the ANO and AN1 pins. 3. 38 .7.We performed level conversion because the microcontroller operates at 5V TTL level while the ethernet chip operates at 3. The level conversion was done using 74HCT08 (quad AND gate).

39 . in addition to its own work such as RS-232. Once StackInit( ) is called. This module is implemented by the source file “StackTsk. it polls the MAC layer for valid data packets. when given processing time. TCP. When one is received. It is important to note that Stack Manager is not an integral part of our TCP/IP Stack. It is written so that the main application does not have to manage stack modules. Some modules (such as IP. our TCP/IP Stack uses a special application layer module known as “StackTask”. to ensure that all incoming packets are handled on time. and Sensor interfacing. Before the Stack Manager task can be put to work.3.c”. StackTask is implemented as a cooperative task.1 TCP/IP Implementation Our stack is a collection of different modules. along with any time-out and error condition handling. the main application must call the StackTask( ) function periodically. it must be initialized by calling the StackInit( ) function.2. it decodes it and routes it to the appropriate module for further processing.2 SOFTWARE DESIGN IMPLEMENTATION 3. or the Stack Manager. In order to relieve the main application from the burden of managing the individual modules. regardless of main application logic. This function initializes the Stack Manager variables and individual modules in the correct order. LCD. Any application utilizing our stack must perform certain steps to ensure that modules are called at the appropriate times. This task of managing stack modules remains the same. UDP and ICMP) must be called when a corresponding packet is received.

ARP. UDP. TCP. The absence of DHCP implementation in our project causes the IP address of the microcontroller to be fixed and unable to be changed by the network server. The FTP. DHCP and other protocols such as SLIP are not supported. If a data packet received then Get data packet protocol type If packet type is IP then Fetch IP header of packet Get IP packet type If IP packet type is ICMP then Call ICMP module Else if IP packet type is TCP then Call TCP module Else if IP packet type is UDP then Call UDP module Else Handle not supported protocol End If End If Else if packet type is ARP then Call ARP module End If Thus the protocols supported by our project are MAC. IP.The exact steps used by StackTask are shown in the algorithm below. ICMP. 40 . and HTTP.

If frame type is ICMP (say). The status of SM gets changed to either ARP or IP. If IP then status is changed to ICMP and SM enters into ICMP module.7: Flow chart of TCP/IP Implementation (For ICMP only) First of all SM is set to idle. then the SM enters ICMP module. Then the SM enters in the MAC module. to handle the ICMP task. If SM=ICMP. then SM is changed to ICMP (say). Again frame type is checked. SM=ARP SM=TCP SM= Stack Manager FT = Frame Type Fig 3. Then the frame type is checked if that of ARP or IP.For example the stack manager operations concerning the ICMP packets transmission and reception is shown and described below. 41 .

Firstly we read the whole contents of the file and stored it in a string. with data transfer rate set to be 10Mbps in half duplex mode equally worked. it can definitely be accessed through the internet. stored in our module.168. Now the challenging task was to send a request to our module at a constant interval. both connected to same router.2Web/Database Server Our module is an IP enabled device. retrieve the data. and show a graphical representation of data according to the request at the time of request. The page “status. The second problem of retrieving of data was done using the string operation. Also connecting these two via a lab link cable or the cross wire cable. There was code in that very same page which would read the CGI page. For our demonstration purpose we assign IP of our module to be 192. Then using few string operations.cgi” in our module was written in such a way that we have kept certain tokens that would help to extract the required readings from the total contents of file. where X is any value in between 1 to 255 but not equal to 5).11.11. Now if a public IP if provided to it. the readings were retrieved and stored in variables for further processing.X. 42 . the essence of a Web/database server is inevitable.2. The first problem of repeated query to our module at a constant interval was solved using the META tag in the PHP page which sends a request to our module. But being an eight bit microcontroller it would not be able to serve thousands of possible requests from the public domain. Now for our demonstration purpose we called our page at an interval of one minute. META tag was in such a way that it recursively called the page itself.3.5 and the IP of the central web/database server was assigned to be 192. taking into consideration of the token we have kept. store it in a managed way.cgi”.2 (192.168. In order to address this problem and to manage readings of different weather variables.168.11. Also any hacker wanting to crash our system can generate large no of requests that our module cannot handle. “status.

And along with the weather readings. which in turns leads to calculate the average reading of that day from the ‘hour’ table and store in the day table where field are only ‘year’. ‘month’. it would be definitely be an idiotic task. The value of minute to be 00 indicates that the hour has been incremented by one. the value of hour to be 00 indicated the change of day. in such a way that ‘year’. So. For the purpose of plotting of graph we use gd_2 library of PHP. weather variables. ‘day’. This finally led us to have proper data which is to be used to show the proper graph as requested by user in the public domain. The sample of user interface and the graph plotted using random data for temperature is as shown in the ‘fig e’ and ‘fig f’ respectively. ‘month’ and ‘day’ including the weather variables. if we were to average the data at the fly time (request time). Now in order to address this problem what we did was we created five tables. these were also stored in the table. At that very instant we would read the last 60 rows of data from the main table in order to calculate the average value of the readings of that particular hour and then store it in the new table where the minute field is not present as it was in the main table. Before storing we also need to consider the time at which the reading has been taken. at the place where our module is kept for monitoring. When the data was being written in the main table. From this function we extracted all these fields and stored it in different variables. 43 . The main challenging task was to represent the data as according to the user request. In the similar manner two more tables for month and year were also maintained. Here users can send requests to view the plot in an hourly basis or daily basis as well. Usage of the function was to be done in proper consent. Similarly. Last but not least we need to represent those data in the graphical format. ‘date( )’. ‘hour’ and ‘minute’ were also the field of table. Here for each reading to be plotted we need to average 525600(=365*24*60) readings because we were taking readings at an interval of one minute. For that we use the built in function of PHP. Let’s say a user requested to view the average temperature on a yearly basis in order to have an idea of impact of global warming. we were checking the values of the ‘date’ parameters. For that as mentioned we use MySQL database.Third problem was to store the retrieved value in a manageable way. We were storing the retrieved data.


Design (Simulation and Hardware).1: Gantt chart: “IP Based Weather Station: Mausam Parisuchak” 2007-2008 4.25 8.IOE 1 Table 4. The Gantt chart of our project is shown below.1 PROJECT TIMELINE The project passed through all the phases: Research.1 4.22 ENC28J60 J1006FOIT PIC18F4620 HD7740 family Resistors.00 7.25 6.25 6.75 4.1: Financial Details of Hardware Requirements for single module (1$=63 NRS) 45 . OCT Events / Time Research & Analysis Sponsorship Material Order Simulation 7Design Hardware Design Testing & Maintenance Documentation (115) OCT (1530) NOV (115) NOV (1530) DEC (115) DEC (1530) JAN (115) JAN (1530) FEB (115) Fig4.2 PROJECT COST ANALYSIS s/n 1 2 3 4 5 6 Hardware requirements Sensors a.47 10 38.50 0.00 7.25 8.47 Total $ 1. LDR Ethernet Controller RJ45 JACK Microcontroller LCD Miscellaneous Specifications LM35 Quantity 1 1 1 1 1 1 Rate $ 1. TOTAL MODULE COST 6 Wi-Fi transreceiver From ICIMOD 1 7 PV panels From CES.50 0.75 4.etc. Analysis. Testing and Maintenance and Documentation.buffers. Temperature Sensor b.

400 /. 46 .NRs.Thus the total weather module cost is approximately 2.

our project can be used to monitor different physical parameters which in turns help to analyse the performance to different 47 . It also provides references for futher experiments as data are kept in the managed way in the modern databse. and thus can be implemented as Advanced Remote Data Logger. Where sensing and recording of data are done automatically and also that the data are tabulated properly in modern database system () which further enhances the usability of data recorded.4 APPLICATIONS OF THE PROJECT With the advancement of today’s technology only logging of data is not sufficient. This is what incorporated in our project. With the addition of many weather sensors. it can give the data of various parameters. Temperature and humidity monitoring in airport is also an important and critical task where too our project can be utilized.4. Solar Panel can be added on our module so that it can behave as independent unit and can be mounted in the remote area without any external power supply.3 FUTURE ENHANCEMENTS This project is flexible and efficient for the proper remote monitoring of the remote area. But the availability of data in the usable form for the real time application is most important. 4. In the industrial plants as well. In botanical studies for example in the green house the regular monitoring of data is an important and tidious task and with aid of our project this can be done quite easily and efficiently. With the feature of real time avialability our aim is to provide the unmanned weather station.

sophisticated machines and also predefined premitive measures can be carried out to prevent disasters. This was the problem we faced when we chose to implement a web server in a microcontroller. For the solution of this problem we decided to search for the places where our project could be implemented and that we could get mutual benifits. it is easy to be paved. ICIMOD was the organisation toward whom we should be grateful for reliefing us from entangling in such a mess by providing us supports and encouragements. For days we searched in the library for a similar project being undertaken by our seniors but could not get a single one. And also that we cannot complain the manufacturer if we received any damaged piece. We need to order components by keeping adequate time margin that we have enough time for succesful completion of our project. Small variations of weather parameters for small period can contain vital information thus implementing our project help to address those types of cases as well. Here we receive the nightmare of problems. We also need to work hard on getting appropriate programmers.5 PROBLEMS FACED Where there is a gravel road. but if there is no road. With dedicated hard work and 48 . Next step in our project was to select the adequate hardware. Some major components of our project were not avialable in the local market so we needed to get them from the manufacturers abroad. because in course of our working process the probability of getting components damaged cannot be ignored. 4. is even more difficult. Also the cost of attaining each component was far too behind our budget as we need to get more than one complete set of components. Time was another important factor. then to construct a paved road. Knowing different weather parameters of climate of Snowy Mountain is an essential factor for development of mountain tourism in the country like Nepal. Since PIC18F series was unfamiliar to our friends and seniors as well.

49 . twisted pair cable.3V to 5V logic shifter. we have to take care of voltage level conversion in our design which is taken care by using AND gate as 3.Thus we can say gradual debugging and reconnenting components taking in account of knowledge gain in the course of instrumentation II really become a fruitfull. On successful completion of the design on Proteus Simulation we implemented the design in the hardware. For this we used ferrite bead. Since our Ethernet chip worked at 3. Though simulation helps in providing a dirction to a project but never is an exact relica of overall project. The code for microcontroller was to be written using C language. So we need to have proper simulation software for that purpose. decoupling capacitors. we also need to consider high frequency design as well. But to get the relevent and reliable simulation software which provide the facility of simulating our components and that to free was really a tough job. But newer release of proteus solved our problem. On the course of hardware design we faced various problems.searching procedures we were able to accumulate a couple programmer circuits schematics but could not get a working one on our table. But eventually we got one. Directly testing our codes on the hardware module could result in the devastating effects.3 V and PIC18F4620 at 5V. For days we get frustrated as our task use to be done on the simulation but not on the hardware. proper alignement of active and passive components etc. Since we need to work at higher frequency 20 MHz. But the working environment of MPLAB was quite different and we do need to work hard to get familiarize with.

This module finds its practical implementation in the remote mountainous area of Nepal which can provide data through the internet either by a series of microwave links or satellite links. 50 . the microcontroller. We would also like to thank the teachers and our supervisors for providing us the needed support. and a weather station. We would like to thank all those who have supported us. Finally the support of ICIMOD is also highly appreciated.6 CONCLUSION The project entitled “IP based weather station: MAUSAM PARISUCHAK” undertaken by us consists of 3 major portions: the sensors. TCP/IP communication. and the Ethernet chip which is used to connect to a LAN. The module built in our project acts as a web server and displays the sensor data in the form of web pages.4. It provides real time data of weather in remote/inaccessible locations through a wireless /wired connection. It includes the 3 concepts: embedded systems.

microchip. www.REFERENCES www.Web servers for Embedded Systems by Jeremy Bentham 4. TCP/IP lean. Microprocessors and Interfacing by Douglas V Hall and many more blogs 51 2.

ANNEX Fig a: Snapshot of Simulation on Proteus 52 .

Fig b: Snapshot of C Programming in MPLAB IDE 53 .

Fig c: Snapshot of the Project Work done in ProtoBoard 54 .

Fig d: Snapshot of the PIC Programmer built in ProtoBoard 55 .

Fig e: Interface designed in PHP for the public domain users Fig f: Graph designed in PHP for public domain users as per request. Note: this graph is created from random data 56 .

Fig g: Our module in PCB 57 .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times