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 ?
#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() {
Serial.begin(9600);
esp8266.begin(9600);
delay(1000);
}
void loop() {
Serial.println("Sending an AT commands");
esp8266.println("AT");
delay(30);
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 ofESP8200
to any digital pins of arduino ?N Sharma– N Sharma2017年04月29日 12:10:10 +00:00Commented Apr 29, 2017 at 12:10 -
2Like 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– Majenko2017年04月29日 12:45:42 +00:00Commented 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 failsN Sharma– N Sharma2017年04月29日 13:08:03 +00:00Commented Apr 29, 2017 at 13:08 -
I have added my pictorial representation of my project in questionN Sharma– N Sharma2017年04月29日 13:21:24 +00:00Commented Apr 29, 2017 at 13:21
-
2Another hint: Do a google image search for "ESP8266 Arduino". You will get thousands of pictures showing you how to wire it.Majenko– Majenko2017年04月29日 13:56:51 +00:00Commented Apr 29, 2017 at 13:56