Giter VIP home page Giter VIP logo

arduino-esp8266's Introduction

Hi there πŸ‘‹

Somehow you've landed here πŸ€”

I am probably building something or learning some stuff. Feel free to look around, check my contributions below, website and LinkedIn profile.

arduino-esp8266's People

Contributors

diaoul avatar groovygrovesy avatar jonathanchristison avatar lasselukkari avatar pastukhov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-esp8266's Issues

Send UDP data

I'm trying to send UDP NTP packet by code like this

Serial.print("connect NTP server: ");
Serial.println(getStatus(wifi.connect(4, ESP8266_PROTOCOL_UDP, "pool.ntp.org", 123)));
delay(20);
byte ntpP[48] = {0xEC,0x06,0x00,0xE3};
Serial.println(getStatus(wifi.send(4, ntpP)));

But in fact, all 0x00 values is skipped and ESP8266 receive only 3 bytes
Do you know why please?

Canot get IP

Serial.begin(9600);      // sets the serial port to 9600
Serial1.begin(9600); 
wifi.begin(Serial1);
wifi.setTimeout(20000);
wifi.quitAP();
//get version
char versions[16] = {};
Serial.print("getVersion: ");
Serial.print(getStatus(wifi.getVersion(versions, 16)));
Serial.print(" : ");
Serial.println(versions);
Serial.print("setWifiMode: ");
Serial.println(getStatus(wifi.setWifiMode(ESP8266_WIFI_BOTH)));    
// setAPConfiguration
Serial.print("setAPConfiguration: ");
Serial.println(getStatus(wifi.joinAP("tamhoa.house", "")));
// setMultipleConnections
Serial.print("setMultipleConnections: ");
Serial.println(getStatus(wifi.setMultipleConnections(true)));
Serial.print("IP: ");    
char ap[32] = {};
Serial.print("getAP: ");
Serial.print(getStatus(wifi.getAP(ap)));
Serial.print(" : ");
Serial.println(ap);
  // getIP
IPAddress ip;
Serial.print("getIP STA: ");
Serial.print(getStatus(wifi.getIP(ESP8266_WIFI_STATION, ip)));
Serial.print(" : ");
Serial.println(ip);
Serial.print("getIP AP: ");
Serial.print(getStatus(wifi.getIP(ESP8266_WIFI_ACCESSPOINT, ip)));
Serial.print(" : ");
Serial.println(ip);
Serial.println("READY");

The results:
setAPConfgetVersion: OK : 0018000902-AI03
setWifiMode: NO CHANGE
setAPConfiguration: OK
setMultipleConnections: OK
IP: getAP: OK : tamhoa.house
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
READY
I viewed the router that module have ip: 192.168.0.104
Why I can not received IP?
And execute command:
Serial.println(getStatus(wifi.connect(ESP8266_PROTOCOL_TCP, IPAddress(184,106,153,149), 80)));
have result: ERROR

http request timeout problem

I am working with Arduino Uno and ESP8266.

I connected ESP8266 with Arduino Uno, and downloaded this library.
(https://github.com/Diaoul/arduino-ESP8266)..

'joinAP' was OK and 'connect' was also OK.

But the problem was http request.

"getStatus(wifi.send("GET / HTTP/1.0\r\n\r\n"))" in setup code always showed me 'TIMEOUT'.

I just changed SSID, PASS, DSP_IP and port number.. but it doesn't work well.. T.T

Below is my code.

Please save my code..


include <SoftwareSerial.h>

include "ESP8266.h"

define SSID "SSID" // WiFi ID

define PASS "PASS" // WiFi Password

define DST_IP "www.google.com" // IP address

SoftwareSerial esp8266Serial = SoftwareSerial(2, 3); // RX, TX pin num
ESP8266 wifi = ESP8266(esp8266Serial);

void setup()
{
Serial.begin(9600);

// ESP8266
esp8266Serial.begin(9600);
wifi.begin();
wifi.setTimeout(10);

/_/
/_* Basic commands ***_/
/_
**/
// test
Serial.print("test: ");
Serial.println(getStatus(wifi.test()));

// restart
Serial.print("restart: ");
Serial.println(getStatus(wifi.restart()));

// getVersion
char version[16] = {};
Serial.print("getVersion: ");
Serial.print(getStatus(wifi.getVersion(version, 16)));
Serial.print(" : ");
Serial.println(version);

// getWifiMode
///*
ESP8266WifiMode mode;
Serial.print("getWifiMode: ");
Serial.println(getStatus(wifi.getMode(&mode)));//*/
Serial.print("Wifi mode>>:");
Serial.println(mode);
if( mode != ESP8266_WIFI_STATION)
{
// setWifiMode
Serial.print("setWifiMode: ");
// Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_ACCESSPOINT)));
Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_STATION )));
}
else
Serial.println("already ESP8266_WIFI_STATION mode");

