Sei sulla pagina 1di 28

Industrial Training Report

On

Internet Of Things

Submitted In partial fulfillment of the requirement

for the award

of

the degree of

Bachelors of technology

In

Electronics and Communication

Engineering

Submitted to: Er. Bharti Sood submitted by: Ankush Mathur

Name of guide : DR. Sarwan Singh roll no. MAU16UEC016

MAHARAJA AGRASEN INSTITUTE OF

TECHNOLOGY,BADDI(HP)
ACKNOWLEDGEMENT

I , ANKUSH MATHUR, the student of MAHARAJA AGRASEN UNIVERSITY


extremely grateful to “DR. SARWAN SINGH “for the confidence bestowed in me.
At this juncture I feel deeply honored in expressing my sincere thanks to our head
of institute MR.SARWAN SINGH for making the resources available at right time
and providing valuable insights leading to the successful completion of my
training.

I take this opportunity to express my profound gratitude and deep regard to my


guide DR. SARWAN SINGH for her exemplary guidance, monitoring and
constant encouragement throughout the course of this thesis. The blessing, help
and guidance given by her time to time shall carry me a long way in the journey of
life on which I am about to in embark.

I am obliged to staff members of NIELIT for the valuable information provided by


them in their respective field. I am grateful for their co-operation during the of my
assignment.

I would also like to thank Head-Civil Engineering Department, TPO and all the
faculty members of MAHARAJA AGRASEN INSTITUTE OF TECHNOLOGY
for their critical advice and guidance without which this project would not have
been possible.

Lastly, I thank almighty, my parents, brother and friends for their constant
encouragement without which this assignment would not be possible.
ABSTRACT

Industrial training is an important phase of a student life. A well planned, properly


executed and evaluated industry training help a lot in developing a professional
attitude. It develop an awareness of industrial approach to problem solving, based
on a broad understanding of process and mode of operation of organization. The
aim and motivation of this industrial training to receive discipline, skills, teamwork
and technical knowledge through a proper training environment, which will help
me, as a student in the field of Information Technology, to develop a
responsiveness of the self-disciplinary nature of problem in information and
communication technology.

The purpose of this report is to introduce the various aspect of internet of things
which play a key role in our day to day life such as for automation ,smart city
,smart street light ,water distribution etc.
Contents

S. No. Description Page No.

1 CHAPTER 1: INTRODUCTION

2 CHAPTER-II: Literature Survey

3 CHAPTER III: Training Work

4 CHAPTER IV: Result and Discussion

5 CHAPTER V:Conclusion & Future scope of training

6 REFRENCES

7 Appendix
CHAPTER 1: INTRODUCTION

Introduction to IOT

The internet of things (IOT) is the network of physical objects or “things”


embedded with electronics, software, sensors & network connectivity, which
enables these objects to collect & exchange data.
IOT allows objects to be sensed & controlled remotely across existing network
infrastructure, creating opportunities for more direct integration between the
physical world & computer based systems & resulting in improved efficiency,
accuracy & economic benefit.
Architecture view of IoT
The term Internet of Things (often abbreviated IoT) was coined by industry
researchers but has
emerged into mainstream public view only more recently. IoT is a network of
physical devices,
including things like smart phones, vehicles, home appliances, and more, that
connects to and
exchange data with computer.
Internet of Things represents a general concept for the ability of network
devices to sense and
collect data from the world around us, and then share that data across the
Internet where it can be
processed and utilized for various interesting purposes. Some also use the term
industrial Internet interchangeably with IoT. This refers primarily to
commercial applications of IoT technology in the world of manufacturing. The
Internet of Things is not limited to industrial applications,
however.

What internet of things can do for us?


Some future consumer applications envisioned for IoT sound like science
fiction, but some of the
more practical and realistic sounding possibilities for the technology include:
 Receiving warnings on your phone or wearable device when IoT
networks detect some physical danger is detected nearby.
 Self-parking automobiles.
 Automatic ordering of groceries and other home supplies.
 Automatic tracking of exercise habits and other day-to-day personal activity
including goal tracking and regular progress reports.

Potential benefits of IoT in the business world include:


 location tracking for individual pieces of manufacturing inventory.
 fuel savings from intelligent environmental modeling of gas-powered
engines.
 new and improved safety controls for people working in hazardous
