Professional Documents
Culture Documents
Iot Based Irrigation System
Iot Based Irrigation System
ABSTRACT
CHAPTER1. INTRODUCTION
1.1 Introduction
1.2 Block Diagram
2.1 LPC2103
2.1.1 Introduction
2.1.2 Features
2.1.3 Applications
2.1.4 Architectural Overview
2.1.5 Block Diagram
2.1.6 Pin Description Of LPC2103
2.1.7 GPIO
2.3 LCD
2.4 SOIL SENSOR
2.5 RELAY
2.6 MOTOR
2.7 ESP8266
4.1 Introduction
4.1 Tools used
4.1 C51 Compiler & A51 macro assembler
4.1 Start µ vision
ABSTRACT
In the field of agriculture, use of proper method of irrigation is important because the main
reason is the lack of rains & scarcity of land reservoir water. The continuous extraction of water from
earth is reducing the water level due to which lot of land is coming slowly in the zones of un-irrigated
land. Another very important reason of this is due to unplanned use of water due to which a significant
amount of water goes waste. For this purpose; we use this automatic plant irrigation system. The
system derives power from solar energy through photo-voltaic cells. Hence, dependency on erratic
commercial power is not required.
In this project we use solar energy which is used to operate the irrigation pump. The circuit
comprises of sensor parts built using op-amp IC. Op-amp’s are configured here as a comparator. Two
stiff copper wires are inserted in the soil to sense whether the soil is wet or dry. A microcontroller is
used to control the whole system by monitoring the sensors and when sensors sense dry condition of
soil, then the microcontroller will send command to relay driver IC the contacts of which are used to
switch on the motor and it will switch off the motor when the soil is in wet condition. The
microcontroller does the above job as it receives the signal from the sensors through the output of the
comparator, and these signals operate under the control of software which is stored in ROM of the
microcontroller. The condition of the pump i.e., ON/OFF is displayed on a 16X2 LCD which is
interfaced to the microcontroller. Further the project can be enhanced by interfacing it with a GSM
modem to gain control over the switching operation of the motor.
CHAPTER1. INTRODUCTION
1.1 INTRODUCTION
LCD
SOIL SENSOR
Lpc2103
RELAY MOTOR
ESP8266
2.1 LPC2103
1. General description
Due to their tiny size and low power consumption, the LPC2101/2102/2103 are ideal
for applications where miniaturization is a key requirement. A blend of serial communications
interfaces ranging from multiple UARTs, SPI to SSP and two I 2C-buses, combined with on-
chip SRAM of 2 kB/4 kB/8 kB, make these devices very well suited for communication
gateways and protocol converters. The superior performance also makes these devices suitable
for use as math coprocessors. Various 32-bit and 16-bit timers, an improved 10-bit ADC,
PWM features through output match on all timers, and 32 fast GPIO lines with up to nine edge
or level sensitive external interrupt pins make these microcontrollers particularly suitable for
industrial control and medical systems.
2. Features
Key features
16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP48 package.
2 kB/4 kB/8 kB of on-chip static RAM and 8 kB/16 kB/32 kB of on-chip ßash program
memory. 128-bit wide interface/accelerator enables high-speed 70 MHz operation.
ISP/IAP via on-chip bootloader software. Single ßash sector or full chip erase in
100 ms and programming of 256 bytes in 1 ms.
The 10-bit A/D converter provides eight analog inputs, with conversion times as low as
2.44 s per channel and dedicated result registers to minimize interrupt overhead.
Two 32-bit timers/external event counters with combined seven capture and seven
compare channels.
Two 16-bit timers/external event counters with combined three capture and seven
compare channels.
Low power Real-Time Clock (RTC) with independent power and dedicated 32 kHz
clock input.
Multiple serial interfaces including two UARTs (16C550), two Fast I2C-buses
(400 kbit/s), SPI and SSP with buffering and variable data length capabilities.
70 MHz maximum CPU clock available from programmable on-chip PLL with a possible
input frequency of 10 MHz to 25 MHz and a settling time of 100 s.
On-chip integrated oscillator operates with an external crystal in the range from 1 MHz to
25 MHz.
Power saving modes include Idle mode, Power-down mode with RTC active, and Power-
down mode.
XTAL2 V V
TMS TDI DD(3V3) DD(1V8)
V
TRST TCK TDO XTAL1 RST SS
LPC2101/2102/2103 TEST/DEBUG
INTERFACE
system
INTERRUPT
VECTORED
AMBA AHB
INTERNAL
SRAM
MEMORY
ACCELERATOR
CONTROLLER
APB (ARM
peripheral bus) 2 (1)
EINT2 to EXTERNAL I C-BUS SERIAL SCL0, SCL1
(1)
EINT0 INTERRUPTS INTERFACES 0 AND 1 (1)
(1) SDA0, SDA1
3 CAP0
(1)
4 CAP1
(1) CAPTURE/COMPARE (1)
3 CAP2 SCK0, SCK1
3 MAT0
(1) EXTERNAL COUNTER SPI AND SSP (1)
(1) TIMER 0/TIMER 1/ MOSI0, MOSI1
4 MAT1 SERIAL INTERFACES
(1) TIMER 2/TIMER 3 (1)
3 MAT2 MISO0, MISO1
(1)
4 MAT3 (1)
SSEL0, SSEL1
(1)
AD0[7:0] ADC UART0/UART1 TXD0, TXD1
(1)
RXD0, RXD1
DSR1, CTS1,
RTS1, DTR1
DCD1, RI1
GENERAL RTXC1
P0[31:0] REAL-TIME CLOCK RTXC2
PURPOSE I/O
VBAT
WATCHDOG
SYSTEM CONTROL
TIMER
002aab814
5.2 Pin description
Table 3:Pin description
Symbol LQFP48 PLCC44 Type Description
P0.0 to P0.31 I/O Port 0: Port 0 is a 32-bit I/O port with individual direction
controls for each bit. A total of 31 pins of the Port 0 can be
used as general purpose bidirectional digital I/Os while P0.31
is an output only pin. The operation of port 0 pins depends
upon the pin function selected via the pin connect block.
P0.0/TXD0/ 13 [1] 18 [1] I/O P0.0 Ñ General purpose Input/output digital pin (GPIO).
MAT3.1 O TXD0 Ñ Transmitter output for UART0.
O MAT3.1 Ñ PWM output 1 for Timer 3.
P0.1/RXD0/ 14 [2] 19 [2] I/O P0.1 Ñ General purpose Input/output digital pin (GPIO).
MAT3.2 I RXD0 Ñ Receiver input for UART0.
O MAT3.2 Ñ PWM output 2 for Timer 3.
P0.2/SCL0/ 18 [3] 22 [3] I/O P0.2 Ñ General purpose Input/output digital pin (GPIO).
2
CAP0.0 I/O SCL0 Ñ I C0 clock Input/output. Open-drain output (for
2
I C-bus compliance).
I CAP0.0 Ñ Capture input for Timer 0, channel 0.
P0.3/SDA0/ 21 [3] 25 [3] I/O P0.3 Ñ General purpose Input/output digital pin (GPIO).
2
MAT0.0 I/O SDA0 Ñ I C0 data input/output. Open-drain output (for
2
I C-bus compliance).
O MAT0.0 Ñ PWM output for Timer 0, channel 0.
P0.4/SCK0/ 22 [4] 26 [4] I/O P0.4 Ñ General purpose Input/output digital pin (GPIO).
CAP0.1 I/O SCK0 Ñ Serial clock for SPI0. SPI clock output from master
or input to slave.
I CAP0.1 Ñ Capture input for Timer 0, channel 1.
P0.5/MISO0/ 23 [4] 27 [4] I/O P0.5 Ñ General purpose Input/output digital pin (GPIO).
MAT0.1 I/O MISO0 Ñ Master In Slave OUT for SPI0. Data input to SPI
master or data output from SPI slave.
O MAT0.1 Ñ PWM output for Timer 0, channel 1.
P0.6/MOSI0/ 24 [4] 28 [4] I/O P0.6 Ñ General purpose Input/output digital pin (GPIO).
CAP0.2 I/O MOSI0 Ñ Master Out Slave In for SPI0. Data output from SPI
master or data input to SPI slave.
I CAP0.2 Ñ Capture input for Timer 0, channel 2.
P0.7/SSEL0/ 28 [2] 31 [2] I/O P0.7 Ñ General purpose Input/output digital pin (GPIO).
MAT2.0 I SSEL0 Ñ Slave Select for SPI0. Selects the SPI interface as
a slave.
O MAT2.0 Ñ PWM output for Timer 2, channel 0.
P0.8/TXD1/ 29 [4] 32 [4] I/O P0.8 Ñ General purpose Input/output digital pin (GPIO).
MAT2.1 O TXD1 Ñ Transmitter output for UART1.
O MAT2.1 Ñ PWM output for Timer 2, channel 1.
P0.9/RXD1/ 30 [2] 33 [2] I/O P0.9 Ñ General purpose Input/output digital pin (GPIO).
MAT2.2 I RXD1 Ñ Receiver input for UART1.
O MAT2.2 Ñ PWM output for Timer 2, channel 2.
Table 3:Pin description
Symbol LQFP48 PLCC44 Type Description
P0.10/RTS1/ 35 [4] 38 [4] I/O P0.10 Ñ General purpose Input/output digital pin (GPIO).
CAP1.0/AD0.3 O RTS1 Ñ Request to Send output for UART1.
I CAP1.0 Ñ Capture input for Timer 1, channel 0.
I AD0.3 Ñ ADC 0, input 3.
P0.11/CTS1/ 36 [3] 39 [3] I/O P0.11 Ñ General purpose Input/output digital pin (GPIO).
CAP1.1/AD0.4 I CTS1 Ñ Clear to Send input for UART1.
I CAP1.1 Ñ Capture input for Timer 1, channel 1.
I AD0.4 Ñ ADC 0, input 4.
P0.12/DSR1/ 37 [4] 40 [4] I/O P0.12 Ñ General purpose Input/output digital pin (GPIO).
MAT1.0/AD0.5 I DSR1 Ñ Data Set Ready input for UART1.
O MAT1.0 Ñ PWM output for Timer 1, channel 0.
I AD0.5 Ñ ADC 0, input 5.
P0.13/DTR1/ 41 [4] 43 [4] I/O P0.13 Ñ General purpose Input/output digital pin (GPIO).
MAT1.1 O DTR1 Ñ Data Terminal Ready output for UART1.
O MAT1.1 Ñ PWM output for Timer 1, channel 1.
P0.14/DCD1/ 44 [3] 2 [3] I/O P0.14 Ñ General purpose Input/output digital pin (GPIO).
SCK1/EINT1 I DCD1 Ñ Data Carrier Detect input for UART1.
I/O SCK1 Ñ Serial Clock for SPI1. SPI clock output from master
or input to slave.
I EINT1 Ñ External interrupt 1 input.
P0.15/RI1/ 45 [4] 3 [4] I/O P0.15 Ñ General purpose Input/output digital pin (GPIO).
EINT2 I RI1 Ñ Ring Indicator input for UART1.
I EINT2 Ñ External interrupt 2 input.
P0.16/EINT0/ 46 [2] 4 [2] I/O P0.16 Ñ General purpose Input/output digital pin (GPIO).
MAT0.2 I EINT0 Ñ External interrupt 0 input.
O MAT0.2 Ñ PWM output for Timer 0, channel 2.
P0.17/CAP1.2/ 47 [1] 5 [1] I/O P0.17 Ñ General purpose Input/output digital pin (GPIO).
SCL1 I CAP1.2 Ñ Capture input for Timer 1, channel 2.
2
I/O SCL1 Ñ I C1 clock Input/output. Open-drain output (for
2
I C-bus compliance).
P0.18/CAP1.3/ 48 [1] 6 [1] I/O P0.18 Ñ General purpose Input/output digital pin (GPIO).
SDA1 I CAP1.3 Ñ Capture input for Timer 1, channel 3.
2
I/O SDA1 Ñ I C1 data Input/output. Open-drain output (for
2
I C-bus compliance).
P0.19/MAT1.2/ 1 [1] 7 [1] I/O P0.19 Ñ General purpose Input/output digital pin (GPIO).
MISO1 O MAT1.2 Ñ PWM output for Timer 1, channel 2.
I/O MISO1 Ñ Master In Slave Out for SSP. Data input to SPI
master or data output from SSP slave.
P0.20/MAT1.3/ 2 [2] 8 [2] I/O P0.20 Ñ General purpose Input/output digital pin (GPIO).
MOSI1 O MAT1.3 Ñ PWM output for Timer 1, channel 3.
I/O MOSI1 Ñ Master Out Slave for SSP. Data output from SSP
master or data input to SSP slave.
Table 3:Pin description
Symbol LQFP48 PLCC44 Type Description
P0.21/SSEL1/ 3 [4] 9 [4] I/O P0.21 Ñ General purpose Input/output digital pin (GPIO).
MAT3.0 I SSEL1 Ñ Slave Select for SPI1. Selects the SPI interface as
a slave.
O MAT3.0 Ñ PWM output for Timer 3, channel 0.
P0.22/AD0.0 32 [4] 35 [4] I/O P0.22 Ñ General purpose Input/output digital pin (GPIO).
I AD0.0 Ñ ADC 0, input 0.
P0.23/AD0.1 33 [1] 36 [1] I/O P0.23 Ñ General purpose Input/output digital pin (GPIO).
I AD0.1 Ñ ADC 0, input 1.
P0.24/AD0.2 34 [1] 37 [1] I/O P0.24 Ñ General purpose Input/output digital pin (GPIO).
I AD0.2 Ñ ADC 0, input 2.
P0.25/AD0.6 38 [1] 41 [1] I/O P0.25 Ñ General purpose Input/output digital pin (GPIO).
I AD0.6 Ñ ADC 0, input 6.
P0.26/AD0.7 39 [1] n.c. I/O P0.26 Ñ General purpose Input/output digital pin (GPIO).
I AD0.7 Ñ ADC 0, input 7.
P0.27/TRST/ 8 [4] 13 [4] I/O P0.27 Ñ General purpose Input/output digital pin (GPIO).
CAP2.0 I TRST Ñ Test Reset for JTAG interface.
[1] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew rate
control.
[2] 5 V tolerant pad providing digital I/O functions with TTL levels and hysteresis and 10 ns slew
rate control. If conÞgured for an input function, this pad utilizes built-in glitch Þlter that blocks
pulses shorter than 3 ns.
[3] Open-drain 5 V tolerant digital I/O I2C-bus 400 kHz speciÞcation compatible pad. It requires
external pull-up to provide an output functionality.
[4] 5 V tolerant pad providing digital I/O (with TTL levels and hysteresis and 10 ns slew rate control)
and analog input function. If conÞgured for an input function, this pad utilizes built-in glitch Þlter
that blocks pulses shorter than 3 ns. When conÞgured as an ADC input, digital section of the pad
is disabled.
[5] Pad provides special analog functionality.
6. Functional description
Architectural overview
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high
performance and very low power consumption. The ARM architecture is based on Reduced
Instruction Set Computer (RISC) principles, and the instruction set and related decode
mechanism are much simpler than those of microprogrammed Complex Instruction Set
Computers (CISC). This simplicity results in a high instruction throughput and impressive
real-time interrupt response from a small and cost-effective processor core.
Pipeline techniques are employed so that all parts of the processing and
memory systems can operate continuously. Typically, while one instruction is being
executed, its successor is being decoded, and a third instruction is being fetched from
memory.
The ARM7TDMI-S processor also employs a unique architectural
strategy known as Thumb, which makes it ideally suited to high-volume applications with
memory restrictions, or applications where code density is an issue.
The key idea behind Thumb is that of a super-reduced instruction set.
Essentially, the ARM7TDMI-S processor has two instruction sets:
APB PERIPHERALS
3.5 GB 0xE000 0000
0x4000 2000
RESERVED ADDRESS SPACE 0x4000 1FFF
0x4000 1000
0x4000 0FFF
8 kB ON-CHIP STATIC RAM (LPC2103)
0x4000 0800
0x4000 07FF
4 kB ON-CHIP STATIC RAM (LPC2102)
0x4000 0000
2 kB ON-CHIP STATIC RAM (LPC2101)
1.0 GB 0x0000 8000
RESERVED ADDRESS SPACE 0x0000 7FFF
0x0000 4000
32 kB ON-CHIP NON-VOLATILE MEMORY (LPC2103) 0x0000 3FFF
16 kB ON-CHIP NON-VOLATILE MEMORY (LPC2102)
0x0000 2000
8 kB ON-CHIP NON-VOLATILE MEMORY 0x0000 1FFF
(LPC2101)
0.0 GB 0x0000 0000
6.5 Interrupt controller
The VIC accepts all of the interrupt request inputs and categorizes them as FIQ, vectored
IRQ, and non-vectored IRQ as deÞned by programmable settings. The programmable
assignment scheme means that priorities of interrupts from the various peripherals can be
dynamically assigned and adjusted.
FIQ has the highest priority. If more than one request is assigned to FIQ, the
VIC combines the requests to produce the FIQ signal to the ARM processor. The fastest
possible FIQ latency is achieved when only one request is classiÞed as FIQ, because then the
FIQ service routine does not need to branch into the interrupt service routine but can run
from the interrupt vector location. If more than one request is assigned to the FIQ class, the
FIQ service routine will read a word from the VIC that identiÞes which FIQ source(s) is (are)
requesting an interrupt.
Vectored IRQs have the middle priority. Sixteen of the interrupt requests can
be assigned to this category. Any of the interrupt requests can be assigned to any of the 16
vectored IRQ slots, among which slot 0 has the highest priority and slot 15 has the lowest.
Interrupt sources
Each peripheral device has one interrupt line connected to the Vectored Interrupt Controller,
but may have several internal interrupt ßags. Individual interrupt ßags may also represent
more than one interrupt source.
After reset all pins of Port 0 are conÞgured as input with the following
exceptions: If debug is enabled, the JTAG pins will assume their JTAG functionality. The pins
associated with the I2C0 interface are open-drain
Device pins that are not connected to a speciÞc peripheral function are controlled by the GPIO
registers. Pins may be dynamically conÞgured as inputs or outputs. Separate registers allow
setting or clearing any number of outputs simultaneously. The value of the output register may
be read back, as well as the current state of the port pins.
GPIO registers are relocated to the ARM local bus for the fastest possible I/O timing.
Mask registers allow treating sets of port bits as a group, leaving other bits unchanged.
Features
Bit-level set and clear registers allow a single instruction set or clear of any number
of bits in one port.
Features
Measurement range of 0 V to 3.3 V.
Each converter capable of performing more than 400,000 10-bit samples per second.
Burst conversion mode for single or multiple inputs.
Every analog input has a dedicated result register to reduce interrupt overhead.
UARTs
The LPC2101/2102/2103 each contain two UARTs. In addition to standard transmit and
receive data lines, UART1 also provides a full modem control handshake
interface.Compared to previous LPC2000 microcontrollers, UARTs in LPC2101/2102/2103
include a fractional baud rate generator for both UARTs. Standard baud rates such as
115200 can be achieved with any crystal frequency above 2 MHz.
Built-in fractional baud rate generator covering wide range of baud rates without a need for
external crystals of particular values.
UART1 is equipped with standard modem interface signals. This module also provides
full support for hardware ßow control (auto-CTS/RTS).
2
I C-bus serial I/O controllers
The I2C-bus is bidirectional, for inter-IC control using only two wires: a Serial Clock Line
(SCL), and a Serial Data Line (SDA). Each device is recognized by a unique address and can
operate as either a receiver-only device (e.g., LCD driver) or a transmitter with the capability
to both receive and send information such as serial memory. Transmitters and/or receivers
can operate in either master or slave mode, depending on whether the chip has to initiate a
data transfer or is only addressed. The I2C-bus is a multi-master bus, it can be controlled by
more than one bus master connected to it.
The I2C-bus implemented in LPC2101/2102/2103 supports bit rates up to 400 kbit/s (Fast
I2C).
Features
o Serial clock synchronization allows devices with different bit rates to communicate via one
serial bus.
o Serial clock synchronization can be used as a handshake mechanism to suspend and resume
serial transfer.
o The I2C-bus can also be used for test and diagnostic purposes.
Features
o Compatible with Motorola SPI, 4-wire TIÕs SSI and National SemiconductorÕs
Microwire buses.
The LPC2101/2102/2103 can count external events on one of the capture inputs if the
minimum external pulse is equal or longer than a period of the PCLK. In this conÞguration,
unused capture lines can be selected as regular timer capture inputs or used as external
interrupts.
Features
o A 32-bit timer/counter with a programmable 32-bit prescaler.
o Four 32-bit capture channels per timer/counter that can take a snapshot of the timer value
when an input signal transitions. A capture event may also optionally generate an interrupt.
o Four external outputs per timer/counter corresponding to match registers, with the
following capabilities:
The LPC2101/2102/2103 can count external events on one of the capture inputs if
the minimum external pulse is equal or longer than a period of the PCLK. In this conÞguration,
unused capture lines can be selected as regular timer capture inputs or used as external
interrupts.
Features
o Two 16-bit timer/counters with a programmable 16-bit prescaler.
o Three 16-bit capture channels that can take a snapshot of the timer value when an input
signal transitions. A capture event may also optionally generate an interrupt.
o Four external outputs per timer/counter corresponding to match registers, with the
following capabilities:
Set LOW on match.
Toggle on match.
Do nothing on match.
Watchdog timer
The purpose of the watchdog is to reset the microcontroller within a reasonable amount of
time if it enters an erroneous state. When enabled, the watchdog will generate a system reset
if the user program fails to ÔfeedÕ (or reload) the watchdog within a predetermined amount
of time.
TPCLK 4.
Real-time clock
The Real-Time Clock (RTC) is designed to provide a set of counters to measure time when
normal or idle operating mode is selected. The RTC has been designed to use little power,
making it suitable for battery powered systems where the CPU is not running continuously
(Idle mode).
Features
o Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and Day of
Year.
o Can use either the RTC dedicated 32 kHz oscillator input or clock derived from the
external crystal/oscillator input at XTAL1. Programmable Reference Clock Divider allows
Þne adjustment of the RTC.
o Dedicated power supply pin can be connected to a battery or the main 3.3 V.
Crystal oscillator
On-chip integrated oscillator operates with external crystal in range of 1 MHz to 25 MHz. The
oscillator output frequency is called fosc and the ARM processor clock frequency is referred to
as CCLK for purposes of rate equations, etc. fosc and CCLK are the same value unless the PLL
is running and connected. Refer to Section 6.17.2 ÒPLLÓ for additional information.
PLL
The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz. The input
frequency is multiplied up into the range of 10 MHz to 70 MHz with a Current Controlled
Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the
multiplier value cannot be higher than 6 on this family of microcontrollers due to the upper
frequency limit of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there
is an additional divider in the loop to keep the CCO within its frequency range while the PLL
is providing the desired output frequency. The output divider may be set to divide by 2, 4, 8, or
16 to produce the output clock. Since the minimum output divider value is 2, it is insured that
the PLL output has a 50 % duty cycle. The PLL is turned off and bypassed following a chip
reset and may be enabled by software. The program must conÞgure and activate the PLL, wait
for the PLL to Lock, then connect to the PLL as a clock source. The PLL settling time is 100
s.
The wake-up timer ensures that the oscillator and other analog functions
required for chip operation are fully functional before the processor is allowed to execute
instructions. This is important at power on, all types of reset, and whenever any of the
aforementioned functions are turned off for any reason. Since the oscillator and other functions
are turned off during Power-down mode, any wake-up of the processor from Power-down
mode makes use of the wake-up timer.
Code security
This feature of the LPC2101/2102/2103 allow an application to control whether it can be
debugged or protected from observation.
If after reset on-chip bootloader detects a valid checksum in ßash and reads 0x8765 4321 from
address 0x1FC in ßash, debugging will be disabled and thus the code in ßash will be protected
from observation. Once debugging is disabled, it can only be enabled by performing a full chip
erase using the ISP.
Additionally all 10 capture input pins can also be used as external interrupts without the
option to wake the device up from Power-down mode.
Power control
The LPC2101/2102/2103 supports two reduced power modes: Idle
mode and Power-down mode.
In Power-down mode, the oscillator is shut down and the chip receives no
internal clocks. The processor state and registers, peripheral registers, and internal SRAM
values are preserved throughout Power-down mode and the logic levels of chip output pins
remain static. The Power-down mode can be terminated and normal operation resumed by
either a reset or certain speciÞc interrupts that are able to function without clocks. Since all
dynamic operation of the chip is suspended, Power-down mode reduces chip power
consumption to nearly zero.
APB bus
The APB divider determines the relationship between the processor clock (CCLK) and the
clock used by peripheral devices (PCLK). The APB divider serves two purposes. The Þrst is to
provide peripherals with the desired PCLK via APB bus so that they can operate at the speed
chosen for the ARM processor. In order to achieve this, the APB bus may be slowed down to
1
2 to 14 of the processor clock rate. Because the APB bus must work properly at power-up
(and its timing cannot be altered if it does not work since the APB divider control registers
reside on the APB bus), the default condition at reset is for the APB bus to run at 14 of the
processor clock rate. The second purpose of the APB divider is to allow power savings when
an application does not require any peripherals to run at the full processor rate. Because the
APB divider is connected to the PLL output, the PLL remains active (if it was running) during
Idle mode.
7. Limiting values
Tj < 125 C
[5] [6] 0 - 5.5 V
VI input voltage pin conÞgured to provide a [7]
digital function
V
VO output voltage output active 0 - DD(3V3) V
V
IH HIGH-state input voltage 2.0 - - V
V
IL LOW-state input voltage - - 0.8 V
V
hys hysteresis voltage - 0.4 - V
V V
OH HIGH-state output voltage IOH = 4 mA [8] DD(3V3) - - V
0.4
V [8] - - 0.4 V
OL LOW-state output voltage IOL = 4 mA
I V =V 0.4 V [8] 4 - - mA
OH HIGH-state output current OH DD(3V3)
I [8] 4 - - mA
OL LOW-state output current VOL = 0.4 V
I [9] - - 45 mA
OHS HIGH-state short-circuit VOH = 0 V
output current
I V =V [9] - - 50 mA
OLS LOW-state short-circuit OL DDA
output current
I [10]
pd pull-down current VI = 5 V 10 50
I [11] 15 50 85
150 A
pu pull-up current VI = 0 V
V <V <5V [10]
DD(3V3) I 0 0 A
I
DD(act) active mode supply VDD(1V8) = 1.8 V, Ta = 25 C, 0
current code
while(1){}
executed from ßash, no active
peripherals
CCLK = 10 MHz <tbd> 7 <tbd> mA
CCLK = 70 MHz <tbd> 41 <tbd> mA
(other parameters as above)
I
DD(pd) Power-down mode supply VDD(1V8) = 1.8 V, Ta = +25 C <tbd> 7 <tbd> A
current
VDD(1V8) = 1.8 V, Ta = +85 C <tbd> <tbd> <tbd> A
2.2POWER SUPPLY
All digital circuits require regulated power supply. In this article we are going to learn how to get a
regulated positive supply from the mains supply.
Figure 1 shows the basic block diagram of a fixed regulated power supply. Let us go through each block.
TRANSFORMER
A transformer consists of two coils also called as “WINDINGS” namely PRIMARY & SECONDARY.
They are linked together through inductively coupled electrical conductors also called as CORE. A
changing current in the primary causes a change in the Magnetic Field in the core & this in turn induces an
alternating voltage in the secondary coil. If load is applied to the secondary then an alternating current will
flow through the load. If we consider an ideal condition then all the energy from the primary circuit will be
transferred to the secondary circuit through the magnetic field.
So
The secondary voltage of the transformer depends on the number of turns in the Primary as well as in the second
Rectifier
A rectifier is a device that converts an AC signal into DC signal. For rectification purpose we use a diode, a
diode is a device that allows current to pass only in one direction i.e. when the anode of the diode is
positive with respect to the cathode also called as forward biased condition & blocks current in the reversed
biased condition.
Rectifier can be classified as follows:
1) Half Wave rectifier.
This is the simplest type of rectifier as you can see in the diagram a half wave rectifier consists of only one
diode. When an AC signal is applied to it during the positive half cycle the diode is forward biased &
current flows through it. But during the negative half cycle diode is reverse biased & no current flows
through it. Since only one half of the input reaches the output, it is very inefficient to be used in power
supplies.
Half wave rectifier is quite simple but it is very inefficient, for greater efficiency we would like to use both
the half cycles of the AC signal. This can be achieved by using a center tapped transformer i.e. we would
have to double the size of secondary winding & provide connection to the center. So during the positive
half cycle diode D1 conducts & D2 is in reverse biased condition. During the negative half cycle diode D2
conducts & D1 is reverse biased. Thus we get both the half cycles across the load.
One of the disadvantages of Full Wave Rectifier design is the necessity of using a center tapped
transformer, thus increasing the size & cost of the circuit. This can be avoided by using the Full Wave
Bridge Rectifier.
3) Bridge Rectifier.
As the name suggests it converts the full wave i.e. both the positive & the negative half cycle into DC thus
it is much more efficient than Half Wave Rectifier & that too without using a center tapped transformer
thus much more cost effective than Full Wave Rectifier.
Full Bridge Wave Rectifier consists of four diodes namely D1, D2, D3 and D4. During the positive half
cycle diodes D1 & D4 conduct whereas in the negative half cycle diodes D2 & D3 conduct thus the diodes
keep switching the transformer connections so we get positive half cycles in the output.
If we use a center tapped transformer for a bridge rectifier we can get both positive & negative half cycles
which can thus be used for generating fixed positive & fixed negative voltages.
FILTER CAPACITOR
Even though half wave & full wave rectifier give DC output, none of them provides a constant output
voltage. For this we require to smoothen the waveform received from the rectifier. This can be done by
using a capacitor at the output of the rectifier this capacitor is also called as “FILTER CAPACITOR” or
“SMOOTHING CAPACITOR” or “RESERVOIR CAPACITOR”. Even after using this capacitor a small
amount of ripple will remain.
We place the Filter Capacitor at the output of the rectifier the capacitor will charge to the peak voltage during eac
cycle then will discharge its stored energy slowly through the load while the rectified voltage drops to zero, thus
to keep the voltage as constant as possible.
If we go on increasing the value of the filter capacitor then the Ripple will decrease. But then the costing will inc
The value of the Filter capacitor depends on the current consumed by the circuit, the frequency of the waveform
accepted ripple.
Where,
Vr= accepted ripple voltage.( should not be more than 10% of the voltage)
I= current consumed by the circuit in Amperes.
F= frequency of the waveform. A half wave rectifier has only one peak in one cycle so F=25hz
Whereas a full wave rectifier has Two peaks in one cycle so F=100hz.
VOLTAGE REGULATOR
A Voltage regulator is a device which converts varying input voltage into a constant regulated output
After filtering the rectifier output the signal is given to a voltage regulator. The maximum input voltage
that can be applied at the input is 35V.Normally there is a 2-3 Volts drop across the regulator so the input
voltage should be at least 2-3 Volts higher than the output voltage. If the input voltage gets below the Vmin
of the regulator due to the ripple voltage or due to any other reason the voltage regulator will not be able to
produce the correct regulated voltage.
3 Circuit diagram:
IC 7805:
7805 is an integrated three-terminal positive fixed linear voltage regulator. It supports an input voltage of
10 volts to 35 volts and output voltage of 5 volts. It has a current rating of 1 amp although lower current
models are available. Its output voltage is fixed at 5.0V. The 7805 also has a built-in current limiter as a
safety feature. 7805 is manufactured by many companies, including National Semiconductors and Fairchild
Semiconductors.
The 7805 will automatically reduce output current if it gets too hot.The last two digits represent the
voltage; for instance, the 7812 is a 12-volt regulator. The 78xx series of regulators is designed to work in
complement with the 79xx series of negative voltage regulators in systems that provide both positive and
negative regulated voltages, since the 78xx series can't regulate negative voltages in such a system.
The 7805 & 78 is one of the most common and well-known of the 78xx series regulators, as it's small
component count and medium-power regulated 5V make it useful for powering TTL devices.
Vout 5V
Output Imax 1A
2.3 LCD MODULE
To display interactive messages we are using LCD Module. We examine an intelligent LCD display
of two lines,16 characters per line that is interfaced to the controllers. The protocol (handshaking) for the
display is as shown. Whereas D0 to D7th bit is the Data lines, RS, RW and EN pins are the control pins
and remaining pins are +5V, -5V and GND to provide supply. Where RS is the Register Select, RW is the
Read Write and EN is the Enable pin.
The display contains two internal byte-wide registers, one for commands (RS=0) and the second
for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the character RAM)
that can be programmed to generate any desired character that can be formed using a dot matrix. To
distinguish between these two data areas, the hex command byte 80 will be used to signify that the display
RAM address 00h will be chosen.Port1 is used to furnish the command or data type, and ports 3.2 to3.4
furnish register select and read/write levels.
The display takes varying amounts of time to accomplish the functions as listed. LCD bit 7 is monitored for
logic high (busy) to ensure the display is overwritten.
Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for
debugging purpose. The most common type of LCD controller is HITACHI 44780 which provides a simple
interface between the controller & an LCD. These LCD's are very simple to interface with the controller as
well as are cost effective.
Features:
Applications include transducer Amplifiers dc amplification blocks, and all the conventional
Operational Amplifier circuits that now CAN be implemented more easily in single-supply-voltage
systems. For example, these devices CAN be operated directly from the standard 5-V supply used in digital
systems and easily provide the required Interface electronics without additional 5-V supplies.
Complete LM358 datasheet specifications. The LM358 series consists of two independent,
high gain, internally frequency compensated operational amplifiers which were designed specifically to
operate from a single power supply over a wide range of voltages. Operation from split power supplies is
also possible and the low power supply current drain is independent of the magnitude of the power supply
voltage.
Description:
LM 358 consist of two independent, high gain, internally frequency compensated operational amplifiers
which were designed specifically to operate from a single power supply over a wide range of voltage.
Operation from split power supplies is also possible and the low power supply current drain is independent
of the magnitude of the power supply voltage.
Application areas include transducer amplifier, DC gain blocks and all the conventional OP-AMP circuits
which now can be easily implemented in single power supply systems.
PIN DIAGRAM
INTERNAL DIAGRAM:
2.5 RELAY
RELAYS SPDT
Overview OF Relays
A relay is an electrically operated switch used to isolate one electrical circuit from another. In its simplest
form, a relay consists of a coil used as an electromagnet to open and close switch contacts. Since the two
circuits are isolated from one another, a lower voltage circuit can be used to trip a relay, which will control
a separate circuit that requires a higher voltage or amperage. Relays can be found in early telephone
exchange equipment, in industrial control circuits, in car audio systems, in automobiles, on water pumps, in
high-power audio amplifiers and as protection devices.
switch. When you apply a voltage across the coil at points A and B, you create an electromagnetic field,
which attracts a lever in the switch, causing it to make or break contact in the circuit at points C and D
(depending if the design is NO or NC). The switch contacts remain in this state until you remove the
voltage to the coil. Relays come in different switch configurations. The switches may have more than one
"pole," or switch contact. The diagram shows a "single pole single throw" configuration, referred to as
SPST. This is similar to a wall light switch in your home. With a single "throw" of the switch, you close
the circuit.
This circuit is "closed." A gap between the contacts of point E and D creates an "open" circuit. When you
apply power to the coil, a metal level is pulled down, closing the circuit between points E and D and
opening the circuit between E and C. A single pole double throw relay can be used to alternate which
circuit a voltage or signal will be sent to.
SPDT Relay:
(Single Pole Double Throw Relay) an electromagnetic switch, consist of a coil (terminals 85 & 86), 1
common terminal (30), 1 normally closed terminal (87a), and one normally open terminal (87) (Figure 1).
When the coil of an SPDT relay (Figure 1) is at rest (not energized), the common terminal (30) and the
normally closed terminal (87a) have continuity. When the coil is energized, the common terminal (30) and
the normally open terminal (87) have continuity.
The diagram below center (Figure 2) shows an SPDT relay at rest, with the coil not energized. The diagram
below right (Figure 3) shows the relay with the coil energized. As you can see, the coil is an electromagnet
that causes the arm that is always connected to the common (30) to pivot when energized whereby contact
is broken from the normally closed terminal (87a) and made with the normally open terminal (87).
When energizing the coil of a relay, polarity of the coil does not matter unless there is a diode across the
coil. If a diode is not present, you may attach positive voltage to either terminal of the coil and negative
voltage to the other, otherwise you must connect positive to the side of the coil that the cathode side (side
with stripe) of the diode is connected and negative to side of the coil that the anode side of the diode is
connected.
There are far too many applications to list that require the use of a relay, but we do show many of the most
popular applications in the pages that follow and many more in our Relay Diagrams - Quick Reference
application. If you are still unclear about what a relay does or if you should use one after you browse
through the rest of this section, please post a question in the12volt's install bay. (We recommend Tyco
(formerly Bosch) or Potter & Brumfield relays for all of the SPDT and SPST relay applications shown on
this site.)
2.6 DC MOTOR
DC motors are configured in many types and sizes, including brush less, servo, and gear motor
types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is
maintained using either permanent magnets or electromagnetic windings. DC motors are most
commonly used in variable speed and torque.
Motion and controls cover a wide range of components that in some way are used to
generate and/or control motion. Areas within this category include bearings and bushings, clutches and
brakes, controls and drives, drive components, encoders and resolves, Integrated motion control, limit
switches, linear actuators, linear and rotary motion components, linear position sensing, motors (both
AC and DC motors), orientation position sensing, pneumatics and pneumatic components, positioning
stages, slides and guides, power transmission (mechanical), seals, slip rings, solenoids, springs.
Motors are the devices that provide the actual speed and torque in a drive system. This
family includes AC motor types (single and multiphase motors, universal, servo motors, induction,
synchronous, and gear motor) and DC motors (brush less, servo motor, and gear motor) as well as linear,
stepper and air motors, and motor contactors and starters.
Let's start by looking at a simple 2-pole DC electric motor (here red represents a magnet or winding
with a "North" polarization, while green represents a magnet or winding with a "South" polarization).
Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, commutator, field magnet(s),
and brushes. In most common DC motors (and all that Beamers will see), the external magnetic field is
produced by high-strength permanent magnets1. The stator is the stationary part of the motor -- this
includes the motor casing, as well as two or more permanent magnet pole pieces. The rotor (together
with the axle and attached commutator) rotates with respect to the stator. The rotor consists of windings
(generally on a core), the windings being electrically connected to the commutator. The above diagram
shows a common motor layout -- with the rotor inside the stator (field) magnets.
The geometry of the brushes, commutator contacts, and rotor windings are such that
when power is applied, the polarities of the energized winding and the stator magnet(s) are
misaligned, and the rotor will rotate until it is almost aligned with the stator's field magnets. As the
rotor reaches alignment, the brushes move to the next commutator contacts, and energize the next
winding. Given our example two-pole motor, the rotation reverses the direction of current through the
rotor winding, leading to a "flip" of the rotor's magnetic field, and driving it to continue rotating.
In real life, though, DC motors will always have more than two poles (three is a very common
number). In particular, this avoids "dead spots" in the commutator. You can imagine how with our
example two-pole motor, if the rotor is exactly at the middle of its rotation (perfectly aligned with the
field magnets), it will get "stuck" there. Meanwhile, with a two-pole motor, there is a moment where the
commutator shorts out the power supply (i.e., both brushes touch both commutator contacts
simultaneously). This would be bad for the power supply, waste energy, and damage motor components
as well. Yet another disadvantage of such a simple motor is that it would exhibit a high amount of
torque” ripple" (the amount of torque it could produce is cyclic with the position of the rotor).
So since most small DC motors are of a three-pole design, let's tinker with the workings of one via an
interactive animation (JavaScript required):
You'll notice a few things from this -- namely, one pole is fully energized at a time (but two
others are "partially" energized). As each brush transitions from one commutator contact to the next, one
coil's field will rapidly collapse, as the next coil's field will rapidly charge up (this occurs within a few
microsecond). We'll see more about the effects of this later, but in the meantime you can see that this is a
direct result of the coil windings' series wiring:
There's probably no better way to see how an average dc motor is put together, than by just
opening one up. Unfortunately this is tedious work, as well as requiring the destruction of a perfectly good
motor.
2.7
ESP 8266:
ESP8266 Features
The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU (Micro Controller Unit) capability
produced by Shanghai-based Chinese manufacturer,
The chip first came to the attention of western makers in August 2014 with the ESP-01 module, made by a
third-party manufacturer, AI-Thinker. This small module allows microcontrollers to connect to a Wi-Fi
network and make simple TCP/IP connections using Hayes-style commands. However, at the time there
was almost no English-language documentation on the chip and the commands it accepted. The very low
price and the fact that there were very few external components on the module which suggests that it could
eventually be very inexpensive in volume, attracted many hackers to explore the module, chip, and the
software on it, as well as to translate the Chinese documentation.
The ESP8285 is an ESP8266 with 1 MB of built-in flash, allowing for single-chip devices capable of
connecting to Wi-Fi.
In the table above (and the two tables which follow), "Active pins" include the GPIO and ADC pins with
which you can attach external devices to the ESP8266 MCU. The "Pitch" is the space between pins on the
ESP8266 module, which is important to know if you are going to breadboard the device. The "Form factor"
also describes the module packaging as "2 x 9 DIL", meaning two rows of 9 pins arranged "Dual In Line",
like the pins of DIP ICs. Many ESP-xx modules include a small on-board LED which can be programmed
to blink and thereby indicate activity. There are several antenna options for ESP-xx boards including a
trace antenna, an on-board ceramic antenna, and an external connector which allows you to attach an
external Wi-Fi antenna. Since Wi-Fi communications generates a lot of RFI (Radio Frequency
Interference), governmental bodies like the FCC like shielded electronics to minimize interference with
other devices. Some of the ESP-xx modules come housed within a metal box with an FCC seal of approval
stamped on it. First and second world markets will likely demand FCC approval and shielded Wi-Fi
devices.
AI-Thinker modules
ESP-01 module
These are the first series of modules made with the ESP8266 by the third-party manufacturer AI-Thinker
and remain the most widely available. They are collectively referred to as "ESP-xx modules". To form a
workable development system they require additional components, especially a serial TTL-to-USB adapter
(sometimes called a USB-to-UART bridge) and an external 3.3 Volt power supply. Novice ESP-8266
developers are encouraged to consider larger ESP8266 Wi-Fi development boards like the Node MCU
which includes the USB-to-UART bridge and a Micro-USB connector coupled with a 3.3 Volt power
regulator already built into the board. When project development is complete, you may not need these
components and can consider using these cheaper ESP-xx modules as a lower power, smaller footprint
option for your production runs.
In the table above (and the two tables which follow), "Active pins" include the GPIO and ADC pins with
which you can attach external devices to the ESP8266 MCU. The "Pitch" is the space between pins on the
ESP8266 module, which is important to know if you are going to breadboard the device. The "Form factor"
also describes the module packaging as "2 x 9 DIL", meaning two rows of 9 pins arranged "Dual In Line",
like the pins of DIP ICs. Many ESP-xx modules include a small on-board LED which can be programmed
to blink and thereby indicate activity. There are several antenna options for ESP-xx boards including a
trace antenna, an on-board ceramic antenna, and an external connector which allows you to attach an
external Wi-Fi antenna. Since Wi-Fi communications generates a lot of RFI (Radio Frequency
Interference), governmental bodies like the FCC like shielded electronics to minimize interference with
other devices. Some of the ESP-xx modules come housed within a metal box with an FCC seal of approval
stamped on it. First and second world markets will likely demand FCC approval and shielded Wi-Fi
devices.
AI-Thinker modules
ESP-01 module
These are the first series of modules made with the ESP8266 by the third-party manufacturer AI-Thinker
and remain the most widely available. They are collectively referred to as "ESP-xx modules". To form a
workable development system they require additional components, especially a serial TTL-to-USB adapter
(sometimes called a USB-to-UART bridge) and an external 3.3 Volt power supply. Novice ESP-8266
developers are encouraged to consider larger ESP8266 Wi-Fi development boards like the Node MCU
which includes the USB-to-UART bridge and a Micro-USB connector coupled with a 3.3 Volt power
regulator already built into the board. When project development is complete, you may not need these
components and can consider using these cheaper ESP-xx modules as a lower power, smaller footprint
option for your production runs.
ESP8266 offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the
application or to offload all Wi-Fi networking functions from another application processor.
When ESP8266 hosts the application, and when it is the only application processor in the device, it is able
to boot up directly from an external flash. It has integrated cache to improve the performance of the system
in such applications, and to minimize the memory requirements.
Alternately, serving as a Wi-Fi adapter, wireless internet access can be added to any microcontroller-based
design with simple connectivity through UART interface or the CPU AHB bridge interface.
The popularity of many of these "other boards" over the earlier ESP-xx modules is the inclusion of an on-
board USB-to-UART bridge (like the Silicon Labs' CP2102 or the WCH CH340G) and a Micro-USB
connector coupled with a 3.3 Volt regulator to provide both power to the board and connectivity to the host
(software development) computer commonly referred to as the console. With earlier ESP-xx modules,
these two items (the USB-to-Serial adaptor and a 3.3 Volt regulator) had to be purchased separately and be
wired into the ESP-xx circuit. Modern ESP8266 boards like the Node MCU boards are a lot less painful
and offer more GPIO pins to play with. Most of these "other boards" are based on the ESP-12E module, but
new modules are being introduced seemingly every few months.
CHAPTER3
SOFTWARE DEVELOPMENT:
4.1 Introduction:
In this chapter the software used and the language in which the program code is defined is mentioned and the
program code dumping tools are explained. The chapter also documents the development of the program for the
application. This program has been termed as “Source code”. Before we look at the source code we define the two
header files that we have used in the code.
Keil development tools for the 8051 Microcontroller Architecture support every level of software
developer from the professional applications
Step1: open the NEW Uversion project which is in the project option in the tool bar.
Step2: save the project with the required name and click save button
Step:3 select the device from NXP options the window which comes after saving the
project.
Step 4: select the LPC 2148 from the NXP options
Step 7: a new text file will open which we have to write the following code
Step 8 : write the code require for ur applications
Step 11: select the saved .c file from the window which is showing to add the file by
clicking the add tab.
Step 12: thus .C file is added to the Source Group is clearly seen
Step 13: press the icon that shows Rebuilt Target which proceeds for the Linking if the .C
file.
Step 14:Re-built All Target files for complete process of assembling->Compiling ->linking->
generating .hex file
Step 15: press the start/stop debug icon for debugging of the code which written.
Following are debugging windows press F11 for step by step debug
Window:1
Window2
CHAPTER 5. SOURCE CODE
5.1Source code
Source code:
#include<LPC2103.H>
#include<string.h>
#define Logic_Low 0
#define Port0 0
#define Port1 1
/******************************************************************/
#define Motor (1<<29)
#include "LCD.c"
#include "Serial_Uart0.c"
#include "GSM.c"
#include "adc0.c"
#include "App.c"
main()
{
GPIO_Port0s_IODIR = ~(Inputs);
GPIO_Port0s_IODIR = (LCD_Data|RS|EN|Outputs); //output=1
// input=0
while(1)
{
Get_ADC_Data();
ADC_Data_Dispaly();
Check_Sensors();
}
}
if(port==0)
{
x=(Port0_Set& (1<<pin))?1:0;
}
void Project_Title(void)
{
Lcd_Data_Str(1,1,"iot Based ");
Lcd_Data_Str(2,1,"Irrigation System");
Delay(500);
Lcd_Data_Chr(0,0,0,LCD_CLEAR);
Lcd_Data_Str(2,1,"Soil:");
void Enable_UART0_Interrupt(void);
void Disable_UART0_Interrupt(void);
void Project_Title(void);
void LCD_Lable_display(void);
void Misscall_Message_Sending(void);
void Sending_Message_Structure(void);
void Data_For_Sending_Message(void);
void Multichannel_GetData(void);
void clear_mess_buffer(void);
void String_Compare(void);
unsigned char *GPS_Data_Link(void);
//--------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------------------------------------
----
/
*---------------------------------------------------------------------
-----------------------------
GSM Modem Initing functions
----------------------------------------------------------------------
----------------------------*/
void GSM_S900(void)
{
GSM_Modem_Init();
Sim_Registering();
Message_Deleting();
Registering_Mobile_NO();
}
/
*---------------------------------------------------------------------
-----------------------------
Modem Initing functions
----------------------------------------------------------------------
----------------------------*/
void GSM_Modem_Init(void)
{
Lcd_Data_Str(1,1,"GSM Initng ");
Lcd_Data_Str(1,1,"GSM Inited ");
Delay(gsm_delay);
Lcd_Data_Str(1,1,"SIM Chkng ");
}
/
*---------------------------------------------------------------------
-----------------------------
SIM Registering....
----------------------------------------------------------------------
----------------------------*/
void Sim_Registering(void)
{
UART0_TX_Str("AT+CREG?");
for(j=0;j<4;j++)
{
sim_reg[j]=UART0_RX_Chr();
}
for(j=0;j<4;j++)
{
Lcd_Data_Chr(1,2,ptr++,sim_reg[j]);
}
if(sim_reg[3]==0x31)
{
Lcd_Data_Str(1,1,"GSM Inited ");
Lcd_Data_Str(2,1,"SIM Registered ");
Delay(500);
Enable_UART0_Interrupt();
}
else
{
Lcd_Data_Str(2,1,"SIM Registering");
Delay(700);
Lcd_Data_Str(2,1," ");
goto start;
}
}
/
*---------------------------------------------------------------------
-----------------------------
Phone_No_Registering........
----------------------------------------------------------------------
----------------------------*/
void Registering_Mobile_NO(void)
{
Project_Title();
Delay(300);
Give_Misscall(Restg);
while(1)
{
if(Reg_Phno_flag==1)
{
Ph_no_Reg_Message_Sending();
Give_Misscall(Restd);
}
}
}
void Ph_no_Reg_Message_Sending(void)
{
Lcd_Data_Str(1,1," ");
Lcd_Data_Str(1,1,"Misscall ");
for(j=0;j<15;j++)
{
misscall_phone[j]=UART0_RX_Chr();
}
Lcd_Data_Str(2,1,"message sending");
UART0_TX_Str ("AT\r\n");
Delay(gsm_delay);
UART0_TX_Str ("AT+CMGS=");
UART0_TX_Str(misscall_phone);
UART0_TX_Chr(0x0D);
UART0_TX_Chr(0x0A);
while(UART0_RX_Chr()!='>');
UART0_TX_Str ("Your Phone No:");
UART0_TX_Str(misscall_phone);
UART0_TX_Str("Is Feeded Sucessfully");
while(UART0_RX_Chr()!='O');
while(UART0_RX_Chr()!='K');
Lcd_Data_Str(2,1," message sent ");
}
void Give_Misscall(unsigned char ph)
{
if(!ph)
{
Lcd_Data_Str(1,1,"Give Miscal ");
Lcd_Data_Str(2,1,"To Reg Phone No ");
}
if(ph)
{
Lcd_Data_Str(1,1,"Ur Ph No ");
Lcd_Data_Str(2,1,"Reg Successfully");
Delay(300);
}
}
/
*---------------------------------------------------------------------
-----------------------------
Chk_for_MissCall--->Cut_Call--->Send_Messg
----------------------------------------------------------------------
----------------------------*/
void Misscall_Detect()//unsigned char *mmess)
{
Disable_UART0_Interrupt();
Delay(500);
UART0_TX_Str("ATH");
for(j=0;j<15;j++)
{
misscall_phone[j]=UART0_RX_Chr();
}
Misscall_Message_Send(GPS_Data_Link());
/
*---------------------------------------------------------------------
-------------------------------------
MissCall_Sending_Message_Structure
----------------------------------------------------------------------
-------------------------------------*/
void Check_Sensors(void)
{
if(PinStatus_Port(0,5)==0)
{
Lcd_Data_Str(2,6,"Wet");
Clear_Port0s=Motor;
Misscall_Message_Send("GSM Based Irrigation System\r\n Soil Wet
Condition");
}
if((PinStatus_Port(0,5)==1))
{
Lcd_Data_Str(2,6,"Dry");
if((TankWater==1))
{
if(Volt_Nok==0)
{
Set_Port0s=Motor;
}
if(Volt_Nok==1)
{
Clear_Port0s=Motor;
}
}
Misscall_Message_Send("GSM Based Irrigation System\r\n Soil Dry
Condition");
}
if(PinStatus_Port(0,6)==0&&PinStatus_Port(0,7)==0)
{
Lcd_Data_Str(2,10,"WTank:F");
if(TFull_flag==1)
{
Misscall_Message_Send("GSM Based Irrigation System\r\n Soil Dry
Condition");
}
}
if(PinStatus_Port(0,6)==1&&PinStatus_Port(0,7)==0)
{
Lcd_Data_Str(2,10,"WTank:M");
}
if(PinStatus_Port(0,6)==1&&PinStatus_Port(0,7)==1)
{
TankWater=0;
Lcd_Data_Str(2,10,"WTank:E");
Clear_Port0s=Motor;
Misscall_Message_Send("GSM Based Irrigation System\r\n Soil Dry
Condition");
}
#define RS (0xFFFFFFFF)<<31
#define EN (1<<30)
void Lcd_Init(void);
int Lcd_Data_Chr(unsigned char ,unsigned char ,unsigned char
,unsigned char);
int Lcd_Data_Str(unsigned char ,unsigned char ,unsigned char temp[]);
int Lcd_Wr(unsigned char );
/*********************************************************************
************
**********************************************************************
***********/
void Lcd_Init(void)
{
Lcd_Data_Chr(0,0,0,LCD_2_LINE);
Lcd_Data_Chr(0,0,0,DISPLAY_ON);
Lcd_Data_Chr(0,0,0,LCD_CURSOR_OFF);
Lcd_Data_Chr(0,0,0,LCD_CLEAR);
if(RS1==0)
{
Set_Port0s= (temp1<<16)&LCD_Data;
Lcd_Wr(LCD_C);
if(RS1==1)
{
if(line==1)
{
x=0x7f+position;
Set_Port0s= (x<<16)&LCD_Data;
Lcd_Wr(LCD_C);
if(line==2)
{
x=0xbf+position;
Set_Port0s= (x<<16)&LCD_Data;
Lcd_Wr(LCD_C);
}
Set_Port0s= (temp1<<16)&LCD_Data;
Lcd_Wr(LCD_D);
Delay(5);
}
unsigned int p;
unsigned char t;
if(line1==1)
{
p=0x7f+position;
Lcd_Data_Chr(0,0,0,(Set_Port0s=(p<<16)&LCD_Data));
if(line1==2)
{
p=0xbf+position;
Lcd_Data_Chr(0,0,0,(Set_Port0s=(p<<16)&LCD_Data));
}
while(temp[t]!='\0')
{
Set_Port0s= (temp[t]<<16)&LCD_Data;
Lcd_Wr(LCD_D);
t++;
}
Lcd_Wr(unsigned char r)
{
if(r==1)
{
Set_Port0s= RS;
Set_Port0s= EN;
Delay(1);
Clear_Port0s= EN;
}
if(r==0)
{
Clear_Port0s= RS;
Set_Port0s= EN;
Delay(1);
Clear_Port0s= EN;
BIBILOGRAPHY
1. WWW.MITEL.DATABOOK.COM
2. WWW.ATMEL.DATABOOK.COM
3. WWW.FRANKLIN.COM
4. WWW.KEIL.COM
en.wikipedia.org/wiki/ZigBee
WWW .ZIGBEE .ORG /
www.nxp.com/documents/user_manual/UM1 http://www.futurlec.com/GPS.shtml013
HTTP :// EN .WIKIPEDIA .ORG /WIKI /G LOBAL _P OSITIONING _S YSTEM9. PDF
http://electronics.howstuffworks.com/gadgets/travel/gps.htm
http://en.wikipedia.org/wiki/GSM
http://burnsidetelecom.com/whitepapers/gsm.pdf
http://www.itu.int/osg/spu/ni/3G/casestudies/GSM-FINAL.pdf
REFERENCES
1. ARM-systemonchip-architecture by Steve furber.
2. ARM-user manual UM10114.
3. ARM System Developers Guide by Andrew N.SLOSS
4. "Power Electronics” by M D Singh and K B Khanchandan
5. "Linear Integrated Circuits” by D Roy Choudary & Shail Jain
6. "Electrical Machines” by S K Bhattacharya
7. "Electrical Machines II” by B L Thereja
8. www.8051freeprojectsinfo.com