/_/
/_* WiFi commands ***_/
/_
**/
// joinAP
Serial.print("joinAP: ");
Serial.println(getStatus(wifi.joinAP(SSID, PASS)));

/_/
/_* TCP/IP commands ***_/
/_
**/
// connect
Serial.print("connect: ");
Serial.println(getStatus(wifi.connect(ESP8266_PROTOCOL_TCP, DST_IP, 80)));

// send
Serial.print("send: ");
Serial.println(getStatus(wifi.send("GET / HTTP/1.0\r\n\r\n")));

}

void loop()
{
/_/
/_* WiFi commands ***_/
/_
**/

// read data
unsigned int id;
int length;
int totalRead;
char buffer[300] = {};

if ((length = wifi.available()) > 0) {
id = wifi.getId();
totalRead = wifi.read(buffer, 300);

if (length > 0) {
Serial.print("Received ");
Serial.print(totalRead);
Serial.print("/");
Serial.print(length);
Serial.print(" bytes from client ");
//Serial.print("from client ");
Serial.print(id);
Serial.print(": ");
Serial.println((char*)buffer);
}
}
}

String getStatus(bool status)
{
if (status)
return "OK";

return "KO";
}

String getStatus(ESP8266CommandStatus status)
{
switch (status) {
case ESP8266_COMMAND_INVALID:
return "INVALID";
break;

case ESP8266_COMMAND_TIMEOUT:
return "TIMEOUT";
break;

case ESP8266_COMMAND_OK:
return "OK";
break;

case ESP8266_COMMAND_NO_CHANGE:
return "NO CHANGE";
break;

case ESP8266_COMMAND_ERROR:
return "ERROR";
break;

case ESP8266_COMMAND_NO_LINK:
return "NO LINK";
break;

case ESP8266_COMMAND_TOO_LONG:
return "TOO LONG";
break;

case ESP8266_COMMAND_FAIL:
return "FAIL";
break;

default:
return "UNKNOWN COMMAND STATUS";
break;
}
}

String getRole(ESP8266Role role)
{
switch (role) {
case ESP8266_ROLE_CLIENT:
return "CLIENT";
break;

case ESP8266_ROLE_SERVER:
return "SERVER";
break;

default:
return "UNKNOWN ROLE";
break;
}
}

String getProtocol(ESP8266Protocol protocol)
{
switch (protocol) {
case ESP8266_PROTOCOL_TCP:
return "TCP";
break;

case ESP8266_PROTOCOL_UDP:
return "UDP";
break;

default:
return "UNKNOWN PROTOCOL";
break;
}
}

Hardware Serial Port problem,

Hi,

 I try to use your library with a M2560 Serial1 and nothing work,  I had try with a "terminal" program and the port is wired correctly.  I'm sure I make a mistake but I can't find it.  Here is my small lines of code:

include <Wifi_Diaoul/ESP8266.h>

HardwareSerial esp8266Serial = Serial1;

void setup()
{
Serial.begin(115200);

esp8266Serial.begin(115200);
ESP8266 wifi = ESP8266(esp8266Serial);

wifi.begin();
wifi.setTimeout(1000);

// test
Serial.print("test: ");
Serial.println(getStatus(wifi.test()));

}

Thanks
Sylvain Bissonnette

Library on ATmega32U4 with HardwareSerial

I tested the library on ATmega32U4 today with this configuration

HardwareSerial esp8266Serial = Serial1;
ESP8266 wifi = ESP8266(esp8266Serial);

It is very weird, it send command without \r\n so ESP8266 not recognize them, only reply with the same string.

So I tested this
ESP8266 wifi = ESP8266(Serial1);