environments.
Network Devices and the Internet of Things
All kinds of ordinary household gadgets can be modified to work in an IoT
system. Wi-Fi network adapters, motion sensors, cameras, microphones and
other instrumentation can be embedded in these devices to enable them for
work in the Internet of Things. Home automation systems already implement
primitive versions of this concept for things like smart light bulbs, plus other
devices like wireless scales and wireless blood
pressure monitors that each represent early examples of IOT gadgets. Wearable
computing devices like smart watches and glasses are also envisioned to be key
components in future IoT systems.
The same wireless communication protocols like Wi-Fi and Bluetooth naturally
extend to the Internet of Things also.
Issues Around IoT
 Internet of Things immediately triggers questions around the privacy of
personal data.
 Whether real-time information about our physical location or updates
about our weight
 and blood pressure that may be accessible by our health care providers,
having new kinds
 and more detailed data about ourselves streaming over wireless networks
and potentially around the world is an obvious concern.
 Supplying power to this new proliferation of IoT devices and their
network connections
 can be expensive and logistically difficult. Portable devices require
batteries that
 someday must be replaced. Although many mobile devices are optimized
for lower
 power usage, energy costs to keep potentially billions of them running
remains high.

CHAPTER-II: Literature Survey

History of the Internet of Things

The idea of adding sensor and intelligence to basic objects was discussed
throughout the 1980s and 1990s (and there are arguably some much earlier
ancestors), but apart from some early projects -- including an internet-connected
vending machine -- progress was slow simply because the technology wasn't ready.
Processors that were cheap and power-frugal enough to be all but disposable were
required before it became cost-effective to connect up billions of devices.
The adoption of RFID tags-- low-power chips that can communicate wirelessly --
solved some of this issue, along with the increasing availability of broadband
internet and cellular and wireless networking. The adoption of IPv6 -- which,
among other things, should provide enough IP addresses for every device the world
(or indeed this galaxy) is ever likely to need -- was also a necessary step for the
IoT to scale. Kevin Ashton coined the phrase 'Internet of Things' in 1999, although
it took at least another decade for the technology to catch up with the vision.

"The IoT integrates the interconnectedness of human culture -- our 'things' -- with
the interconnectedness of our digital information system -- 'the internet.' That's the
IoT,"

Adding RFID tags to expensive pieces of equipment to help track their location
was one of the first IoT applications. But since then, the cost of adding sensors and
an internet connection to objects has continued to fall, and experts predict that this
basic functionality could one day cost as little as 10 cents, making it possible to
connect nearly everything to the internet.

The IoT was initially most interesting to business and manufacturing, where its
application is sometimes known as machine-to-machine (M2M), but the emphasis
is now on filling our homes and offices with smart devices, transforming it into
something that's relevant to almost everyone. Early suggestions for internet-
connected devices included 'blog objects' (objects that blog and record data about
themselves to the internet), ubiquitous computing invisible computing, and
pervasive computing. However, it was Internet of Things and IoT that stuck.

Interfacing of LCD
A Liquid Crystal Display is an electronic device that can be used to show
numbers or text. There are two main types of LCD display, numeric displays
(used in watches ,calculators etc) and alphanumeric text displays (often used in
devices such as photocopiers and mobile telephones).The display is made up of
a number of shaped ‘crystals’. In numeric displays these crystals are shaped into
‘bars’, and in alphanumeric displays the crystals are simply arranged into
patterns of ‘dots’. Each crystal has an individual electrical connection so that
each crystal can be controlled independently.
When the crystal is ‘off’ (i.e. when no current is passed through the crystal) the
crystal reflect the same amount of light as the background material, and so the
crystals cannot be seen. However when the crystal has an electric current passed
through it, it changes shape and so absorbs more light. This makes the crystal
appear darker to the human eye - and so the shape of the dot or bar can be seen
against the background.
On most LCD displays there is memory for 40 characters on each line. Each
space in the RAM memory can be thought of as a ‘box’ which is ready to hold a
single character.

Introduction to Arduino

A micro-controller is a small computer on a single integrated circuit containing


a processor core, memory, and programmable input/output peripherals. The
important part for us is that a micro-controller contains the processor (which all
computers have) and memory, and some input/output pins that you can control.
often called GPIO -General Purpose Input Output pins). The Arduino platform
has become quite popular with people just starting out with electronics, and for
good reason. Unlike most previous programmable circuit boards ,the Arduino
does not need a separate piece of hardware (called a programmer) in order to
load new code onto the board – you can simply use a USB cable. Additionally,
the Arduino IDE uses a simplified version of C++, making it easier to learn to
program. Finally, Arduino provides a standard form factor that breaks out the
functions of the micro-controller into a more accessible package.
Arduino Board
There are many varieties of Arduino boards (explained on the next page) that
can be used for different purposes. Some boards look a bit different from the
one
Below , but most Arduinos have the majority of these components in common:

