Several articles about water-level controllers for overhead tanks have been published in earlier issues of EFY magazine. But the project we are going to share today is new and unique. So presented here is a Web-based water-level monitor and motor-pump controller using ATmega128 microcontroller, Ethernet controller ENC28J60 and TCP-IP protocol. The design involves the use of port-forwarding facility of broadband modem or router. By using this facility, one can port forward a local IP address to a public IP address with which controlling appliances from any part of the world through the Web becomes possible. The authors’ prototype is shown in Fig. 1. Five water-level sensors are used to monitor the water levels in the overhead tank via Web browser.

Fig. 1: Authors’ prototype of web-based water-level monitor and pump controller
Fig. 1: Authors’ prototype of web-based water-level monitor and pump controller

Circuit and working

3CB_PartsThe circuit diagram of the Web-based water-level monitor and pump controller is shown in Fig. 2. The circuit is built around microcontroller ATmega128 (IC1), Ethernet controller ENC28J60 (IC2), a sensor circuit and 16×2 LCD display.

ATmega128. ATmega128 microcontroller of AVR family is chosen for the design as it is inexpensive and has sufficient memory to carry out the necessary tasks. ATmega128 has 128k Flash memory, 4k EEPROM and 4k SRAM. It is available in 64-pin TQFP package and has SPI hardware. Even though it is not difficult to solder 64-pin TQFP package, off-the-shelf available ATmega128 module (Fig. 3) is used to speed up the design process.

The code is written in C and compiled using AVR-GCC to fit into the memory size of ATmega128. The HTML code is put into program memory of ATmega128; therefore the use of external EEPROM is avoided.

ENC28J60 module. ENC28J60 Ethernet controller from Microchip is a low-cost and easy-to-handle IC since it comes with a 28-pin DIP package having a serial peripheral interface (SPI) bus. A number of Ethernet controllers are available in the market but Microchip Ethernet controller is easy to integrate with any other controller. It operates at 3.3V power supply and is readily available in the market. Details of the driver and its functions are provided in the Microchip TCP/IP stack section of http://www.microchip.com website. The driver functions have been implemented in this design after careful study.

SPI communication. ATmega128 microcontroller is chosen as master and ENC28J60 as slave for the SPI communication. FOSC/2 clock mode is chosen by properly setting SPSR register in the microcontroller. Since ENC28J60 operates at 3.3V power supply, it is necessary to use a proper level shifter/buffer in the SPI bus when it is interfaced with a microcontroller operating at 5V supply.

BB7_Table AZE_Table_2

The LCD is operated in 4-line mode. Port pins PD4 through PD7 of IC1 are used as data lines. Pins PD1, PD2 and PB6 serve as control lines for the LCD display. Pin PD0 acts as chip select pin for IC2. Pins PB1 and PB2 are connected to SCK and SI pin of IC2, respectively. Pin PB3 is connected to SO pin of IC2 via level shifter IC3 to maintain proper TTL level since IC2 is operated at a 3.3V power supply. The INT pin of IC2 is not used. We have used 74HCT125 as the level-shifter-interface IC between the microcontroller and the Ethernet controller. A 16MHz crystal is used as the external clock source for the microcontroller. A TYCO magnetic jack is used to establish connections between Ethernet controller IC2 and PC using RJ45 connectors.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here