I am trying to learn internet of things with smart home. I will connect an ESP8266 and an Arduino with the IBM Bluemix server to control a circuit from a public IP.

I want to start with the local network for now. I have gone through a couple of links which seem like a great start http://allaboutee.com/2014/12/30/esp8266-and-arduino-webserver/

They explain how it works, and have source code but no circuit diagram. How should I connect the ESP8266 with Arduino for this example ?

enter image description here

enter image description here

#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial esp8266(rxPin,txPin);

void setup() {

void loop() {
  Serial.println("Sending an AT commands");
  while(esp8266.available()) {
    String data = esp8266.readStringUntil('\n');
    Serial.println("Got response from esp8266: " + data);

1 Answer 1


The exact same way as any other ESP8266 example. The fact that you are using it as a web server doesn't change how you wire it.

For that specific code snippet it even tells you in the comments:

// 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
  • In case of ESP8266 act as web server, can we connect TX/RS of ESP8200 to any digital pins of arduino ?
    – N Sharma
    Apr 29, 2017 at 12:10
  • 2
    Like I said: the fact you're using it as a web server makes absolutely no difference to how you wire it. It's using SoftwareSerial. SoftwareSerial will work on any pins. Take your pick.
    – Majenko
    Apr 29, 2017 at 12:45
  • I have this code pastebin.com/1miy33ne but esp is not sending a message as this condition while(esp8266.available()) { always fails
    – N Sharma
    Apr 29, 2017 at 13:08
  • I have added my pictorial representation of my project in question
    – N Sharma
    Apr 29, 2017 at 13:21
  • 2
    Another hint: Do a google image search for "ESP8266 Arduino". You will get thousands of pictures showing you how to wire it.
    – Majenko
    Apr 29, 2017 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.