Components of Arduino board


 Power USB(1)
 USB 1.0 A TO B CABLES
 A to B connector cable
 Power (Barrel Jack):
 Voltage Regulator(3)
 Crystal Oscillator(4)
 Arduino Reset(17)
 Analog pins(10)
 Power LED indicator(13)
 TX and RX LEDs (14)
 Digital I/O(15)
 AREF(16)
.

Integrated development environment


A arduino C/C++ sketch, as seen by the arduino IDE programmer, consist of only
two functions.
Setup: This function is called once when a sketch starts after power-up or reset. It
is used to
Initialize variables, input and output pin modes, and other libraries needed in the
sketch.
Loop: After setup has been called, function loop is executed repeatedly in the main
program.
It controls the board until the board is powered of or is reset.

Introduction to ESP8266

The ESP8266 Wi-Fi Module is a self contained SOC with integrated TCP/IP
protocol stack that can give any microcontroller access to your Wi-Fi network.
The ESP8266 is capable of either hosting an application or offloading all Wi-Fi
networking functions from another application processor.
Each ESP8266 module comes pre-programmed with an AT command set
firmware meaning, you can simply hook this up to your Arduino device and get
about as much Wi-Fi-ability as a Wi-Fi Shield offers (and that’s just out of the
box).The ESP8266module is an extremely cost effective board with a huge, and
ever growing, community.
ESP 8266 Applications
 Smart power plugs
 Home automation
 Mesh network
 Industrial wireless control
 IP Cameras
 Sensor networks
 Wearable electronics
 Wi-Fi location-aware devices
 Security ID tags

Raspberry pi

A Raspberry Pi is a credit card-sized computer originally designed for


education, inspired by 1981 BBC Micro. Creator Eben Upton’s goal was to
create a low-cost device that would improve programming skills and hardware
understanding at pre- university level.31
Computer and can provide all the expected abilities that implies, at a low power
consumption level.
Raspberry Pi Board
Different Types of Raspberry Pi Models
The different types of raspberry pi models are following:
 Raspberry Pi 1 model B
 Raspberry Pi 1 model A
 Raspberry Pi 1model A+
 Raspberry Pi Zero
 Raspberry Pi 2
Features:
 Quad-core Cortex-A53 CPU at 1.2GHz with a Video Core IV GPU
clocked at 300-400MHz (3D clocked at 300MHz, video at 400MHz)
 1GB of RAM,
 802.11n wireless
 power consumption of 4W

CHAPTER III: Training Work

IOT based Smart Street Light

I n t o d a y’ s w o r l d w e a l l a r e w e l l a c q u a i n t e d wi t h o u r n a t i o n ’ s
e n e r g y s c e n a r i o . We are well aware of the fact that not only the available
power is less than the demand but also it is being wasted on a large scale .The
wastage is in the form of unnecessary usages of light .So we need an efficient
and renewable energy systems that has long term advantages. O u r p r o j e c t i s
a b o u t i n t e l l i g e n t S o l a r Li g h t e n i n g S ys t e m u s i n g l o w c o s t
microcontroller and two way modules to control traffic using smart sensors. It
is
a w i r e l e s s s ys t e m t h a t i s e f f i c i e n t , c o s t e f f e c t i v e , p r a c t i c a l , e c o
f r i e n d l y e a s i l y accessible, and automatic using renewable energy sources like
solar panels and led.
Overview
Street lighting is one of the important parts of a city’s infrastructure where the
main function is to illuminate the city’s streets during daily hours of the day. The
project proposes a smart energy efficient street lighting system based on low cost
microcontroller and using two way Street module. The main objective is to design
energy efficient based controller for controlling the light emitting diode based
streetlamp via appropriate lighting levels control. This system consists of a
microcontroller, light Sensor, current Sensor, laser Sensor ,Module and a set of
the light emitting diode module. While , the controlling and managing of the
system is based on the presence of traffic and environmental conditions. +our
different levels of streetlight brightness has been used for lighting up the street
proportional to the different situations (discussed later). The system was
programmed to automatically turn off during the hours of daylight and only
operate during the night and heavy raining or bad weather. The system also uses a
manual mode to operate it form a remote place but according to the given
conditions. Several numbers of tests have been conducted to test and validate the
proposed prototype in the different environment .While using a solar panel the
system offers reduction in power consumption. &ach pole is working as an
independent unit and is robust ,efficient and intelligent. Around 11/$2-/ reduction
in power consumption can be achieved through this proposed system if it were to
use on the e3isting power lines. Hardware used in IOT based Smart Parking
System
 PIR Sensor
