SlideShare a Scribd company logo
IOT - How to talk to Webserver
from arduino
By Indraneel Ganguli
Introduction
There has been a lot of talk on IOT (Internet of things) and how its going to be the next big thing. Devices
connected to the internet and talking to each other . This fascinated me. I thought of embarking on a small
mission of finding out and implementing a small scale project which touches on IOT.
Also I didn't wanted to spend too much money on this project and wanted a cheap way of building something
which will demonstrated IOT working. Started searching on Amazon.in to find something cheap.
The problem statement
(created one)
The problem statement i created for this project is that i need have a device talk to a webserver over
WIFI and do some action.
Need to build stuff cheaply
After a bit of research on Google , found that one can use Arduino UNO for the device (cost - Rs 450 /$6).
Arduino UNO doesn't have inbuilt WIFI capability . One needs to add Arduino WIFI Sheild to Arduino to make
it WIFI enable. Arduino WIFI shield is expensive Rs 6000 (~$90). I wanted a cheap alternative . Found
ESP8266 Serial WIFI module (cost Rs 210 /$3). The only caveat is that integrating ESP8266 with Arduino UNO
is bit of hardwork and challenge ( which i could overcome after slogging for 2 days)
Stuff needed to build one
Inventory
1. Arduino UNO - http://www.amazon.in/Development-Board-ATmega328P-ATmega16U2-
Arduino/dp/B00H1HR576/ref=sr_1_1?ie=UTF8&qid=1453694450&sr=8-1&keywords=arduino+uno
Rs 450/$6
2 ESP8266 - http://www.amazon.in/ESP8266-Serial-Wireless-Transceiver-
Module/dp/B00O34AGSU/ref=sr_1_1?ie=UTF8&qid=1453693968&sr=8-1&keywords=esp8266 - Rs 210
($3)
3. Breadboard , jumper wires . etc .
Connection Setup
1.One needs to connect Arduino UNO with ESP8266 . ESP8266 has the following connections
Connection Setup (contd ..)
2. Connect Arduino PIN 2 to TX of ESP8266 and Arduino PIN 3 to RX of ESP8266
3. Connect 3.3 V pin of Arduino to Vcc of ESP8266
4. Connect 3.3 V pin tof Arduino to CH_PD of ESP 8266
6 Connect GND pin of Arduino to GND ping of ESP8266.
How would it look after connection.
Install Arduino IDE on Mac /PC / or Linux
One need to install Arduino IDE
https://www.arduino.cc/en/Main/Software
Connect USB from Arduino to your PC . You would see power
on lights on Arduino.
Install ESP Library into Arduino IDE
Go to Tools-> Library -> Manage Libraries , in the search box
type ESP8266.
The program code (aka sketch)
#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
}
// contd to next page
The program code (contd..)
void loop()
{
Serial.begin(115200);
esp8266.begin(115200); // your esp's baud rate might be different
sendData("AT+RSTrn",2000,DEBUG); // reset module
sendData("AT+CWMODE=1rn",3000,DEBUG); // configure as access point
sendData("AT+CWJAP="WIFISSID"","WIFIPASSWORD"rn",3000,DEBUG);
sendData("AT+CIFSRrn",3000,DEBUG); // get ip address
Serial.println("Start of operation") ;
//sendData("AT+CIPSTART="TCP","x.x.x.x",yrn",3000,DEBUG);
sendData("AT+CIPSTART="TCP","192.168.0.102",8080rn",3000,DEBUG);
sendData("AT+CIPSEND=72rn",3000,DEBUG);
String sendcommand = "GET http://x.x.x.x/someURL HTTP/1.0rnrnrn"; //works for most cases
Serial.print(sendcommand.length());
String resp=sendData(sendcommand,5000,DEBUG);
The program code (contd..)
Serial.println("http response start") ;
Serial.println(resp);
Serial.println("http response stop") ;
sendData("AT+CIPCLOSErn",10000,DEBUG) ;
Serial.println("completed operation") ;
delay(30000) ;
}
String sendData(String command, const int timeout, boolean debug)
{
String response = "";
esp8266.print(command); // send the read character to the esp8266
long int time = millis();
The program code (contd..)
while( (time+timeout) > millis())
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
response+=c;
}
}
if(debug)
{
Serial.print(response);
}
return response;
}
Conclusion
This prototype shows on the arduino can talk to webserver over wifi . One can extend this basic working to
advance level like switching on LED , FANS , motors controlled. Since I have set arduino as web client , it can
connect to public ip (without natting etc).

More Related Content