Now it start to sending \r\n (I'm monitoring TX and RX pin of ESP)
Why?

But test() still failed, actually readStatus(), it still return TIMEOUT status.
I cried increase timeout for readStatus() in test() to 1000 and it doesn't help.

setUnvarnishedMode() in the initialize()

What is the reason to call setUnvarnishedMode(false) on every library initialize?
Problem is that this call fail, if was already requested AT+CIPMUX=1
Working solution is restart module together with arduino on every code update, but I want to know the reason for this. Thanks.

Documentation

aHey,
first awesome Libary. The only Problem with the Libary is that there is no Documentation. A big Example is good and helpful but it would be nice to have a Documentation where I can read which Method makes what.

Greetz

wifi.send(unsigned int id, String) always returns TIMEOUT

I'm trying to send a String through a multi-connection instance of the ESP8266 class. When I Serial.print(getStatus(wifi.send(id, sendable))); it returns "TIMEOUT" every time. The data is never received by the client. After defining the ESP8266_DEBUG macro, the serial output looks like:

AT+CIPSEND=0,7
busy
TIMEOUT

Where the first two lines are from the ESP8266 library, and TIMEOUT is the output of getStatus();. This code is run in a loop once the client sends a handshake, so I know that the link is up. Any ideas?

More wifi.send() doesn't work properly

I'm trying to send multiple block like this:

wifi.send(1, "A");
wifi.send(1, "B");
wifi.send(1, "C");
wifi.send(1, "D");

but library send tot the serial port this:

AT+CIPSEND=0,1
AAT+CIPSEND=0,1
AT+CIPSEND=0,1
AT+CIPSEND=0,1
D

So I receive only A and D on the, sometimes A and C.
I don't figure out why. Do you have some idea?

The same problem if I want to send messages to different channels like

wifi.send(0, "A");
wifi.send(1, "B");
wifi.send(2, "C");
wifi.send(3, "D");

Random TIMEOUTs using ESP8266.h library

I'm experiencing random TIMEOUT issues and even random data in responses. Sometimes things 'mostly' work, other times it's a complete failure with nothing but TIMEOUT responses. First, my hardware setup:

Arduino UNO with NodeMCU Dev Board v0.90.
ESP VCC -> UNO 5v
ESP GND -> UNO GND
ESP TX -> UNO D2
ESP RX -> UNO D3

Sketch is the 'complete' example provided in this library with both Hardware and software serial ports set to 115200 bps. (I'm not able to get ANY response using 9600 bps on either/both ports).

The uploaded new firmware (all 4 files) using the Expressif files here:

https://github.com/espressif/ESP8266_AT/tree/master/bin

AT commands appear to work fine using a serial console.

THE PROBLEM:
From the Arduino IDE I upload the sketch which completes successfully. Using the Arduino Serial Monitor I can see the sketch running. After setting up the serial ports, the very first call made in the example sketch is:

Serial.println(getStatus(wifi.test()));

I would expect this to always return OK, but half of the time it is OK and the other half it is TIMEOUT. I have played with increasing and decreasing the wifi.setTimeout(...) setting. I've tried 500 all the way up to 3000.

Sometimes the version number varies.

Serial.print(getStatus(wifi.getVersion(version, 16)));

Keep in mind, sometimes the version number returns OK, but sometimes it is also a TIMEOUT, but when it does return a value it can be slightly different at random where only a single digit changes.

Here is an example console output from the 'complete' example sketch. Note, I have completely unplugged the power to both the UNO and ESP, then loaded the Arduino serial monitor to view output::

test: OK
getVersion: OK : 0820000903
setWifiMode: OK
joinAP: TIMEOUT
getAP: TIMEOUT :
getMAC STA: OK : 18:FD:34:C:2C:36
getIP STA: TIMEOUT : 0.0.0.0
connect: OK
send: TIMEOUT
createServer: OK
deleteServer: ERROR

... Press UNO reset button:

test: OK
getVersion: OK : 0820000903
setWifiMode: TIMEOUT
joinAP: OK
getAP: OK : Home Control
getMAC STA: TIMEOUT : 0:0:0:0:0:0
getIP STA: TIMEOUT : 0.0.0.0
connect: TIMEOUT
send: OK
createServer: ERROR
deleteServer: ERROR

...and again. Note initial test is TIMEOUT, version number is 'ok', but different than the one returned above. The getMAC returns TIMEOUT, but getIP succeeds:

test: TIMEOUT
getVersion: OK : 0010000903
setWifiMode: TIMEOUT
joinAP: OK
getAP: OK : Home Control
getMAC STA: TIMEOUT : 0:0:0:0:0:0
getIP STA: OK : 192.168.0.130
connect: OK
send: OK
createServer: TIMEOUT
deleteServer: TIMEOUT

The above output is can be the same after resetting the UNO and/or ESP using their reset buttons. The order of reset, or completely repowering seems to have no effect on whether I receive TIMEOUT responses or mostly successful responses.

I don't know what else I can do at this point, but the randomness is never going to work for my application. Anyone know why this might be happening?

doesn't work on arduino due

softwareserial isn't available for the arduino due.
please add support fror the library for the arduino due by giving the option to set a hardware serial port (like Serial1).

Implement the Stream interface

The library is only a few functions short of implementing the Stream interface.

The only missing are:
int peek();
void flush();
size_t write(uint8_t);

I can make the changes and create a pull request if you find this reasonable too.

permanent timeout

The library trying to prove by example and by more than change the wifi.setTimeout ( 5000) ; any value can not establish certain configurations as in AP mode

I have checked the code and the timeout is fixed at 20

getVersion: OK : 00200.9.5(b1)
setWifiMode: error AP
AP OK
getWifiMode: OK
getAP: TIMEOUT :
setAPConfiguration: OK
getAPConfiguration: OK : ESP8266 - awesomelib - 10 - 3
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
getIP STA: TIMEOUT : 0.0.0.0
getIP AP: TIMEOUT : 0.0.0.0
setMultipleConnections: TIMEOUT
createServer: TIMEOUT
getConnectedStations: TIMEOUT : 0
getConnectionStatus: TIMEOUT : 0
getConnectedStations: OK : 0
getConnectionStatus: OK : 0

Link to compatible firmware

Hi @Diaoul !

Can you give me a link to download a compatible firmware?

I'm not able to make this version work: https://github.com/espressif/esp8266_at

After install I can't send any AT command even trying with many baud rate.

actually I'm using this version:

AT version:0.50.0.0(Sep 18 2015 20:55:38)
SDK version:1.4.0
compile time:Sep 18 2015 21:32:07

But it is not compatible by example doesn't have the command AT+IPR and it can crash the firmware. See here: http://bbs.espressif.com/viewtopic.php?f=7&t=1910&p=6132&hilit=AT+IPR#p6132

The function to get IP is incompatible too. The right command is:

case ESP8266_WIFI_STATION:
        _serial->println(F("AT+CIPSTA?"));
        if (!find(F("+CIPSTA:ip:\""), 20))
            return ESP8266_COMMAND_TIMEOUT;

Best regards.

[Flow control] Serial incomming data collision

I think outputing data straight to serial is OK but with a proper flow control mechanism like a XON/XOFF.
From the ESP8266 point of view:

Received XOFF => output to buffer
Received XON => empty buffer to serial + resume sending straight to serial

I will adapt the code when a new firmware is out with the appropriate features. Meanwhile collision can still happen.

@lasselukkari: can you submit your patch to Espressif? I'd like the library to be rock solid and for that I need a rock solid ESP8266...

how to do a HTTP GET ?

hi

this might be a stupid question. but i am trying to GET the content from a local server and use it in my arduino code.
the page will give me a variable. no html or nothing.

so how do i use the send ?

this is what i have.

//
' Serial.print("setWifiMode: ");
Serial.println(getStatus(wifi.setMode(ESP8266_WIFI_BOTH)));

Serial.print("joinAP: ");
Serial.println(getStatus(wifi.joinAP("interpol_surveillance_van", "mypassword")));

Serial.print("connect: ");
Serial.println(getStatus(wifi.connect(ESP8266_PROTOCOL_TCP, IPAddress(192,168,1,7), 13568)));

Serial.print("send: ");
Serial.println(getStatus(wifi.send("GET /update/?key=dallameat&field1=22")));'

Compilation errors

Hi!
I am getting an error:
/home/artem/sketchbook/libraries/ESP8266/ESP8266.cpp: In member function β€˜ESP8266CommandStatus ESP8266::send(unsigned int, char_, unsigned int)’:
/home/artem/sketchbook/libraries/ESP8266/ESP8266.cpp:489:32: error: invalid conversion from β€˜char_’ to β€˜const uint8_t* {aka const unsigned char*}’ [-fpermissive]
_serial->write(data, length);
When compiling Complete.ino

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.