PIR sensor detects a human being moving around within approximately
10m from the sensor. This is an average value, as the actual detection
range is between 5m and 12m.PIR are fundamentally made of a pyro
electric sensor, which can detect levels of infrared radiation. For items that
need to discover when an individual has left or entered the area. PIR
sensors are incredible, they are flat control and minimal effort, have a wide
lens range, and are simple to interface with.
Most PIR sensors have a 3-pin connection at the side or bottom. One pin
will be ground, another will be signal and the last pin will be power. Power
is usually up to 5V. Sometimes bigger modules don’t have direct output and
instead just operate a relay which case there is ground, power and the two
switch associations. Interfacing PIR with microcontroller is very easy and
simple. The PIR acts as a digital output so all you need to do is listening for
the pin to flip high or low. The motion can be detected by checking for a
high signal on a single I/O pin. Once the sensor warms up the output will
remain low until there is motion, at which time the output will swing high for
a couple of seconds, then return low. If motion continues the output will
cycle in this manner until the sensors line of sight of still again. The PIR
sensor needs a warm-up time with a specific end goal to capacity fittingly.
This is because of the settling time included in studying nature’s domain.
This could be anyplace from 10-60 seconds.

 Jump wire
A jump wire (also known as jumper, jumper wire, jumper cable, DuPont wire, or
DuPont cable) is an electrical wire, or group of them in a cable, with a connector or
pin at each end (or sometimes without them – simply "tinned"), which is normally
used to interconnect the components of a breadboard or other prototype or test
circuit, internally
or with other equipment or components, without soldering.
 Arduino Microcontroller
Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It
has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs,16 MHz quartz crystal, 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.

 ESP8266 NODEMCU
Node MCU is an open source IoT platform. It includes firmware which runs on
the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on
the ESP-12 module. The term "Node MCU" by default refers to the firmware
rather than the development kits. The firmware uses the Lua scripting language. It
is based on the eLua project, and built on the Espressif Non-OS SDK for ESP8266.
It uses many open source projects, such as lua-cjson, and spiffs.
CHAPTER IV : Result and Discussion

As we know IOT is the upcoming technology, in future every appliance will be


connected with this IOT technology, in fact the revolution has started. I have made
a project on Smart Street Light which work on the idea of “How to save our light
sources”.I n t o d a y’ s w o r l d w e a l l a r e w e l l a c q u a i n t e d w i t h o u r n a t i o
n ’ s e n e r g y s c e n a r i o . We are well aware of the fact that not only the available
power is less than the demand but also it is being wasted on a large scale .The
wastage is in the form of unnecessary usages of light .So we need an efficient
and renewable energy systems that has long term advantages. O u r p r o j e c t i s
a b o u t i n t e l l i g e n t S o l a r Li g h t e n i n g S ys t e m u s i n g l o w c o s t
microcontroller and two way modules to control traffic using smart sensors. It is
a w i r e l e s s s ys t e m t h a t i s e f f i c i e n t , c o s t e f f e c t i v e , p r a c t i c a l , e c o
f r i e n d l y e a s i l y accessible, and automatic using renewable energy sources like
solar panels and led.

The main aim of project is to automatic switch ON/OFF the street light by sensing
the vehicles or human body radiation. In this projects IR’s and PIR’s are used for
sensing the human body and the vehicles. As the sensor senses the human body or
the vehicles the street light associated with respect to that sensor will switch ON &
OFF after certain time.
CHAPTER V: Future scope of training & conclusion

It can also be used as Consumer applications such as smart home, elder care etc.

 It can also used as Smart home i.e.: IOT devices are a part of the larger
concept of home automation, which can include lighting, heating and air
conditioning, media and security systems. Long term benefits could include
energy savings by automatically ensuring lights and electronics are turned
off.
 It can also used as Elder care i.e. : One key application of smart home is to
