Professional Documents
Culture Documents
Project Report On: Energy Meter Monitoring Online Using Wireless Transmission
Project Report On: Energy Meter Monitoring Online Using Wireless Transmission
Project Report On: Energy Meter Monitoring Online Using Wireless Transmission
PROJECT REPORT ON
Energy Meter monitoring online using wireless
transmission
Page 1
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 1
Introduction
Wireless communication is the transfer of information between two or more points that
are not connected by an electrical conductor.
Here in our project we have used GSM for the wireless communication.
GSM (Global System for Mobile Communications, originally Groupe Spécial Mobile), is a
standard developed by the European Telecommunications Standards Institute (ETSI) to
describe protocols for second generation (2G) digital cellular networks used by mobile
phones. It is the de facto global standard for mobile communications with over 90%
market share, and is available in over 219 countries and territories.
Page 2
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
The GSM standard was developed as a replacement for first generation (1G) analog
cellular networks, and originally described a digital, circuit-switched network optimized
for full duplex voice telephony. This was expanded over time to include data
communications, first by circuit-switched transport, then packet data transport via
GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM
Evolution or EGPRS).
Subsequently, the 3GPP developed third generation (3G) UMTS standards followed by
fourth generation (4G) LTE Advanced standards, which are not part of the ETSI GSM
standard.
"GSM" is a trademark owned by the GSM Association. It may also refer to the initially
most common voice codec used, Full Rate.
In 1981, work began to develop a European standard for digital cellular voice telephony
when the European Conference of Postal and Telecommunications Administrations
(CEPT) created the Groupe Spécial Mobile committee and later provided a permanent
technical support group based in Paris. Five years later, in 1987, 15 representatives
from 13 European countries signed a memorandum of understanding in Copenhagen to
develop and deploy a common cellular telephone system across Europe, and EU rules
were passed to make GSM a mandatory standard. The decision to develop a continental
standard eventually resulted in a unified, open, standard-based network which was
larger than that in the United States. In 1989, the Groupe Spécial Mobile committee was
transferred from CEPT to the European Telecommunications Standards Institute (ETSI).
In 1987 Europe produced the very first agreed GSM Technical Specification in February.
Ministers from the four big EU countries cemented their political support for GSM with
the Bonn Declaration on Global Information Networks in May and the GSM MoU was
tabled for signature in September. The MoU drew-in mobile operators from across
Europe to pledge to invest in new GSM networks to an ambitious common date. It got
GSM up and running fast.
In this short 37-week period the whole of Europe (countries and industries) had been
brought behind GSM in a rare unity and speed guided by four public officials Armin
Silberhorn (Germany), Stephen Temple (UK), Philippe Dupuis (France), and Renzo Failli
Page 3
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
(Italy).[8] In 1989 the Groupe Spécial Mobile committee was transferred from CEPT to
the European Telecommunications Standards Institute (ETSI).
In parallel, France and Germany signed a joint development agreement in 1984 and
were joined by Italy and the UK in 1986. In 1986 the European Commission proposed
reserving the 900 MHz spectrum band for GSM.
Phase I of the GSM specifications were published in 1990. The world's first GSM call was
made by the former Finnish prime minister Harri Holkeri to Kaarina Suonio (mayor in
city of Tampere) on July 1, 1991, on a network built by Telenokia and Siemens and
operated by Radiolinja.[9] The following year in 1992, the first short messaging service
(SMS or "text message") message was sent and Vodafone UK and Telecom Finland
signed the first international roaming agreement.
Work began in 1991 to expand the GSM standard to the 1800 MHz frequency band and
the first 1800 MHz network became operational in the UK by 1993. Also that year,
Telecom Australia became the first network operator to deploy a GSM network outside
Europe and the first practical hand-held GSM mobile phone became available.
In 1995, fax, data and SMS messaging services were launched commercially, the first
1900 MHz GSM network became operational in the United States and GSM subscribers
worldwide exceeded 10 million. Also this year, the GSM Association was formed. Pre-
paid GSM SIM cards were launched in 1996 and worldwide GSM subscribers passed 100
million in 1998.
In 2000, the first commercial GPRS services were launched and the first GPRS
compatible handsets became available for sale. In 2001 the first UMTS (W-CDMA)
network was launched, a 3G technology that is not part of GSM. Worldwide GSM
subscribers exceeded 500 million. In 2002 the first Multimedia Messaging Service
(MMS) were introduced and the first GSM network in the 800 MHz frequency band
became operational. EDGE services first became operational in a network in 2003 and
the number of worldwide GSM subscribers exceeded 1 billion in 2004.
By 2005, GSM networks accounted for more than 75% of the worldwide cellular
network market, serving 1.5 billion subscribers. In 2005 the first HSDPA capable
network also became operational. The first HSUPA network was launched in 2007.
Page 4
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
High-Speed Packet Access (HSPA) and its uplink and downlink versions are 3G
technologies, not part of GSM. Worldwide GSM subscribers exceeded two billion in
2008.
The GSM Association estimated in 2010 that technologies defined in the GSM standard
serve 80% of the global mobile market, encompassing more than 5 billion people across
more than 212 countries and territories, making GSM the most ubiquitous of the many
standards for cellular networks.
Macau planned to phase out its 2G GSM networks as of June 4, 2015, making it the first
region to decommission a GSM network.
Page 5
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 2
Objective
This project reads reading from an energy meter, displays that reading on the LCD
panel. Then it upload these reading on internet via http request. These readings are
easily accessible using a URL . Apart from monitoring it also record data, that too is
online accessible.
The objective of the project is to make the data available through the globe. Different
hardware and software have been used in this project. All these hardware and software
works in a coordination. For making HTTP request and response, online webserver is
used. The server is Linux server. For recording data we have use PHP My Admin data
base management system.
Page 6
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 3
Methodology
The following block diagram explains working of the system, later we shall discuss all of
the components of the diagram.
Page 7
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 4
Programming of hardware controller
This chapter elaborate the programming of hardware controller.
Page 8
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
to be flexible and to meet a wide range of end-user needs. Embedded systems control
many devices in common use today.
Modern embedded systems are often based on microcontrollers (i.e CPUs with
integrated memory and/or peripheral interfaces) but ordinary microprocessors (using
external chips for memory and peripheral interface circuits) are also still common,
especially in more complex systems. In either case, the processor(s) used may be types
ranging from rather general purpose to very specialised in certain class of
computations, or even custom designed for the application at hand. A common standard
class of dedicated processors is the digital signal processor (DSP).
The key characteristic, however, is being dedicated to handle a particular task. Since the
embedded system is dedicated to specific tasks, design engineers can optimize it to
reduce the size and cost of the product and increase the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, and
largely complex systems like hybrid vehicles, MRI, and avionics. Complexity varies from
low, with a single microcontroller chip, to very high with multiple units, peripherals and
networks mounted inside a large chassis or enclosure.
Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile
phones, videogame consoles, digital cameras, DVD players, GPS receivers, and printers.
Household appliances, such as microwave ovens, washing machines and dishwashers,
include embedded systems to provide flexibility, efficiency and features. Advanced
HVAC systems use networked thermostats to more accurately and efficiently control
temperature that can change by time of day and season. Home automation uses wired-
Page 9
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Medical equipment uses embedded systems for vital signs monitoring, electronic
stethoscopes for amplifying sounds, and various medical imaging (PET, SPECT, CT, MRI)
for non-invasive internal inspections. Embedded systems within medical equipment are
often powered by industrial computers. Embedded systems are used in transportation,
fire safety, safety and security, medical applications and life critical systems, as these
systems can be isolated from hacking and thus, be more reliable.[citation needed] For
fire safety, the systems can be designed to have greater ability to handle higher
temperatures and continue to operate. In dealing with security, the embedded systems
can be self-sufficient and be able to deal with cut electrical and communication systems.
A new class of miniature wireless devices called motes are quickly gaining popularity as
the field of wireless sensor networking is increasing. Wireless sensor networking, WSN,
makes use of miniaturization made possible by advanced IC design to couple full
wireless subsystems to sophisticated sensors, enabling people and companies to
measure a myriad of things in the physical world and act on this information through IT
monitoring and control systems. These motes are completely self-contained, and will
typically run off a battery source for years before the batteries need to be changed or
charged.
Embedded Wi-Fi modules provide a simple means of wirelessly enabling any device
which communicates via a serial port.
Page
10
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Atmel® Studio 6 is the integrated development platform (IDP) for developing and
debugging Atmel ARM® Cortex®-M and Atmel AVR® microcontroller (MCU) based
applications. The Atmel Studio 6 IDP gives you a seamless and easy-to-use environment
to write, build and debug your applications written in C/C++ or assembly code.
Atmel Studio 6 is free of charge and is integrated with the Atmel Software Framework
(ASF)—a large library of free source code with 1,600 ARM and AVR project examples.
ASF strengthens the IDP by providing, in the same environment, access to ready-to-use
code that minimizes much of the low-level design required for projects. Use the IDP for
our wide variety of AVR and ARM Cortex-M processor-based MCUs, including our
broadened portfolio of Atmel SAM3 ARM Cortex-M3 and M4 Flash devices.
With the introduction of Atmel Gallery and Atmel Spaces, Atmel Studio 6 further
simplifies embedded MCU designs to reduce development time and cost. Atmel Gallery
is an online apps store for development tools and embedded software. Atmel Spaces is a
cloud-based collaborative development workspace allowing you to host software and
hardware projects targeting Atmel MCUs.
Facilitates reuse of existing software and, by doing so, enables design differentiation.
Supports the product development process with easy access to integrated tools and
software extensions through Atmel Gallery. Reduces time to market by providing
advanced features, an extensible software eco-system, and powerful debug integration.
Page
11
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 5
The parts & Interfacing
Following are the parts of the project.
Electricity meters are typically calibrated in billing units, the most common one being
the kilowatt hour [kWh]. Periodic readings of electricity meters establishes billing
cycles and energy used during a cycle.
In settings when energy savings during certain periods are desired, meters may
measure demand, the maximum use of power in some interval. "Time of day" metering
allows electric rates to be changed during a day, to record usage during peak high-cost
Page
12
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
periods and off-peak, lower-cost, periods. Also, in some areas meters have relays for
demand response load shedding during peak load periods.
As commercial use of electric energy spread in the 1880s, it became increasingly
important that an electric energy meter, similar to the then existing gas meters, was
required to properly bill customers for the cost of energy, instead of billing for a fixed
number of lamps per month. Many experimental types of meter were developed. Edison
at first worked on a DC electromechanical meter with a direct reading register, but
instead developed an electrochemical metering system, which used an electrolytic cell
to totalise current consumption. At periodic intervals the plates were removed,
weighed, and the customer billed. The electrochemical meter was labor-intensive to
read and not well received by customers.
An early type of electrochemical meter used in the United Kingdom was the 'Reason'
meter. This consisted of a vertically mounted glass structure with a mercury reservoir
at the top of the meter. As current was drawn from the supply, electrochemical action
transferred the mercury to the bottom of the column. Like all other DC meters, it
recorded ampere-hours. Once the mercury pool was exhausted, the meter became an
open circuit. It was therefore necessary for the consumer to pay for a further supply of
electricity, whereupon, the supplier's agent would unlock the meter from its mounting
and invert it restoring the mercury to the reservoir and the supply.
In 1885 Ferranti offered a mercury motor meter with a register similar to gas meters;
this had the advantage that the consumer could easily read the meter and verify
consumption. The first accurate, recording electricity consumption meter was a DC
meter by Dr Hermann Aron, who patented it in 1883. Hugo Hirst of the British General
Electric Company introduced it commercially into Great Britain from 1888.[3] Unlike
their AC counterparts, DC meters did not measure energy. Instead they measured
charge in ampere-hours. Since the voltage of the supply should remain substantially
constant, the reading of the meter was proportional to actual energy consumed. For
example: if a meter recorded that 100 ampere-hours had been consumed on a 200 volt
supply, then 20 kilowatt-hours of energy had been supplied. Aron's meter recorded the
total charge used over time, and showed it on a series of clock dials.
Page
13
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
The first specimen of the AC kilowatt-hour meter produced on the basis of Hungarian
Ottó Bláthy's patent and named after him was presented by the Ganz Works at the
Frankfurt Fair in the autumn of 1889, and the first induction kilowatt-hour meter was
already marketed by the factory at the end of the same year. These were the first
alternating-current watt-hour meters, known by the name of Bláthy-meters. The AC
kilowatt hour meters used at present operate on the same principle as Bláthy's original
invention. Also around 1889, Elihu Thomson of the American General Electric company
developed a recording watt meter (watt-hour meter) based on an ironless commutator
motor. This meter overcame the disadvantages of the electrochemical type and could
operate on either alternating or direct current.
The most common unit of measurement on the electricity meter is the kilowatt hour
[kWh], which is equal to the amount of energy used by a load of one kilowatt over a
period of one hour, or 3,600,000 joules. Some electricity companies use the SI
megajoule instead.
Demand is normally measured in watts, but averaged over a period, most often a
quarter or half hour.
Page
14
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Distortion of the electric current by loads is measured in several ways. Power factor is
the ratio of resistive (or real power) to volt-amperes. A capacitive load has a leading
power factor, and an inductive load has a lagging power factor. A purely resistive load
(such as a filament lamp, heater or kettle) exhibits a power factor of 1. Current
harmonics are a measure of distortion of the wave form. For example, electronic loads
such as computer power supplies draw their current at the voltage peak to fill their
internal storage elements. This can lead to a significant voltage drop near the supply
voltage peak which shows as a flattening of the voltage waveform. This flattening causes
odd harmonics which are not permissible if they exceed specific limits, as they are not
only wasteful, but may interfere with the operation of other equipment. Harmonic
emissions are mandated by law in EU and other countries to fall within specified limits.
The most common type of electricity meter is the electromechanical induction watt-
hour meter.
Page
15
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
The disc is acted upon by two sets of coils, which form, in effect, a two phase induction
motor. One coil is connected in such a way that it produces a magnetic flux in
proportion to the voltage and the other produces a magnetic flux in proportion to the
current. The field of the voltage coil is delayed by 90 degrees, due to the coil's inductive
nature, and calibrated using a lag coil. This produces eddy currents in the disc and the
effect is such that a force is exerted on the disc in proportion to the product of the
instantaneous current, voltage and phase angle (power factor) between them. A
permanent magnet exerts an opposing force proportional to the speed of rotation of the
disc. The equilibrium between these two opposing forces results in the disc rotating at a
speed proportional to the power or rate of energy usage. The disc drives a register
Page
16
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
mechanism which counts revolutions, much like the odometer in a car, in order to
render a measurement of the total energy used.
The type of meter described above is used on a single-phase AC supply. Different phase
configurations use additional voltage and current coils.
The disc is supported by a spindle which has a worm gear which drives the register. The
register is a series of dials which record the amount of energy used. The dials may be of
the cyclometer type, an odometer-like display that is easy to read where for each dial a
single digit is shown through a window in the face of the meter, or of the pointer type
where a pointer indicates each digit. With the dial pointer type, adjacent pointers
generally rotate in opposite directions due to the gearing mechanism.
The amount of energy represented by one revolution of the disc is denoted by the
symbol Kh which is given in units of watt-hours per revolution. The value 7.2 is
commonly seen. Using the value of Kh one can determine their power consumption at
any given time by timing the disc with a stopwatch.
Where:
P = power in watts.
For example, if Kh = 7.2 as above, and one revolution took place in 14.4 seconds, the
power is 1800 watts. This method can be used to determine the power consumption of
household devices by switching them on one by one.
Page
17
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
reading may be supplied to the power company by telephone, post or over the internet.
The electricity company will normally require a visit by a company representative at
least annually in order to verify customer-supplied readings and to make a basic safety
check of the meter.
In an induction type meter, creep is a phenomenon that can adversely affect accuracy,
that occurs when the meter disc rotates continuously with potential applied and the
load terminals open circuited. A test for error due to creep is called a creep test.
Electronic meters display the energy used on an LCD or LED display, and some can also
transmit readings to remote places. In addition to measuring energy used, electronic
meters can also record other parameters of the load and supply such as instantaneous
and maximum rate of usage demands, voltages, power factor and reactive power used
etc. They can also support time-of-day billing, for example, recording the amount of
energy used during on-peak and off-peak hours.
Solid-state design: Solid state electricity meter used in a home in the Netherlands. Basic
block diagram of an electronic energy meter As in the block diagram, the meter has a
power supply, a metering engine, a processing and communication engine (i.e. a
microcontroller), and other add-on modules such as RTC, LCD display, communication
ports/modules and so on. The metering engine is given the voltage and current inputs
and has a voltage reference, samplers and quantisers followed by an ADC section to
yield the digitised equivalents of all the inputs. These inputs are then processed using a
digital signal processor to calculate the various metering parameters such as powers,
energies etc.
The largest source of long-term errors in the meter is drift in the preamp, followed by
the precision of the voltage reference. Both of these vary with temperature as well, and
vary wildly because most meters are outdoors. Characterising and compensating for
these is a major part of meter design.
Page
18
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
The processing and communication section has the responsibility of calculating the
various derived quantities from the digital values generated by the metering engine.
This also has the responsibility of communication using various protocols and interface
with other addon modules connected as slaves to it.
RTC and other add-on modules are attached as slaves to the processing and
communication section for various input/output functions. On a modern meter most if
not all of this will be implemented inside the microprocessor, such as the real time clock
(RTC), LCD controller, temperature sensor, memory and analog to digital converters.
Robotic arm controller comprises several electronic components. Here we will discuss
the important parts of the circuit.
The ATmega16 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced
RISC architecture. By executing powerful instructions in a single clock cycle, the
ATmega16 achieves throughputs approaching 1 MIPS per MHz allowing the system
designer to optimize power consumption versus processing speed.
Page
19
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Page
20
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Page
21
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Page
22
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Page
23
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
The AVR core combines a rich instruction set with 32 general purpose working
registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU),
allowing two independent registers to be accessed in one single instruction executed in
one clock cycle. The resulting architecture is more code efficient while achieving
throughputs up to ten times faster than conventional CISC microcontrollers. The
ATmega16 provides the following features: 16K bytes of In-System Programmable Flash
Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K byte
SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG
interface for Boundary scan, On-chip Debugging support and programming, three
flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial
programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit
ADC with optional differential input stage with programmable gain (TQFP package
only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and
six software selectable power saving modes. The Idle mode stops the CPU while
allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI
port, and interrupt system to continue functioning. The Power-down mode saves the
register contents but freezes the Oscillator, disabling all other chip functions until the
next External Interrupt or Hardware Reset. In Power-save mode, the Asynchronous
Timer continues to run, allowing the user to maintain a timer base while the rest of the
device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules
except Asynchronous Timer and ADC, to minimize switching noise during ADC
conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest
of the device is sleeping. This allows very fast start-up combined with low-power
consumption. In Extended Standby mode, both the main Oscillator and the
Asynchronous Timer continue to run. The device is manufactured using Atmel’s high
density non-volatile memory technology. The On chip ISP Flash allows the program
memory to be reprogrammed in-system through an SPI serial interface, by a
conventional non-volatile memory programmer, or by an On-chip Boot program
running on the AVR core. The boot program can use any interface to download the
application program in the Application Flash memory. Software in the Boot Flash
section will continue to run while the Application Flash section is updated, providing
true Re ad-While-Write operation. By combining an 8-bit RISC CPU with In-System Self-
Programmable Flash on a monolithic chip, the Atmel ATmega16 is a powerful
Page
24
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Page
25
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
A personal computer has a serial port known as communication port or COM Port used
to connect a modem for example or any other device, there could be more than one COM
Port in a PC.
Serial ports are controlled by a special chip called UART (Universal Asynchronous
Receiver Transmitter). Different applications use different pins on the serial port and
this basically depend of the functions required. If we need to connect our PC for
example to some other device by serial port, then we have to read instruction manual
for that device to know how the pins on both sides must be connected and the setting
required.
Page
26
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Serial communication has some advantages over the parallel communication. One of the
advantages is transmission distance, serial link can send data to a remote device more
far then parallel link. Also the cable connection of serial link is simpler then parallel link
and uses less number of wires.
Serial link is used also for Infrared communication, now many devices such as laptops &
printers can communicate via inferred link.
There are two methods for serial communication, Synchronous & Asynchronous.
In Synchronous serial communication the receiver must know when to “read” the next
bit coming from the sender, this can be achieved by sharing a clock between sender and
receiver.
When a word is given to the UART for Asynchronous transmissions, a bit called the
“Start Bit” is added to the beginning of each word that is to be transmitted. The Start Bit
Page
27
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
is used to alert the receiver that a word of data is about to be sent, and to force the clock
in the receiver into synchronization with the clock in the transmitter.
After the Start Bit, the individual bits of the word of data are sent, each bit in the word is
transmitted for exactly the same amount of time as all of the other bits
When the entire data word has been sent, the transmitter may add a Parity Bit that the
transmitter generates. The Parity Bit may be used by the receiver to perform simple
error checking. Then at least one Stop Bit is sent by the transmitter.
If the Stop Bit does not appear when it is supposed to, the UART considers the entire
word to be garbled and will report a Framing Error.
Page
28
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
SIMCom Wireless Solutions is a subsidiary of SIM Technology Group Ltd (stock code:
2000. H.K). It is a fast growing[citation needed] wireless M2M company, designing and
offering a variety of wireless modules based on GSM/GPRS/EDGE, WCDMA/HSDPA and
TD-SCDMA technical platforms
According to ABI Insight report, SIMCom Cellular Module was number two provider of
wireless modules worldwide in 2008 with 20% acquisition of global market share in
2009 the launched SIM 900.
Page
29
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Chapter 7
References
1. Atmega 16 data sheet.
2. USB to serial data sheet.
3. Energy meter manuals
4. Serial communication manuals of AVR
5. GSM Modem manual
6. AT commands manual
Page
30
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
Appendix 1
The codding
/*
* Source code.c
* Author: acer
*/
#include <avr/io.h>
Page
31
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
#include <util/delay.h>
#include "lcd.h"
uint16_t E_data;
char digits[2];
/*Macros definition*/
Page
32
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
UBRRL = ubrr_value;
UBRRH = (ubrr_value>>8);
UCSRC=(1<<URSEL)|(3<<UCSZ0);
UCSRB=(1<<RXEN)|(1<<TXEN);
//Do nothing
return UDR;
Page
33
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
//Do nothing
UDR=data;
while(*StringPtr != 0x00)
StringPtr++;
Page
34
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
void SIM900Init(void)
char command[60];
char ret;
sprintf(command, "AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
_delay_ms(1000);
LCDClear();
ret = USARTReadChar();
if (ret == 13)
//i--;
Page
35
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
//i--;
else
LCDGotoXY(i,0);
LCDData(ret);
_delay_ms(1000);
sprintf(command, "AT+SAPBR=1,1");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0, "Setting APN");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
Page
36
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
//i--;
//i--;
else
LCDGotoXY(i,0);
LCDData(ret);
}
_delay_ms(1000);
sprintf(command, "AT+CREG?");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0, "Checking registration status");
_delay_ms(1000);
Page
37
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
else
LCDGotoXY(i,0);
LCDData(ret);
_delay_ms(1000);
sprintf(command, "AT+SAPBR=2,1");
Page
38
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0,"Querying bearer 1");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
else
LCDGotoXY(i,0);
LCDData(ret);
Page
39
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
_delay_ms(1000);
sprintf(command, "AT+HTTPINIT");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0,"Intializing HHTP");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
Page
40
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
else
LCDGotoXY(i,0);
LCDData(ret);
}
_delay_ms(1000);
}
Page
41
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
else
//LCDGotoXY(i,0);
//LCDData(ret);
}
_delay_ms(1000);
LCDClear();
sprintf(command, "AT+HTTPPARA=\"CID\",1");
USARTWriteString(command);
USARTWriteChar(13);
Page
42
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Sending HTTP Parameters");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
else
LCDGotoXY(i,0);
Page
43
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
LCDData(ret);
sprintf(command, "AT+HTTPACTION=0");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Sending HTTP Action");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
//i--;
Page
44
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
else
LCDGotoXY(i,0);
LCDData(ret);
sprintf(command, "AT+HTTPREAD");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Reading HTTP");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)
ret = USARTReadChar();
if (ret == 13)
//i--;
Page
45
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
//i--;
else
LCDGotoXY(i,0);
LCDData(ret);
int main(void)
int unit_main;
char unit_decimal;
char check=0;
InitLCD(LS_BLINK);
Page
46
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
USARTInit(103);
SIM900Init();
LCDClear();
_delay_ms(1000);
SETBIT(DDRC,BIT(5));
CLEARBIT(DDRC,BIT(4));
SETBIT(PORTC,BIT(4));
LCDClear();
/**********************************/
//save_EEPROM(20,0);
//EEPROM_write(30,0);
//EEPROM_write(40,0);
/*********************************/
int i = EEPROM_read(40);
unit_decimal = EEPROM_read(30);
unit_main = read_EEPROM(20);
LCDWriteStringXY(4,1,".");
Page
47
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
while(1)
if( (PINC&(1<<4)) == 0 )
//LCDWriteStringXY(0,1,"if loop");
SETBIT(PORTC,BIT(5));
_delay_ms(200);
CLEARBIT(PORTC,BIT(5));
i++;
LCDWriteIntXY(0,0,i,3);
EEPROM_write(40,i);
check=1;
if(i==32)
i=0;
unit_decimal ++;
EEPROM_write(30,unit_decimal);
if (unit_decimal == 100)
Page
48
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
unit_decimal = 0;
unit_main ++;
save_EEPROM(20,unit_main);
//LCDWriteIntXY(0,1,unit_main,4);
//LCDWriteIntXY(5,1,unit_decimal,2);
http_send(unit_main, unit_decimal);
_delay_ms(10000);
// else
// {
// LCDWriteStringXY(0,1,"else loop");
// }
Page
49
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
uint16_t data_l,data_h,data_f;
data_f = data;
EEPROM_write(add,data_h);
add++;
EEPROM_write(add,data_l);
uint16_t data_l,data_h;
data_h = EEPROM_read(add);
add++;
Page
50
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
data_l = EEPROM_read(add);
E_data = ((data_h<<8)|data_l);
return E_data;
// sei();
EEAR = uiAddress;
EEDR = ucData;
EECR |= (1<<EEMWE);
EECR |= (1<<EEWE);
// sei();
Page
51
ROBO INDIA | Energy Meter monitoring online using wireless Transmission
//CLEARBIT(SREG,BIT(7));
EEAR = uiAddress;
EECR |= (1<<EERE);
return EEDR;
//SETBIT(SREG,BIT(7));
Page
52