itead / iteadlib_arduino_weeesp8266 Goto Github PK
View Code? Open in Web Editor NEWAn easy-to-use Arduino ESP8266 library besed on AT firmware.
License: MIT License
An easy-to-use Arduino ESP8266 library besed on AT firmware.
License: MIT License
Sorry I have two question
(1).I run the sample code "Connect Wifi", but complier error "Serial1' was not declared in this scope".
(2).The circuit isn't it?
http://microcontrollerelectronics.com/wp-content/uploads/2014/12/esp8266_bb.png
Hi everyone,
I need to monitoring WiFi package.
I'm not sure "ITEADLIB_Arduino_WeeESP8266" can use.
I'm not good English **
Thank you
This is a question and it's also related to #30 issue.
There is an MQTT implementation for ESP8266 and (probably it also can be used for) Arduino, it's based on the WiFi Shield API, as I understand. Also as I see people try to implement the WiFi Shield API to make their libraries compatible with other existing libraries which use WiFi.
The question is why did you decide to create your own API instead of implementing the WiFi Shield API which is a de-facto standard for Arduino, as I see it?
In theory, I can be wrong, if this library would has the WiFi Shield API, then it could be easy to use the mentioned MQTT implementation and any other.
Currently the baud rate is hardcoded to be 9600, it would be nice to make this a setting so that users who use the library could set the baud rate.
hi boes:
i want to see whta at comman we send & what i recved, but if i ouput with
Serial.println();
all operation will be failed, but if i do NOT out, all are ok. any suggest???
THX
Help me, please!
Code in standart WiFi Arduino module for UDP:
void setup() {
...
Udp.begin(localPort);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if (packetSize){ ... }
}
How to use your library to listen UDP packets to a specific port?
bool ESP8266::eATCWLAP
extra \r
change:
return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list, 10000);
to:
return recvFindAndFilter("OK", "\r\n", "\r\n\r\nOK", list, 10000);
The example in /examples/HTTPGET cannot work on UNO.
It always failed to establish a tcp connection.
After I change the buffer size in line 65 from 1024 to 128, it worked smoothly.
So I wondered this is an issue or not?
Hi,
I'm a noob, so forgive me if this isn't the right place to post.
I have an UNO and are using SoftwareSerial to connect to my ESP8266.
When I compile, I get the following error "error: no matching function for call to 'ESP8266::ESP8266(SoftwareSerial&)'" when it reaches the line below "ESP8266 wifi(mySerial);"
Below is a snippet of my code.
-----Snip-----
SoftwareSerial mySerial(2, 3); // RX, TX
ESP8266 wifi(mySerial);
void setup(void)
----Snip-----
Regards
Dean
Why unit8_t? i realy can't convert it to ssomewhat, that i can compare with String or maybe int data types
can i change recived data type?
This could be useful method by itself. You had it in the restart method. Similar to the kick() method, except it just keeps waiting. Every once in a while my board just seems to lock up, it would be nice if we could make it auto-reset itself. I haven't gotten that far yet. :-)
bool ESP8266::waitForStable(void)
{
unsigned long start = millis();
while (millis() - start < 3000) {
if (eAT()) {
delay(1500); /* Waiting for stable */
return true;
}
delay(100);
}
}
Hello,
exist some possibility to change baud rate for hardware serial and software serial from main sketch?
or i must change it in ESP8266.h ??
and if not exist can you modify lib for doing that
Can I use this lib with Arduino Leonardo?
And does It matters firmware version (esp8266)?
Thanks
I am trying to connect two arduino UNO using this code but there is some issue in following function..
len = wifi.recv(buffer, sizeof(buffer), 200);
ERROR:
client.ino: In function ‘void loop()':
client:48: error: ‘class ESP8266′ has no member named ‘recv’
‘class ESP8266′ has no member named ‘recv’
Please provide me a solution for this
Hello,
I am having a problem with the getLocalIP() function as it only returns a white space.
Example :
00160901
reset ok
to access point ok
Join AP success
<--- This is where I should get the ip, but it displays a white space instead.
multiple ok
start server ok
setup end
Here is my setup code.
#include "ESP8266.h"
#define SSID "ssid"
#define PASSWORD "pass"
ESP8266 wifi(Serial1);
void setup() {
Serial.begin(115200);
// GET FIRMWARE VERSION OF THE ESP8266
Serial.println(wifi.getVersion().c_str());
// RESET WIFI
if (wifi.restart()) {
Serial.print("reset ok\r\n");
} else {
Serial.print("reset failure\r\n");
}
// SET MODE
if (wifi.setOprToStation()) {
Serial.print("to access point ok\r\n");
} else {
Serial.print("to access point err\r\n");
}
// REACH ACCESS POINT
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.println(wifi.getLocalIP().c_str());
} else {
Serial.print("Join AP failure\r\n");
}
// ENABLE MULTIPLE CONNECTION
if (wifi.enableMUX()) {
Serial.print("multiple ok\r\n");
} else {
Serial.print("multiple err\r\n");
}
// START SERVER
if (wifi.startTCPServer(8000)) {
Serial.print("start server ok\r\n");
} else {
Serial.print("start server err\r\n");
}
Serial.print("setup end\r\n");
}
Thank you for the lib by the way, despite this little thing, it works great.
Hi,
My ESP8266 firmware is
AT+GMR
AT version:0.21.0.0
SDK version:0.9.5
OK
My arduino is a leonardo R3
I have used for the first time your library this weekend. I was not able to use your example ConnectWifi.
I have update the example with my SSID and password. and also ESP8266 object creation as follow
ESP8266 wifi(Serial1,115200);
the log I get is something like this:
setup begin
FW Version:0.21.0.0
to station ok
Join AP failure
setup end
In my first test application of the ESP8266 I was doing as follow and it able to join the SSID
String cmd="AT+CWMODE=1";
Serial.print("SEND: ");
Serial.println(cmd);
Serial1.println(cmd);
Serial1.flush();
delay(2000);
cmd="AT+CWJAP="";
cmd+=ssid;
cmd+="","";
cmd+=pwd;
cmd+=""";
Serial.print("SEND: ");
Serial.println(cmd);
Serial1.println(cmd);
Serial1.flush();
delay(5000);
return Serial1.find("OK");
I have a look to your .CPP file, and you are doing quite the same but I was not able to connect my WIFI.
I test I have updated you .CPP file as follow,
bool ESP8266::joinAP(String ssid, String pwd)
{
//sATCWMODE(1);
delay(2000);
String cmd="AT+CWMODE=1";
Serial.print("SEND: ");
Serial.println(cmd);
m_puart->println(cmd);
m_puart->flush();
delay(2000);
cmd="AT+CWJAP="";
cmd+=ssid;
cmd+="","";
cmd+=pwd;
cmd+=""";
Serial.print("SEND: ");
Serial.println(cmd);
m_puart->println(cmd);
m_puart->flush();
delay(5000);
return m_puart->find("OK");
}
and this time i was able to connect my WIFI.
any clue for me?
Regards
I have also try without success:
modifying
bool ESP8266::sATCWJAP
bool ESP8266::sATCWJAP(String ssid, String pwd)
{
String data;
rx_empty();
m_puart->print("AT+CWJAP="");
Serial.print("AT+CWJAP="");
m_puart->print(ssid);
Serial.print(ssid);
m_puart->print("\",\"");
Serial.print("\",\"");
m_puart->print(pwd);
Serial.print(pwd);
m_puart->println("\"");
Serial.println("\"");
delay(5000);
return m_puart->find("OK");
/*
data = recvString("OK", "FAIL", 10000);
if (data.indexOf("OK") != -1) {
return true;
}
return false;
*/
}
the output was AT+CWJAP="MYSSID","MYPASSWORD"
Hello
Is there any way to send an mail using the library ?
Mickael.
does anyone know what is the Problem? i can not compile it with arduino IDE 1.6.6, i get this error:
...WeeESP8266-master/ESP8266.h:38:7: note: in expansion of macro 'ESP8266'
class ESP8266 {
^
:0:9: error: expected unqualified-id before numeric constant
thanks!
It would be good to include the pinout in the readme
I'm using an arduino nano v3 and I got this error
ConnectWiFi:28: error: no matching function for call to ‘ESP8266::ESP8266(SoftwareSerial&)’
/home/ricardo/.AIDE/arduino/libraries/WeeESP8266-master/ESP8266.h:37: note: candidates are: ESP8266::ESP8266(HardwareSerial&)
/home/ricardo/.AIDE/arduino/libraries/WeeESP8266-master/ESP8266.h:29: note: ESP8266::ESP8266(const ESP8266&)
If I just write
ESP8266 wifi(Serial);
Apparently my problem has gone but I can't connect the ESP with my AP
Any idea?
Can this lib work with an Arduino Nano?
Thanks
Thank you for your library, you are very kind for the arduino community.
Here is the issue I faced while using the library, I was fine when I use standalone AT command.
Like the one below, it is fully functional.
AT version:0.21.0.0
SDK version:0.9.5
Yet, when I am using the library, it all goes err.
Mine is Arduino Uno, ESP8266 version as above.
Is it my hardward problem or should I update my firmware?
AT+GMR
AT+CWMODE?
to station err
AT+CWJAP="SSID","PASSWORD"
Join AP failure
setup end
Good night. How can I use this library with Texas Instrument Tiva C 123gxl and Energia IDE?
I've try, but without success.
Extra \r in eATCIFSR
change
return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", list);
to:
return recvFindAndFilter("OK", "\r\n", "\r\n\r\nOK", list);
UNO does not work with 0.9.5 firmware and SoftwareSerial
What version of firmware used?
Compiling the "HTTPGET" example, throws this error:
HTTPGET:32: error: no matching function for call to 'ESP8266::ESP8266(SoftwareSerial&)'
Hello,
i found your great library but i'm having some issues with the TCP server.
With the given example after 1 successfully request i am unable to do a second one. No reponse whatsoever.
Do you have any idea why ?
Thank you in advance!
In bool ESP8266::eATGMR I think there is an extra \r at least with my version of the esp8266 (0020000903 compiled @ Dec 15 2014 19:43:31 AITHINKER-20141206)
change:
return recvFindAndFilter("OK", "\r\r\n", "\r\n\r\nOK", version);
to:
return recvFindAndFilter("OK", "\r\n", "\r\n\r\nOK", version);
Hello,
I am having trouble getting my esp8266 to communicate via UART with my Arduino Mega.
I downloaded the SDK version 1.0.0 with AT firmware version 0.22 from the
espressif website
Here are the files I flashed using the NodeMCU flasher program for Windows:
boot_v1.2.bin at 0x00000
user1.512.new.bin at 0x01000
blank.bin at 0x7E000
Are these files the correct ones, with the correct offsets?
Is there a way to ensure that I have the correct firmware installed before running the "test" example?
Thank you.
What modifications are required to allow the code to work with arduino micro (https://www.adafruit.com/products/1086) ?
Thanks,
Chris.
SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
ESP8266 wifi(mySerial);
void setup(void)
{
Serial.begin(9600);
mySerial.begin(9600);
Serial.print("setup begin\r\n");
Serial.print("FW Version: ");
Serial.println(wifi.getVersion().c_str());
if (wifi.setOprToStation()) {
Serial.print("to station ok\r\n");
} else {
Serial.print("to station err\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
while(1){
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
break;
} else {
Serial.print("Join AP failure\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
}
Serial.print("setup end\r\n");
}
void loop(void)
{
}
I have connected esp8266 to arduino uno as
ESP8266_TX->RX1(D19)
ESP8266_RX->TX1(D18)
ESP8266_CH_PD->3.3V
ESP8266_VCC->3.3V
ESP8266_GND->GND.
setOprToStation() is returning False every time try to connect with the AP.
Please help me
Please tell me can this library connect to ntp server and get unix time?
When you call releaseTCP() and the module is still receiving content after a send() command the release command will fail. It took me a while to figure this out... my current workaround is to add a 10s delay after send() but that's not really a longterm solution.
The problem is that if you use a small receive buffer, say 128 bytes, it exits way before all the content is received.
The tcp messages sending and receiving fine , but the udp message not being received
any one facing same problem ?
the code
ESP8266 wifi(Serial2);
for arduino due defined as global freeze all serial ports.
I need to move inside setup.
void setup(void)
{
Serial.begin(9600);
Serial.print("setup begin\r\n");
ESP8266 wifi(Serial2);
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
Hello,
i'm trying to plug a Wee serial wifi module (http://wiki.iteadstudio.com/Wee_Serial_WIFI_Module) on my Arduino Uno, through an Xbee shield (https://hackspark.fr/fr/xbee-shield.html) .
After some tough tryouts to make upload work again, i can now upload my sketch to the arduino (the sketch is the example from the library).
All i get is
setup begin
FW Version:
to station err
Join AP failure
setup end
What can I do ?
Thank you very much
Hi, thanks for the great library, but i have a problem using it.
I test my board with the example "HTTPGET" . But i got an error. "create tcp err".
I have changed www.baidu.com to a local server running on my computer but still get the same error.
Here is the log:
setup begin
FW Version:AT+GMR
00200.9.5(b1)
compiled @ Dec 25 2014 21:40:28
AI-THINKER Dec 25 2014
OK
to station + softap ok
Join AP success
IP:AT+CIFSR
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:a2:ff:e3"
+CIFSR:STAIP,"192.168.1.5"
+CIFSR:STAMAC,"18:fe:34:a2:ff:e3"
OK
single ok
setup end
create tcp err
release tcp err
The following code:
auto str = wifi.getJoinedDeviceIP();
cout.print("wifi.getJoinedDeviceIP() = ");
cout.println(str);
returns "" even after connecting to an AP. This code was inserted into the example code, and all the other "debug" print statements look correct (i.e. I'm sure I'm connecting to AP and setting up server correctly).
I am using the above code
`#include
SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
ESP8266 wifi(mySerial);
void setupesp8266()
{
while (1) {
Serial.print("restaring esp8266...");
if (esp8266.restart()) {
Serial.print("ok\r\n");
break;
}
else {
Serial.print("not ok...\r\n");
Serial.print("Trying to kick...");
while (1) {
if (esp8266.kick()) {
Serial.print("ok\r\n");
break;
}
else {
Serial.print("not ok... Wait 5 sec and retry...\r\n");
delay(5000);
}
}
}
}
Serial.begin(9600);
mySerial.begin(115200);
Serial.print("setup begin\r\n");
Serial.print("FW Version: ");
Serial.println(esp8266.getVersion().c_str());
if (esp8266.setOprToStation()) {
Serial.print("to station ok\r\n");
break;
} else {
Serial.print("to station err\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
while(1){
if (esp8266.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
break;
} else {
Serial.print("Join AP failure\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
}
Serial.print("setup end\r\n");
}
void setup(void)
{
setupesp8266();
}
void loop(void)
{
}
`
but is giving following error
ConnectWiFi:12: error: 'esp8266' was not declared in this scope
if (esp8266.restart()) {
^
ConnectWiFi:35: error: 'esp8266' was not declared in this scope
Serial.println(esp8266.getVersion().c_str());
^
ConnectWiFi:38: error: break statement not within loop or switch
break;
^
Using library ESP8266Wifi in folder: C:\Users\admin\Documents\Arduino\libraries\ESP8266Wifi (legacy)
Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
'esp8266' was not declared in this scope
please help me
Are you planning to add MQTT and REST support to your awesome library?
This would be enormous for IoT projects.
I do not want to run the ESP8266 as standalone - because of some other reasons.
But there is no solution out there to have a ESP8266 connected to Arduino or Teensy
and use MQTT library directly on your Arduino / Teensy.
The following line in uint32_t ESP8266::recvPkg(uint8_t *buffer, uint32_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id)
memcpy(buffer,
data.substring(index_colon + 1, index_colon + 1 + len).c_str(),
ret);
(around line 367 of ESP8266.cpp)
Returns incomplete data if a 0x00 occurs in 'data' as this is interpreted as '\0' and terminates the string. I have made a hacky solution by buffering all incoming data in a char array 'charData', and replacing the above with the following:
memcpy(buffer, &charData[index_colon + 1], ret);
I would advise using a statically assigned char array as a global buffer for all of your functions, rather than using the arduino String object, as the dynamic memory allocation is slow and may cause problems.
when sending the char '\0' (normal thing on transfering binary data), the "wait for 'SEND OK'" will fail.
In bool ESP8266::recvFindAndFilter
at the end it has:
data = "";
return false;
If those two if statements are never satisfied it returns an empty string which shouldn't happen, but when it does it appears like the library isn't working, when it's just a minor bug. I think instead it should be:
data = data_tmp;
return false;
That way if the filter doesn't work, it'll just return the full string.
Hi,
I am trying to connect ESP8266 and Arduino UNO. I downloaded the ESP8266 library and tried the ConnectWifi program in it. But I am not able to connect to the wifi network. It is giving me the following error.
setup begin
FW Version:
to station err
Join AP failure
setup end
PFB the program I have uploaded:
SoftwareSerial mySerial(3,2);
ESP8266 wifi(mySerial);
//#define SERIAL_BUFFER_SIZE 256
//#define SERIAL_RX_BUFFER_SIZE 64
//ESP8266 wifi(Serial);
void setup(void)
{
Serial.begin(9600);
mySerial.begin(115200);
Serial.print("setup begin\r\n");
Serial.print("FW Version: ");
Serial.println(wifi.getVersion().c_str());
if (wifi.setOprToStation()) {
Serial.print("to station ok\r\n");
} else {
Serial.print("to station err\r\n");
}
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
} else {
Serial.print("Join AP failure\r\n");
}
Serial.print("setup end\r\n");
}
void loop(void)
{
}
Kindly someone help me to connect the shield with the network. I already made some research with other issues section in Git hub but nothing happened.
Thanks in advance.
I'm using an atmega32u4 board and working with this library.. Sometimes things seem to work pretty well, but every other reset or so.. wifi.getIpStatus() was returning a blank string. I added some debugging to the recvString method and it is clearly reading the correct data from the ESP (by printing out the characters as they arrive). However, the string append seems to be failing (probably due to memory issues). Printing the length of the string after the "data += a" line is always returning 0.
Do you have any suggestions for how I might use this library and avoid this issue? I've started refactoring the library to use cstrings instead of Arduino StringObjects in the hopes that it'll fix this and cause the library to use significantly less memory. I'll provide a fork and pull request if/when I finish this refactoring.
Hello
Where is this declared ? I have an issue when compiling.
Mickael.
I guess it makes sense to add startUDPServer method similar to TCP's startTCPServer methods (and stopTCPServer, setTCPServerTimeout too).
The AT command for this is the same so it should not be a problem. We are missing the ability to recieve UDP data with current version of the library. (Should use startTCPServer with my UDP Server which is confusing).
I'm running the example TCPClientSingleUNO it's straight forward, however when I complile with only the #defines needed to connect changed I get this.
TCPClientSingleUNO.ino:30:22: error: no matching function for call to 'ESP8266::ESP8266(SoftwareSerial&)'
ESP8266.h defines this. Any ideas where the problem my lay?
Hello, Recently I bough a ESP8266 ESP-12-Q and I would Like to connect it to Arduino UNO, so that I can control sensors from the internet.
This one:
And Im using the code below, which I got from here: #36
#include <ESP8266.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2); // uno sw RX(pin3) --> wifi TX, uno sw TX(pin2) --> wifi RX
ESP8266 wifi(mySerial);
void setup() {
Serial.begin(9600);
mySerial.begin(115200);
setupESP8266();
}
void loop (){
}
void setupESP8266()
{
while (1) {
Serial.print("restaring wifi...");
if (wifi.restart()) {
Serial.print("ok\r\n");
break;
}
else {
Serial.print("not ok...\r\n");
Serial.print("Trying to kick...");
while (1) {
if (wifi.kick()) {
Serial.print("ok\r\n");
break;
}
else {
Serial.print("not ok... Wait 5 sec and retry...\r\n");
delay(5000);
}
}
}
}
Serial.print("setup begin\r\n");
Serial.print("FW Version:");
Serial.println(wifi.getVersion().c_str());
while (1) {
if (wifi.setOprToStation()) {
Serial.print("to station ok\r\n");
break;
}
else {
Serial.print("to station err\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
}
while (1) {
if (wifi.joinAP("MYNETWORK", "PASS")) {
Serial.print("Join AP success\r\n");
break;
}
else {
Serial.print("Join AP failure\r\n");
Serial.println("Wait 5 seconds and try again...");
delay(5000);
}
}
Serial.print("setup end\r\n");
}
I connected like this:
ESP --------- External Power (3.3V 1A) ---------- UNO
Vcc 3.3V
GRD GRD
CH_PD(EN) 3.3v
TX ------------------------------------------------------ Digital 3
RX ------------------------------------------------------ Digital 2
When I open the Serial Console this is the info I get:
I tried several speeds for the software serial (9600, 19200, 115200) no worked.. always the same thing. What am I missing here?
Any tip helps! I really would like to use Wee, fits perfectly to my project but I can not get this ESP working....
Thank you for your time!
10 000 milliseconds for connect to AP - very small. ESP have not time to connect AP.
20000 milliseconds - good.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.