Sei sulla pagina 1di 4

ESP8266 Arduino Code and 3.

3V Schematic to Send and Receive Data

1 sur 4

http://allaboutee.com/2014/12/27/esp8266-arduino-code-and-circuit/

Home
Suggest a Tutorial
Recommended Books
Microcontrollers
Subscribe

ESP8266 Arduino Code and Schematic to Send AT Commands and Print Output
by Miguel on December 27, 2014
in ESP8266
So you got the world wide famous ESP8266 wifi module to play around with it and your Arduino but dont know where/how to get started? For starters, the ESP8266 requires a 3.3V
input which we can get by connecting a 3.3V regulator to the Arduinos Vin pin. The code is just as simple, a loop to receive and send commands, and another loop to print the
response.
In this tutorial I will give you the code and circuit you need to get started. The code is below the video, and the schematic can be found in the video.

Video Tutorial:

Code For ESP8266 to Arduino Communication:


The goal of this code is simple: to receive AT commands from the Arduinos serial window to send them to the ESP8266, and to print the ESP8266s response to the command or to
other actions (such as receiving an HTTP request).
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.

#include <SoftwareSerial.h>
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()
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
}
void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}

if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}

Tweet Share
Related posts:

22/01/2015 11:23

ESP8266 Arduino Code and 3.3V Schematic to Send and Receive Data

2 sur 4

http://allaboutee.com/2014/12/27/esp8266-arduino-code-and-circuit/

How To Use the ESP8266 and Arduino as a Webserver


ESP8266 Arduino LED Control (Control The Digital Pins Via WiFi, Send Data From Webpage to Arduino)
ESP8266 Android Application to Control Arduino Digital Pins and Toggle LEDs
How To Send Data From MATLAB To Your Arduino
Stellaris LaunchPad Code Examples: How To Use The RGB LED For Digital Output

22/01/2015 11:23

ESP8266 Arduino Code and 3.3V Schematic to Send and Receive Data

3 sur 4

http://allaboutee.com/2014/12/27/esp8266-arduino-code-and-circuit/

5 Comments

Chetan Patil

why too much effort??


Just follow these 2 steps....!!!!!!!!
1) connect ESP8266 Rx pin to Arduino Rx, ESP8266 Tx to Arduino Tx, ESP 3v -> Arduino 3v,
ESP gnd-> Arduino gnd.
2) Upload this 2 lines sketch to your arduino board.
/* -------Start------------*/
void setup() {}
void loop() {}
/* -------End!!!!!!!-------*/
thats it!!!!!!!!!!! :)
>>>>>>>>>>>>>>>>>>>MAGIC<<<<<<<<<<<<<<<<<<<

Miguel

Mod

The 3.3V pin from the Arduino cannot supply enough current for the ESP8266 when it
is constantly transmitting data.

Rob

Thanks for the video. I've got my 8266 using the 3.3v rail from an old ATX PSU. other than
that, my configuration is identical. However, the 8266 just returns junk text. I have tried
every baud rate in the software serial to no avail. The text Iget in the serial monitor is a little
different each time I apply power to the 8266. I can read some of the text some of the time
inbetween the jarbled message.
mX,Ga0>P$#te&
x[Vendohinkeron:0.9eady
^erong sySOR
=
wro
ER
Or another time it was like this (I think I see version 9.2.4 in there)
[Ca
H2VvouK$yodor:wwKi?.9.2.45)jorZ
+?
Any thoughts?
I have scoped the 3.3V rail from the ATX PSU and I see it is getting 3.6V actually. Could that
be a problem?

Rob

I switched to the 3.3V from the Arduino (I know it will not work under load, but just
for testing the AT commands) and it works. So I suspect the 3.6V from the PSU was
causing the issue.

Jas

Very nice video thank you :) Can you post the php script pls :)

ESP8266 Arduino LED Control Control


Digital Pins From Webpage

Arduino GPS Tutorial: Get Latitude and


Longitude Coordinates

I have a video about


thathttps://www.youtube.com/watch?...and
also more videos if you want to learn more

PIC18 Explorer Board LCD Code With SPI


Library

HiHow would I dispay


values I stored on a SD card wichwas read
from tempereture sensor ? Or even

hi friend, when i execute a gps


coding in Arduino, when i see in serial
moniter, there is only special character is

Magician Chasis Robot Wireless Control


Interface With Arduino, LabVIEW, and

Hi,Can you pass LAbView


Vi ???

22/01/2015 11:23

ESP8266 Arduino Code and 3.3V Schematic to Send and Receive Data

4 sur 4

http://allaboutee.com/2014/12/27/esp8266-arduino-code-and-circuit/

Previous post: PIC Tutorial: 4-Digit 7-Segment LED


Next post: How To Use the ESP8266 and Arduino as a Webserver

Search:

AllAboutEE Facebook Page:

Categories
Circuits
ESP8266
LabVIEW
Microcontrollers
Arduino
ARM
AVR
PIC
PIC18 Explorer Board
Phone Development
Android
Uncategorized
Get smart with the Thesis WordPress Theme from DIYthemes.
WordPress Admin

22/01/2015 11:23

Potrebbero piacerti anche