PPTX
Arduino & NodeMcu
PDF
Introduction to Arduino and Circuits
PDF
Esp8266 basics
PPTX
IoT Hands-On-Lab, KINGS, 2019
PPTX
Esp8266 NodeMCU
PPTX
ESP8266 Wifi Nodemcu
PDF
lesson2 - Nodemcu course - NodeMCU dev Board
PDF
Home automation-in-the-cloud-with-the-esp8266-and-adafruit-io
Arduino & NodeMcu
Introduction to Arduino and Circuits
Esp8266 basics
IoT Hands-On-Lab, KINGS, 2019
Esp8266 NodeMCU
ESP8266 Wifi Nodemcu
lesson2 - Nodemcu course - NodeMCU dev Board
Home automation-in-the-cloud-with-the-esp8266-and-adafruit-io

What's hot (20)

PDF
Cassiopeia Ltd - ESP8266+Arduino workshop
PDF
NodeMCU ESP8266 workshop 1
PPTX
Remote tanklevelmonitor
PDF
Introduction to Arduino
PPT
IoT with Arduino
PDF
lesson1 - Getting Started with ESP8266
PPTX
Esp8266 - Intro for dummies
PPT
Arduino technical session 1
PPTX
Basics of arduino uno
KEY
Internet of Things
PDF
lwM2M OTA for ESP8266
PPTX
Introduction to Arduino
PPTX
Getting started with arduino workshop
PDF
Rdl esp32 development board trainer kit
PDF
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
PDF
Introducing the Arduino
PDF
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
PDF
Adafruit Huzzah Esp8266 WiFi Board
PPTX
Remote temperature monitor (DHT11)
PDF
Arduino Development For Beginners
Cassiopeia Ltd - ESP8266+Arduino workshop
NodeMCU ESP8266 workshop 1
Remote tanklevelmonitor
Introduction to Arduino
IoT with Arduino
lesson1 - Getting Started with ESP8266
Esp8266 - Intro for dummies
Arduino technical session 1
Basics of arduino uno
Internet of Things
lwM2M OTA for ESP8266
Introduction to Arduino
Getting started with arduino workshop
Rdl esp32 development board trainer kit
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
Introducing the Arduino
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Adafruit Huzzah Esp8266 WiFi Board
Remote temperature monitor (DHT11)
Arduino Development For Beginners
Ad

Viewers also liked (20)

PDF
IoT Devices And Arduino
PPTX
Beginning IoT for Developers
PPT
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
PPT
THE INTERNET OF THINGS
PPT
1-3-phacMC Pres-EDAS
PPTX
Modeling and simulation of the induction motor feed by matrix converter
PDF
The State of Arduino and IoT
PDF
IoT Knowledge Forum Slides by Deepak Gupta
PPTX
Introduction to iot and arduino uno r3
ODP
Presentación internet of thinks
PPTX
Electrical Vehicles
PPTX
Artificial intelligence in qa
PPTX
EEE presentation
PDF
Business Models For Electric Vehicle Charging Stations - OpConnect presentati...
PDF
Node MCU Fun
PPT
Building IoT with Arduino Day One
PDF
Machine learning in software testing
PPTX
IoT BASED SMART HOME USING ARDUINO
PPTX
Traction motor
PPTX
Signalling and Interlocking
IoT Devices And Arduino
Beginning IoT for Developers
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
THE INTERNET OF THINGS
1-3-phacMC Pres-EDAS
Modeling and simulation of the induction motor feed by matrix converter
The State of Arduino and IoT
IoT Knowledge Forum Slides by Deepak Gupta
Introduction to iot and arduino uno r3
Presentación internet of thinks
Electrical Vehicles
Artificial intelligence in qa
EEE presentation
Business Models For Electric Vehicle Charging Stations - OpConnect presentati...
Node MCU Fun
Building IoT with Arduino Day One
Machine learning in software testing
IoT BASED SMART HOME USING ARDUINO
Traction motor
Signalling and Interlocking
Ad

Similar to IOT Talking to Webserver - how to (20)