provide assistance for those with disabilities and elderly individuals. These
home systems use assistive technology to accommodate an owner's
specific disabilities. Voice control can assist users with sight and mobility
limitations while alert systems can be connected directly to cochlear
implants worn by hearing impaired users.

 It can also be used as Commercial applications such as medical & health


care, transportation, manufacturing, agriculture, infrastructure application,
Metropolitan scale deployments, etc.

 It can also used as Medical and healthcare i.e.: The Internet of Medical
Things is an application of the IoT for medical and health related purposes,
data collection and analysis for research, and monitoring. This ‘Smart
Healthcare’, as it can also be called, led to the creation of a digitized
healthcare system, connecting available medical resources and healthcare
services.
 It can also used as Transportation i.e.: The IoT can assist in the integration
of communications, control, and information processing across various
transportation systems. Application of the IoT extends to all aspects of
transportation systems (i.e. the vehicle, the infrastructure, and the driver or
user). Dynamic interaction between these components of a transport system
enables inter and intra vehicular communication, smart traffic control, smart
parking and fleet management, vehicle control, and safety and , electronic
toll collection systems, logistic ad assistance Building and home automation
 It can also used as Manufacturing i.e.: The IOTcan realize the seamless
integration of various manufacturing devices equipped with sensing,
identification, processing, communication, actuation, and networking
capabilities. Based on such a highly integrated smart cyber physical space, it
opens the door to create whole new business and market opportunities for
manufacturing. Network control and management of manufacturing
equipment, asset and situation management, or manufacturing process
control bring the IoT within the realm of industrial applications and smart
manufacturing as well. The IoT intelligent systems enable rapid
manufacturing of new products, dynamic response to product demands,
and real-time optimization of manufacturing production and supply chain
networks, by networking machinery, sensors and control systems together.
 It can also used as Agriculture i.e.: There are numerous IOTapplications in
farming such as collecting data on temperature, rainfall, humidity, wind
speed, pest infestation, and soil content. This data can be used to automate
farming techniques, take informed decisions to improve quality and
quantity, minimize risk and waste, and reduce effort required to manage
crops. For example, farmers can now monitor soil temperature and
moisture from afar, and even apply IoT-acquired data to precision
fertilization programs
 It can also used as Infrastructure applications i.e. :Monitoring and
controlling operations of sustainable urban and rural infrastructures
like bridges, railway tracks and on- and offshore wind-farms is a key
application of the IoT. The IoT infrastructure can be used for monitoring
any events or changes in structural conditions that can compromise
safety and increase risk. IoT can benefit the construction industry by
cost saving, time reduction, better quality workday, paperless workflow
and increase in productivity. It can help in taking faster decisions and
save money with Real-Time Data Analytics. It can also be used for
scheduling repair and maintenance activities in an efficient manner, by
coordinating tasks between different service providers and users of
these facilities. IoT devices can also be used to control critical
infrastructure like bridges to provide access to ships. Usage of IoT
devices for monitoring and operating infrastructure is likely to improve
incident management and emergency response coordination, and
quality of service, up-times and reduce costs of operation in all
infrastructure related areas. Even areas such as waste management can
benefit from automation and optimization that could be brought in by
the IoT.
 It can also used as Metropolitan scale deployments i.e.: There are several
planned or ongoing large-scale deployments of the IoT, to enable better
management of cities and systems. For example, Songdo, South Korea, the
first of its kind fully equipped and wired smart city, is gradually being built,
with approximately 70 percent of the business district completed as of June
2018. Much of the city is planned to be wired and automated, with little or
no human intervention.
 It can also used as Energy management i.e.: Significant numbers of energy-
consuming devices (e.g. switches, power outlets, bulbs, televisions, etc.)
already integrate Internet connectivity, which can allow them to
communicate with utilities to balance power generation and energy usage
and optimize energy consumption as a whole. These devices allow for
remote control by users, or central management via a cloud-based
interface, and enable functions like scheduling (e.g., remotely powering on
or off heating systems, controlling ovens, changing lighting conditions etc.).
The smart grid is a utility-side IoT application; systems gather and act on
energy and power-related information to improve the efficiency of the
production and distribution of electricity.
CONCLUSION

We have learnt about various aspects of IOT in which we have made different
program based on lcd interfacing, learn about sensors, modules etc. By using
arduino we can automates home appliances , street lights , footmats etc. We have
also done a project on Smart Street Light whose main aim is to automatic switch
ON/OFF the street light by sensing the vehicles or human body radiation. In this
projects IR’s and PIR’s are used for sensing the human body and the vehicles. As
the sensor senses the human body or the vehicles the street light associated with
respect to that sensor will switch ON & OFF after certain time.
REFRENCES:

