forked from Circuito-io/ESP8266_SoftwareSerial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirmware.ino
More file actions
72 lines (47 loc) · 2.65 KB
/
Copy pathFirmware.ino
File metadata and controls
72 lines (47 loc) · 2.65 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Robo-Plan Technologies LTD: 08/2016
The purpose of this Arduino Sketch is to check the ESP8266-01 as a peripheral wifi board connected to
an Arduino Uno board via a 5-3.3 logic converter with SoftwareSerial using ESP8266 AT command library created by ITEAD.
The original library can be found: https://github.com/itead/ITEADLIB_Arduino_WeeESP8266
Our goal was to create an Esp8266 AT command library (based on ITEAD library),
that would work well on software serial on most ESP8266 devices, no matter the firmware, or the initial baudrate.
Therefore, we are distributing this preliminary library. Please connect the Esp8266-01 and run this example.
Write to us about any bugs, comments, issues, improvement proposals, etc.
We have modified the original library due to Software serial baudrate problems.
Now, the initialize function, when using software serial only, will set the ESP8266 baudrate to 9600.
The sketch sets the ESP8266 baudrate to 9600 by default for software serial and to 115200 with hardware serial.
Then it connects to your AP, checks the version of the ESP8266, sends a TCP request to google.com and displays the response on the serial monitor.
Notes:
- In order to run the example, first connect the ESP8266 via Software Serial to your arduino board using a logic converter,
as shown in the wiring figure attached.
- Enter your SSID and PASSWORD below.
- If using SoftwareSerial make sure the line "#define ESP8266_USE_SOFTWARE_SERIAL" in ESP8266.h is uncommented.
Troubleshooting:
- If you receive partial response from the esp8266 when using software serial -
go to C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.h
Change line 42: #define _SS_MAX_RX_BUFF 64 // RX buffer size
To: #define _SS_MAX_RX_BUFF 256 // RX buffer size
this will enlarge the software serial buffer.
- Sometime setting the baudrate on initialization fails, try resetting the Arduino, it should work fine.
*/
#include "ESP8266.h"
const char *SSID = "WIFI-SSID";
const char *PASSWORD = "WIFI-PASWWORD";
SoftwareSerial mySerial(10, 11); //SoftwareSerial pins for MEGA/Uno. For other boards see: https://www.arduino.cc/en/Reference/SoftwareSerial
ESP8266 wifi(mySerial);
void setup(void)
{
//Start Serial Monitor at any BaudRate
Serial.begin(57600);
Serial.println("Begin");
if (!wifi.init(SSID, PASSWORD))
{
Serial.println("Wifi Init failed. Check configuration.");
while (true) ; // loop eternally
}
}
void loop(void)
{
Serial.println("Sending Request to www.google.com");
wifi.httpGet();
delay(4000);
}