PDF
Webshield internet of things
PPTX
IoT Platform
PPTX
IoT Platform
PDF
Intro to arduino
PDF
មេរៀនទីd៥ conneeeection with Arduino .pdf
DOCX
Arduino and Circuits.docx
PDF
programmer avec Arduino
PDF
Digital home automation with arduino bluetooth
PPTX
Embedded system application
PDF
Home Automation Using Arduino and ESP8266
PPTX
Gas leakage detection system
PDF
Arduino Based Smart Parking System
PDF
manual Internet of ThingsArduino_IOTArdu
PDF
Syed IoT - module 5
PDF
IoT Arduino UNO, RaspberryPi with Python, RaspberryPi Programming using Pytho...
PDF
Smart Home Automation using Wi-Fi
PDF
Esp8266 Arduino Projects List -Use Arduino for Projects.pdf
PDF
IRJET- Wi-Fi Control First Person View Robot (FPV)
PDF
Start with arduino
PDF
ARUDINO UNO and RasberryPi with Python
Webshield internet of things
IoT Platform
IoT Platform
Intro to arduino
មេរៀនទីd៥ conneeeection with Arduino .pdf
Arduino and Circuits.docx
programmer avec Arduino
Digital home automation with arduino bluetooth
Embedded system application
Home Automation Using Arduino and ESP8266
Gas leakage detection system
Arduino Based Smart Parking System
manual Internet of ThingsArduino_IOTArdu
Syed IoT - module 5
IoT Arduino UNO, RaspberryPi with Python, RaspberryPi Programming using Pytho...
Smart Home Automation using Wi-Fi
Esp8266 Arduino Projects List -Use Arduino for Projects.pdf
IRJET- Wi-Fi Control First Person View Robot (FPV)
Start with arduino
ARUDINO UNO and RasberryPi with Python

Recently uploaded (20)

PPTX
了解新西兰毕业证(Wintec毕业证书)怀卡托理工学院毕业证存档可查的
PDF
Dynamic Checkweighers and Automatic Weighing Machine Solutions
PDF
YKS Chrome Plated Brass Safety Valve Product Catalogue
PPTX
Embeded System for Artificial intelligence 2.pptx
PDF
Prescription1 which to be used for periodo
PPTX
5. MEASURE OF INTERIOR AND EXTERIOR- MATATAG CURRICULUM.pptx
PPTX
executive branch_no record.pptxsvvsgsggs
PPTX
"Fundamentals of Digital Image Processing: A Visual Approach"
PPTX
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
PPTX
Syllabus Computer Six class curriculum s
PPTX
material for studying about lift elevators escalation
PPTX
kvjhvhjvhjhjhjghjghjgjhgjhgjhgjhgjhgjhgjhgjh
PPTX
ATL_Arduino_Complete_Presentation_AI_Visuals.pptx
PPTX
Operating System Processes_Scheduler OSS
PPTX
Embedded for Artificial Intelligence 1.pptx
PPTX
STEEL- intro-1.pptxhejwjenwnwnenemwmwmwm
PDF
Layer23-Switch.com The Cisco Catalyst 9300 Series is Cisco’s flagship stackab...
PPTX
02fdgfhfhfhghghhhhhhhhhhhhhhhhhhhhh.pptx
PPTX
title _yeOPC_Poisoning_Presentation.pptx
PPTX
figurative-languagepowerpoint-150309132252-conversion-gate01.pptx
了解新西兰毕业证(Wintec毕业证书)怀卡托理工学院毕业证存档可查的
Dynamic Checkweighers and Automatic Weighing Machine Solutions
YKS Chrome Plated Brass Safety Valve Product Catalogue
Embeded System for Artificial intelligence 2.pptx
Prescription1 which to be used for periodo
5. MEASURE OF INTERIOR AND EXTERIOR- MATATAG CURRICULUM.pptx
executive branch_no record.pptxsvvsgsggs
"Fundamentals of Digital Image Processing: A Visual Approach"
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
Syllabus Computer Six class curriculum s
material for studying about lift elevators escalation
kvjhvhjvhjhjhjghjghjgjhgjhgjhgjhgjhgjhgjhgjh
ATL_Arduino_Complete_Presentation_AI_Visuals.pptx
Operating System Processes_Scheduler OSS
Embedded for Artificial Intelligence 1.pptx
STEEL- intro-1.pptxhejwjenwnwnenemwmwmwm
Layer23-Switch.com The Cisco Catalyst 9300 Series is Cisco’s flagship stackab...
02fdgfhfhfhghghhhhhhhhhhhhhhhhhhhhh.pptx
title _yeOPC_Poisoning_Presentation.pptx
figurative-languagepowerpoint-150309132252-conversion-gate01.pptx