1. Brown, Eric (13 September 2016). "Who Needs the Internet of Things?".
Linux.com. Retrieved 23 October 2016.
2. Brown, Eric (20 September 2016). "21 Open Source Projects for IoT".
Linux.com. Retrieved 23 October 2016.
3. "Internet of Things Global Standards Initiative". ITU. Retrieved 26 June
2015.
4. Hendricks, Drew. "The Trouble with the Internet of Things". London
Datastore. Greater London Authority. Retrieved 10 August 2015.
5. Wigmore, I. (June 2014). "Internet of Things (IoT)". TechTarget.
6. "Internet of Things (IoT)". gatewaytechnolabs.com.
7. "The "Only" Coke Machine on the Internet". Carnegie Mellon University.
Retrieved 10 November 2014.
8. "Internet of Things Done Wrong Stifles Innovation". InformationWeek. 7 July
2014. Retrieved 10 November 2014.
APPENDIX

Program used in IOT based on Smart Street Light System:


const int ldr = A1;
const int trigPin = 5;
const int echoPin = 6;
#define led 3
int printme;
int ldrVal = 300;
long duration;
int distance;
#include <SoftwareSerial.h>
#define RX 10
#define TX 11
String AP = "princes"; // CHANGE ME
String PASS = "123456789"; // CHANGE ME
String API = "4PBL35S1GP0QC8YB"; // CHANGE ME
String HOST = "api.thingspeak.com";
String PORT = "80";
String field = "field1";
int countTrueCommand;
int countTimeCommand;
boolean found = false;
int valSensor = 1;
SoftwareSerial esp8266(RX,TX);
const int sensorIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

void setup() {
// put your setup code here, to run once:
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
pinMode(3,OUTPUT);
esp8266.begin(115200);
sendCommand("AT",5,"OK");
sendCommand("AT+CWMODE=1",5,"OK");
sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}

void loop() {
// put your main code here, to run repeatedly:
Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707;
AmpsRMS = (VRMS * 1000)/mVperAmp;
Serial.print(AmpsRMS);
Serial.println(" Amps RMS");Serial.println(String(AmpsRMS));

long duration, distance;


digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
ldrVal = analogRead(ldr);
Serial.println(ldrVal);
Serial.println(distance);
if (distance < 10&&ldrVal<300)
{
digitalWrite(led, HIGH);
delay(500);
if(led==HIGH&&AmpsRMS<0.42)
{
printme=1;
}
// } digitalWrite(3, HIGH);
// delay(500);
}
else
{
digitalWrite(3, LOW);
delay(1000);
}
valSensor = getSensorData();
// AmpsRMS=getCurrentsensorValue();
String getData = "GET /update?api_key="+ API +"&"+ field
+"="+String(valSensor) +"&field2=" +
String(AmpsRMS)+"&field3="+String(distance)+"&field4="+String(printme);
//String getData = "GET /update?api_key="+ API +"&"+ field2
+"="+String(AmpsRMS);
sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
esp8266.println(getData);delay(1500);countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");

}
int getSensorData(){
return ldrVal; // Replace with
}
int getCurrentsensorValue()
{return AmpsRMS;
}
void sendCommand(String command, int maxTime, char readReplay[]) {
Serial.print(countTrueCommand);
Serial.print(". at command => ");
Serial.print(command);
Serial.print(" ");
while(countTimeCommand < (maxTime*1))
{
esp8266.println(command);//at+cipsend
if(esp8266.find(readReplay))//ok
{
found = true;
break;
}

countTimeCommand++;
}
if(found == true)
{
Serial.println("Ok");
countTrueCommand++;
countTimeCommand = 0;
}

if(found == false)
{
Serial.println("Fail");
countTrueCommand = 0;
countTimeCommand = 0;
}

found = false;
}
float getVPP()
{
float result;

int readValue; //value read from the sensor


int maxValue = 0; // store max value here
int minValue = 1024; // store min value here

uint32_t start_time = millis();


while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the maximum sensor value*/
minValue = readValue;
}
}
// Subtract min from max
result = ((maxValue - minValue) * 5.0)/1024.0;

return result;
}

Potrebbero piacerti anche