IOT Smart Grid Monitoring Webserver - Report
IOT Smart Grid Monitoring Webserver - Report
In recent years, the demand for electricity has peaked due to increase in
number of electrical devices, gadgets and industrial appliances. This sudden
change in load causes Load shedding problems due to un-predictability and lack of
real time monitoring which may be resolved on this day using IOT. The main
theme of the IoT, or Internet of Things, is a perception in which the Internet is used
around the globe, incorporating everyday phenomena. In this project, IoT is
incorporated for monitoring parameters in electrical grid. The distribution load
parameters can be monitored through the IoT using current and voltage sensors.
Smart grid is one of the features of smart city model in which energy consumption
monitoring and management of grid is done. So to measure electrical grid
parameters like voltage, current and power values sensors are deployed and
measured data will be connected to IOT based web-server and updated in real-time
through a mobile app or webpage. Smart grids also will provide a vital
communication between the provider and consumer.
CHAPTER-1
INTRODUCTION
On the other hand, by using this model any consumer or organization can monitor
their smart energy system, which enhances their energy consumption system.
Apart from this, by applying the principles of this implementation model it
becomes easy to utilize smart power monitoring systems in an efficient way.The
intelligent energy monitoring and protection system has been regarded as a single
of the greatest innovative technologies that assists in utilizing the links provided by
the Internet of Things and provides smart home the ability to tracking and
management of energy consumption and protection of grid against electrical faults.
The WiFi module integrated with arduino microcontroller that aids in data
transmission can be communicated through IOT which presents a sophisticated
power-monitoring device.
The Smart grid is a technology that makes electric grid control, automate and
manage the growing demands and needs of electricity, allowing two-way
communication between the utility and the customers. Smart grid improves power
quality, provides efficient transmission, quicker rerouting when equipment fails or
when outages occur and reduces peak demand. An essential feature of a smart grid
is to improve the efficiency, economics, and sustainability of the generation,
transmission, and distribution of electricity by the use of information and
communications technology. The smart grid, being a vast system, utilizes various
communications and networking technologies with its applications, which include
both wired and wireless communications. “Web of Things” refers to the general
idea of things, especially everyday objects, which are readable, recognizable,
locatable, addressable, and/or controllable via the Internet, irrespective of the
communication means (whether via RFID, wireless LAN, wide- area networks, or
other means).
LITERATURE SURVEY
One year after the previous edition of the Cluster book (2012), it is clear that the
Internet of Things (IOT) has reached many different players and gained additional
recognition. Smart Cities (and regions), Smart Car and Mobility, Smart Home and
Assisted Living, Smart Industries, Public safety, Energy environmental protection,
Agriculture, and Tourism have received a lot of attention as potential Internet of
Things application areas. In line with this trend, the majority of governments in
Europe, Asia, and the Americas now see the Internet of Things as a source of
innovation and growth. Although larger players in some application areas have yet
to recognise the potential, many of them are paying close attention or even
hastening the pace by coining new terms for the IoT and adding new components
to it.Furthermore, end users in the private and business sectors have developed
significant competence in dealing with smart devices and networked applications.
As the Internet of Things evolves, its potential is increased by combining it with
related technology approaches and concepts such as cloud computing, the Future
Internet, Big Data, robotics, and Semantic technologies. The concept is not new in
and of itself, but it has only recently become apparent as related concepts have
begun to reveal synergies by combining them. However, the Internet of Things is
still maturing, in particular due to a number of factors, which limit the full
exploitation of the IOT. Among those factors the following appear to be most
relevant
PROPOSED SYSTEM
PROPOSED SYSTEM
In the proposed system, power management can be done automatically in grid side
by knowing energy usage time to time. This proposed system utilizes an Arduino
microcontroller and sensors. The measured electrical parameters can be displayed
on the webpage or mobile device through the Wi-Fi module. The proposed system
design eliminates the involvement of human in electricity maintenance. The user
can monitor energy consumption in watts from a webpage by providing a channel
id for the load. The Webpage utilizes the WiFi IOT monitoring app or webpage
analytics to analyze the energy usage to give more detailed description and
visualization of the energy usage statistics. Wi-Fi unit performs IOT operation by
sending energy data of the load to the webpage which can be accessed through the
channel id of any android mobile device.
ADVANTAGES
BLOCK DIAGRAM
BLOCK DIAGRAM DESCRIPTION
This system presents an integration of both hardware and software. The software is
used to monitor power usage and the consumption of household appliances and
control systems through current and voltage sensors and notification of any
mismatches in parameters. The system consists of Arduino UNO, a WiFi module
(ESP8266), ZMPT101B voltage sensor and ACS712-20 current sensor modules.
Arduino UNO is a microcontroller used to program customized coding for
executing output at any instant time. It is also a very capable microcontroller that
receives and sends information over the Internet with various modules and shield
platforms. However, in this case, the ESP8266 WiFi module is used as the
platform. The ESP8266 WiFi module is famous for its IoT applications. The
outputs are shown in a IoT implementation based on the webserver or mobile
application (APPS). Android based IOT monitoring is used to display the voltage,
current, and power consumption where the web or mobile application is used to
visualize the data and trigger alarm, when necessary. In the web and mobile
application systems, the energy usage statistics of power consumption parameters
are determined. It displays the detailed monitoring of electrical quantities such as
voltage, current, power, and energy.
Sensors can be embedded in electrical loads and can also be connected to home-
related gadgets. The overcurrent or circuit overloading can be detected earlier
based on advanced IoT applications where consumers’ alarm triggers. Relay
module is used to protect against faults by automatically disconnecting the loads
from fault conditions.
CIRCUIT DIAGRAM
CIRCUIT DESCRIPTION
First, both analog readings of V/I sensors for AC appliances are converted into
data streams in compliance with internet protocol, and are forwarded to a IP
address by the Arduino serial communication.
All of the important AC power parameters are sent to the IoT platform through Wi-
Fi network. The values of voltage, current, electric power are displayed in the IOT
monitoring in mobile app.
Therefore, the acquired readings of instantaneous voltage and current are sent to
the Wi-Fi module through serial data communication. When fault condition is
detected arduino sends signal to the relay module and the load gets disconnected
from the grid automatically. And the buzzer produces alarm during the fault
conditions thus producing alerts.
The Signal Condition gives reading each time the arduino LED flashes and
the microcontroller takes this reading and sends it to the cloud using ESP 8266.
ESP 8266 is a Wi-Fi module, which provides internet facility for the
microcontroller. ESP 8266 transmits the data serially to the web page or IOT WiFi
android app for a display that can be viewed from anywhere in the world. The ESP
8266 can be provided with a 5V supply through a ESP8266 TTL Adaptor and
Arduino Uno board is powered by a 12V adapter. Arduino is programmed using
Arduino IDE and the Wi-Fi module is programmed using AT commands in the
same Arduino IDE.
CHAPTER-5
HARDWARE DETAILS
ARDUINO UNO
Overview
The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet).
It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6
analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an
ICSP header, and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with
an AC-to-DC adapter or battery to get started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-
serial driver chip. Instead, it features the Atmega8U2 programmed as a USB-to-
serial converter.
"Uno" means one in Italian and is named to mark the upcoming release of Arduino
1.0. The Uno and version 1.0 will be the reference versions of Arduino, moving
forward. The Uno is the latest in a series of USB Arduino boards, and the reference
model for the Arduino platform; for a comparison with previous versions, see the
index of Arduino boards.
Open-Source Hardware
The Arduino platform is itself pretty useful for microcontroller projects, but that
alone is not enough to propel the popularity and widespread adoption of the
platform. Instead of closing the design of the interface board and development
environment, the entire Arduino project is deeply entrenched in the emerging
practice of open-source hardware. Unlike open-source software, of which Linux is
usually the often-cited example, open-source hardware seeks collaboration where
physical objects are the outcome. It engages a distributed model of hardware
development with contributors generally residing in different parts of the world.
Rather than closed systems, open source projects allow an individual freedom to
access the source files of a design, make improvements, and redistribute these
improvements to a larger community.
Power
The Arduino Uno can be powered via the USB connection or with an external
power supply. The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart)
or battery. The adapter can be connected by plugging a 2.1mm centre-positive plug
into the board's power jack. Leads from a battery can be inserted in the Gnd and
Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.
Fig: Arduino Uno Pin Details
Memory
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2
KB of SRAM and 1 KB of EEPROM (which can be read and written with the
EEPROM library).
Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. Arduino calculate
time by using the crystal oscillator. The number printed on top of the Arduino
crystal is 16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16 MHz.
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial
data. These pins are connected to the corresponding pins of the ATmega8U2 USB-
to-TTL Serial chip.
External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt
on a low value, a rising or falling edge, or a change in value. See the
attachInterrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite()
function.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10
bits of resolution (i.e. 1024 different values). By default they measure from ground
to 5 volts, though is it possible to change the upper end of their range using the
AREF pin and the analogReference() function. Additionally, some pins have
specialized functionality:
I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the
Wire library.
There are a couple of other pins on the board:
AREF: Reference voltage for the analog inputs. Used with
analogReference().
Reset: Bring this line LOW to reset the microcontroller. Typically used to
add a reset button to shields which block the one on the board.
Arduino Reset
We can reset our Arduino board, i.e., start our program from the beginning. We
can reset the UNO board in two ways. First, by using the reset button (17) on the
board. Second, you can connect an external reset button to the Arduino pin labelled
RESET (5).
Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as the
brain of your board. The main IC (integrated circuit) on the Arduino is slightly
different from board to board. The microcontrollers are usually of the ATMEL
Company. You must know what IC your board has before loading up a new
program from the Arduino IDE. This information is available on the top of the IC.
For more details about the IC construction and functions, you can refer to the data
sheet.
Analog pins
The Arduino UNO board has five analog input pins A0 through A5. These pins can
read the signal from an analog sensor like the humidity sensor or temperature
sensor and convert it into a digital value that can be read by the microprocessor.
ICSP pin
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino
consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often referred to
as an SPI (Serial Peripheral Interface), which could be considered as an
"expansion" of the output. Actually, we are slaving the output device to the master
of the SPI bus.
Power LED indicator
This LED should light up when you plug our Arduino into a power source to
indicate that our board is powered up correctly. If this light does not turn on, then
there is something wrong with the connection.
AREF
Digital I / O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM
(Pulse Width Modulation) output. These pins can be configured to work as input
digital pins to read logic
TX and RX LEDs
On our board, we will find two labels: TX (transmit) and RX (receive). They
appear in two places on the Arduino UNO board. First, at the digital pins 0 and 1,
to indicate the pins responsible for serial communication. Second, the TX and RX
led (13). The TX led flashes with different speed while sending the serial data. The
speed of flashing depends on the baud rate used by the board. RX flashes during
the receiving process.
Communication
The Arduino Uno has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega328 provides UART TTL
(5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX).
An ATmega8U2 on the board channels this serial communication over USB and
appears as a virtual com port to software on the computer. The '8U2 firmware uses
the standard USB COM drivers, and no external driver is needed. However, on
Windows, a .inf file is required. The Arduino software includes a serial monitor
which allows simple textual data to be sent to and from the Arduino board. The RX
and TX LEDs on the board will flash when data is being transmitted via the USB-
to-serial chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino
software includes a Wire library to simplify use of the I2C bus; see the
documentation for details. For SPI communication, use the SPI library.
Programming
The Arduino Uno can be programmed with the Arduino software (download).
Select "Arduino Uno from the Tools > Board menu (according to the
microcontroller on Wer board). For details, see the reference and tutorials.
The ATmega328 on the Arduino Uno comes preburned with a bootloader that
allows us to upload new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol (reference, C
header files).
We can also bypass the bootloader and program the microcontroller through the
ICSP (In-Circuit Serial Programming) header; see these instructions for details.
The ATmega8U2 firmware source code is available. The ATmega8U2 is loaded
with a DFU bootloader, which can be activated by connecting the solder jumper on
the back of the board (near the map of Italy) and then resetting the 8U2. We can
then use Atmel's FLIP software (Windows) or the DFU programmer (Mac OS X
and Linux) to load a new firmware. Or we can use the ISP header with an external
programmer (overwriting the DFU bootloader).
This setup has other implications. When the Uno is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from
software (via USB). For the following half-second or so, the bootloader is running
on the Uno. While it is programmed to ignore malformed data (i.e. anything
besides an upload of new code), it will intercept the first few bytes of data sent to
the board after a connection is opened. If a sketch running on the board receives
one-time configuration or other data when it first starts, make sure that the
software with which it communicates waits a second after opening the connection
and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on
either side of the trace can be soldered together to re-enable it. It's labeled
"RESET-EN". You may also be able to disable the auto-reset by connecting a 110
ohm resistor from 5V to the reset line; see this forum thread for details.
Physical Characteristics
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches
respectively, with the USB connector and power jack extending beyond the former
dimension. Four screw holes allow the board to be attached to a surface or case.
Note that the distance between digital pins 7 and 8 is 160 mil (0.16"), not an even
multiple of the 100 mil spacing of the other pins.
Working Principle
Current Sensor detects the current in a wire or conductor and generates a
signal proportional to the detected current either in the form of analog voltage or
digital output.
Current Sensing is done in two ways i.e., direct sensing and Indirect
Sensing. In Direct sensing to detect current Ohm’s law is used to measure the
voltage drop occurred in a wire when current flows through it. A current-carrying
conductor also gives rise to a magnetic field in its surrounding. In Indirect Sensing,
the current is measured by calculating this magnetic field by applying either
Faraday’s law or Ampere law. Here either a Transformer or Hall Effect sensor or
fiber optic current sensor are used to sense the magnetic field.
Fig: Functional Block Diagram
ACS712 Current Sensor uses Indirect Sensing method to calculate the
current. To sense current a liner, low-offset Hall sensor circuit is used in this IC.
This sensor is located at the surface of the IC on a copper conduction path. When
current flows through this copper conduction path it generates a magnetic field
which is sensed by the Hall Effect sensor. A voltage proportional to the sensed
magnetic field is generated by the Hall sensor, which is used to measure current.
The proximity of the magnetic signal to the Hall sensor decides the accuracy
of the device. Nearer the magnetic signal higher the accuracy. ACS712 Current
Sensor is available as a small, surface mount SOIC8 package. In this IC current
flows from Pin-1 and Pin-2 to Pin-3 and Pin-4. This forms the conduction path
where the current is sensed. Implementation of this IC is very easy.
Fig: Current Measured On the Sensing Terminals
The 20A Range Current Sensor Module ACS712 consists of a precise, low-
offset, linear Hall circuit with a copper conduction path located near the surface of
the die. Applied current flowing through this copper conduction path generates a
magnetic field in which the Hall IC converts into a proportional voltage.
This ACS721 current module is based on the ACS712 sensor, which can
accurately detect AC or DC current. The maximum AC or DC that can be detected
can reach 20A, and the present current signal can be read via analog I / O port of
Arduino.
ZMPT101B AC Voltage Sensor is the best for the purpose, where we need to
measure the accurate AC voltage with a voltage transformer. This is an ideal
choice to measure the AC voltage using Arduino/ESP8266/Raspberry Pi like an
opensource platform. In many electrical projects, engineer directly deals with
measurements with few basic requirements like High galvanic isolation, Wide
Range, High accuracy, Good Consistency.
The primary and secondary coils of this transformer have a DC resistance close
to 110Ω at 20°C. Coming back to the ZMPT101B module, it can handle AC
voltages up to 250V (50Hz/60Hz). Its secondary circuitry, centered on the
LM358 dual op-amp chip, also allows tweaking the isolated analog output via
an onboard multiturn trimpot. The recommended operating voltage of the
module is 5VDC.
Holds up to 4kV per breakdown voltage, the ratio of turns is 1: 1, but this is a
current transformer of 2mA: 2mA.
NodeMCU, a development board, utilizes the ESP8266 chip as its core but offers
more bells and whistleslike built-in Wi-Fi and a USB-to-serial converter. Though
not precisely identical, NodeMCU is constructed around ESP8266.
The phrase "NodeMCU" combines the words "node" and "MCU" (microcontroller
unit). The ESP8266microprocessor powers the NodeMCU development board,
however the term "NodeMCU" refers to thefirmware that runs on it.
The ESP8266 microcontroller can work in both analog and digital modes. While
the majority of its pins aredigital, it does include one analog input, the ADC0 pin
(sometimes designated A0).
The ESP8266 is a wireless module that has Wi-Fi functionality. It enables devices
to connect and be managed via the Internet, making it a practical and cost-effective
solution for a wide range of wireless applications and projects, including the
Internet of Things (IoT).
Let’s look at the Node MCU ESP8266 specifications and construction of this
module which makes itsuperior to its counterparts.
The onboard ESP8266 chip manufactured by Espressif Systems has an
ESP8266EX core Wi-Fi SoCand a Tensilica L106 32-bit processor in the
same chip.
Node MCU ESP8266 has 2.4GHz 802.11b/g/n Wi-fi with on-board antenna
which supportsWPA/WPA2.
It has 17 GPIO, 11 are usable( 6 are used for communication with the
onboard flash memory chip)and some of them support PWM. This GPIO
can be used to interface ESP8266 NodeMCU with theexternal environment
through sensors and actuators.
It also has UART, SDIO, SPI, I2C, I2S, and IR remote control peripheral
interface.
It operates on 2.5-3.6V and average 80mA current with temperatures
ranging from -40 to 125 C.
It comes in a QFN 32-pin ( 5mm * 5mm) package.
It supports firmware upgrades via UART download/ OTA (via network).
It also has SDK for customized development/cloud server development.
Power Pins
Usually, all boards come with power pins: 3V3, GND, and VIN. You can use these
pins to power the board (if you’re not providing power through the USB port), or
to get power for other peripherals (if you’re powering the board using the USB
port).
12V 2A SMPS
This industry power module SMPS converts AC power to 12V 5A DC. It has built-
in over-voltage, over-current, and short circuit protection. Perfectly designed and
well constructed,small and compact Size with an indicator. This is the switched-
mode power supply (SMPS)which converts 100 - 264V AC to 12V DC. It can
provide up to 5A maximum current. All typesof protections such as over-voltage
protection, over-current protection, short circuit protection,and surge-protected
output are provided in the supply.
SMPS Connector Pin Details
These SMPS are achieved high efficiency and robust to use; By using these latest
SMPS,you can reduce your electricity bill. This SMPS will provide you with a
constant output of 12V5A means we can drive applications that have a maximum
current rating up to 5A. It includes any type of motor with different RPM,
thermoelectric Peltier, etc. It has passed the CE &RoHS certification. This power
supply is built with high-quality and high-performance materials. This SMPS
power supply has a led power supply with a metal body for hidden installation for
led lighting.
SPECIFICATIONS
Output:
DC Voltage: 12V
Rated Current: 2A
Current Range: 0-5A
Rated Power: 60W
Ripple & Noise (maximum): 150mV
Voltage Adjustable Range: 10-13.2V
Voltage Tolerance: ±2.0%
Line Regulation: ±0.5%
Load Regulation: ±0.5%
Setup, Rise, Hold Up Time: 200ms, 50ms, 20ms at full load
Input:
2. It is an official Arduino software, making code compilation too easy that even a
common person with no prior technical knowledge can get their feet wet with the
learning process.
3. It is easily available for operating systems like MAC, Windows, Linux and runs
on the Java Platform that comes with inbuilt functions and commands that play a
vital role for debugging, editing and compiling the code in the environment.
6. The main code, also known as a sketch, created on the IDE platform will
ultimately generate a Hex File which is then transferred and uploaded in the
controller on the board.
7. The IDE environment mainly contains two basic parts: Editor and Compiler
where former is used for writing the required code and later is used for compiling
and uploading the code into the given Arduino Module.
Details on IDE: The IDE environment is mainly distributed into three sections
1. Menu Bar
2. Text Editor
3. Output Pane
As we download and open the IDE software, it will appear like an image below.
Arduino IDE Main Window
The bar appearing on the top is called Menu Bar that comes with five different
options as follow
File – You can open a new window for writing the code or open an existing one.
Following table shows the number of further subdivisions the file option is
categorized into.
And at the end of compilation, it will show you the hex file it has generated for the
recent sketch that will send to the Arduino Board for the specific task you aim to
achieve.
Edit – Used for copying and pasting the code with further modification for font
Tools – Mainly used for testing projects. The Programmer section in this panel is
used for burning a bootloader to the new microcontroller.
Help – In case you are feeling skeptical about software, complete help is available
from getting started to troubleshooting.
The Six Buttons appearing under the Menu tab are connected with the running
program as follow.
Menu Buttons
The check mark appearing in the circular button is used to verify the code.
Click this once you have writtenyour code.
The arrow key will upload and transfer the required code to the Arduino
board.
The dotted paper is used for creating a new file.
Menu Exmples
Output Pane
The bottom of the main screen is described as an Output Pane that mainly
highlights the compilation status of the running code: the memory used by the
code, and errors occurred in the program. You need to fix those errors before you
intend to upload the hex file into your Arduino Module.
More or less, Arduino C language works similar to the regular C language used for
any embedded system microcontroller, however, there are some dedicated libraries
used for calling and executing specific functions on the board.
The digitalRead and digitalWrite commands are used for addressing and
making the Arduino pins as an input and output respectively.
These commands are text sensitive i.e. you need to write them down the
exact way they are given like digitalWrite starting with small “d” and write
with capital “W”. Writing it down with Digitalwrite or digitalwritewon’t be
calling or addressing any function.
Example : if we want to use Pin D13 as output , the code will be;
pinMode(13, OUTPUT); followed by digitalWrite(13,HIGH);
If we want to use Pin D13 as input, the code will be : pinMode(13,
INPUT);followed by x=digitalRead(13);
Selecting Board of Arduino
In order to upload the sketch, we need to select the relevant board we are using and
the ports for that operating system. As we click the Tools on the Menu, it will open
like the figure below.
Just we go to the “Board” section and select the board wewould like to work on.
Similarly, COM1, COM2, COM4, COM5, COM7 or higher are reserved for the
serial and USB board. we can look for the USB serial device in the ports section of
the Windows Device Manager.
Folloinwg figure shows the COM4 that wehave used for my project, indicating the
Arduino Uno with COM4 port at the right bottom corner of the screen.
After correct selection of both Board and Serial Port, click the verify and then
upload button appearing in the upper left corner of the six button section or you
can go to the Sketch section and press verify/compile and then upload.
The sketch is written in the text editor and is then saved with the file
extension .ino.
It is important to note that the recent Arduino Modules will reset
automatically as you compile and press the upload button the IDE software,
however, older version may require the physical reset on the board.
As we upload the code, TX and RX LEDs will blink on the board, indicating
the desired program is running successfully.
CHAPTER-7
SOFTWARE PROGRAM
ARDUINO CODING
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //RX, TX
#define Buzzer 12
double sensorValue1 = 0;
int crosscount = 0;
int climb_flag = 0;
int val[100];
int max_v = 0;
double VmaxD = 0;
double VeffD = 0;
double Veff = 0;
double Watts = 0;
void setup()
{
Serial.begin(9600);
delay(10);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(Buzzer,OUTPUT);
mySerial.begin(9600);
delay(3000);
mySerial.print("ATE0\r\n");
delay(500);
mySerial.print("AT+CIPMUX=1\r\n");
delay(500);
mySerial.print("AT+CIPSERVER=1,80\r\n");
void loop() {
for ( int i = 0; i < 100; i++ )
{
sensorValue1 = analogRead(A0);
if (analogRead(A0) > 511)
{
val[i] = sensorValue1; }
else {
val[i] = 0; }
delay(1); }
max_v = 0;
for ( int i = 0; i < 100; i++ ) {
if ( val[i] > max_v ) {
max_v = val[i];
}
val[i] = 0; }
if (max_v != 0) {
VmaxD = max_v;
VeffD = VmaxD / sqrt(2);
Veff = (((VeffD - 420.76) / -90.24) * -210.2) + 210.2;
}
else {
Veff = 0;
}
Serial.print("Voltage: ");
Serial.println(Veff);
VmaxD = 0;
unsigned int temp=0;
float maxpoint = 0;
int i=0;
for(i=0;i<500;i++) {
if(temp = analogRead(A1),temp>maxpoint) {
maxpoint = temp; } }
adcvalue = maxpoint;
Voltage = (adcvalue / 1024.0) * 5000;
Current = ((Voltage - offsetvoltage) / sensitivity);
Current = ( Current ) / ( sqrt(2) );
Serial.print("Current: ");
Serial.println(Current,2);
mySerial.print("\r\n");
mySerial.print("Current: ");
mySerial.print(Current);
mySerial.println("A");
mySerial.print("Power: ");
mySerial.print(Watts);
mySerial.print("W");
digitalWrite(Buzzer,LOW);
delay(1000);
}
PROTOTYPE OF HARDWARE
Prototype of Hardware
CHAPTER-8
CONCLUSION