IOT Talking to Webserver - how to

  • 1. IOT - How to talk to Webserver from arduino By Indraneel Ganguli
  • 2. Introduction There has been a lot of talk on IOT (Internet of things) and how its going to be the next big thing. Devices connected to the internet and talking to each other . This fascinated me. I thought of embarking on a small mission of finding out and implementing a small scale project which touches on IOT. Also I didn't wanted to spend too much money on this project and wanted a cheap way of building something which will demonstrated IOT working. Started searching on Amazon.in to find something cheap.
  • 3. The problem statement (created one) The problem statement i created for this project is that i need have a device talk to a webserver over WIFI and do some action.
  • 4. Need to build stuff cheaply After a bit of research on Google , found that one can use Arduino UNO for the device (cost - Rs 450 /$6). Arduino UNO doesn't have inbuilt WIFI capability . One needs to add Arduino WIFI Sheild to Arduino to make it WIFI enable. Arduino WIFI shield is expensive Rs 6000 (~$90). I wanted a cheap alternative . Found ESP8266 Serial WIFI module (cost Rs 210 /$3). The only caveat is that integrating ESP8266 with Arduino UNO is bit of hardwork and challenge ( which i could overcome after slogging for 2 days) Stuff needed to build one
  • 5. Inventory 1. Arduino UNO - http://www.amazon.in/Development-Board-ATmega328P-ATmega16U2- Arduino/dp/B00H1HR576/ref=sr_1_1?ie=UTF8&qid=1453694450&sr=8-1&keywords=arduino+uno Rs 450/$6 2 ESP8266 - http://www.amazon.in/ESP8266-Serial-Wireless-Transceiver- Module/dp/B00O34AGSU/ref=sr_1_1?ie=UTF8&qid=1453693968&sr=8-1&keywords=esp8266 - Rs 210 ($3) 3. Breadboard , jumper wires . etc .
  • 6. Connection Setup 1.One needs to connect Arduino UNO with ESP8266 . ESP8266 has the following connections
  • 7. Connection Setup (contd ..) 2. Connect Arduino PIN 2 to TX of ESP8266 and Arduino PIN 3 to RX of ESP8266 3. Connect 3.3 V pin of Arduino to Vcc of ESP8266 4. Connect 3.3 V pin tof Arduino to CH_PD of ESP 8266 6 Connect GND pin of Arduino to GND ping of ESP8266.
  • 8. How would it look after connection.
  • 9. Install Arduino IDE on Mac /PC / or Linux One need to install Arduino IDE https://www.arduino.cc/en/Main/Software Connect USB from Arduino to your PC . You would see power on lights on Arduino. Install ESP Library into Arduino IDE Go to Tools-> Library -> Manage Libraries , in the search box type ESP8266.
  • 10. The program code (aka sketch) #include <SoftwareSerial.h> #define DEBUG true SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3. // This means that you need to connect the TX line from the esp to the Arduino's pin 2 // and the RX line from the esp to the Arduino's pin 3 void setup() { } // contd to next page
  • 11. The program code (contd..) void loop() { Serial.begin(115200); esp8266.begin(115200); // your esp's baud rate might be different sendData("AT+RSTrn",2000,DEBUG); // reset module sendData("AT+CWMODE=1rn",3000,DEBUG); // configure as access point sendData("AT+CWJAP="WIFISSID"","WIFIPASSWORD"rn",3000,DEBUG); sendData("AT+CIFSRrn",3000,DEBUG); // get ip address Serial.println("Start of operation") ; //sendData("AT+CIPSTART="TCP","x.x.x.x",yrn",3000,DEBUG); sendData("AT+CIPSTART="TCP","192.168.0.102",8080rn",3000,DEBUG); sendData("AT+CIPSEND=72rn",3000,DEBUG); String sendcommand = "GET http://x.x.x.x/someURL HTTP/1.0rnrnrn"; //works for most cases Serial.print(sendcommand.length()); String resp=sendData(sendcommand,5000,DEBUG);
  • 12. The program code (contd..) Serial.println("http response start") ; Serial.println(resp); Serial.println("http response stop") ; sendData("AT+CIPCLOSErn",10000,DEBUG) ; Serial.println("completed operation") ; delay(30000) ; } String sendData(String command, const int timeout, boolean debug) { String response = ""; esp8266.print(command); // send the read character to the esp8266 long int time = millis();
  • 13. The program code (contd..) while( (time+timeout) > millis()) { while(esp8266.available()) { // The esp has data so display its output to the serial window char c = esp8266.read(); // read the next character. response+=c; } } if(debug) { Serial.print(response); } return response; }
  • 14. Conclusion This prototype shows on the arduino can talk to webserver over wifi . One can extend this basic working to advance level like switching on LED , FANS , motors controlled. Since I have set arduino as web client , it can connect to public ip (without natting etc).