Arduino Library for ESP8266 Wifi Shield
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
test
.gitignore
ArduEsp8266.cpp
ArduEsp8266.h
ArduEsp8266_APinfo.h
LICENSE
README.md

README.md

ArduEsp8266

This Arduino library supplies simple high level access to the ESP8266 wifi module (see https://nurdspace.nl/ESP8266). It allows you to connect your Arduino to the wifi module, join or create a wifi signal and create or connect to a server. The library includes a serial debugging interface using Arduino SoftwareSerial (see https://www.arduino.cc/en/Reference/softwareSerial) to get debug messages.

Hint Although this library isn't complete you can still use some of the important functions like joining a wifi signal and connect to remote server and receive data from it.

Installation

Download repository content from release and install it manualy into your Arduino IDE libraries directory. See https://www.arduino.cc/en/pmwiki.php?n=Guide/Libraries#toc5 for details.

Quick Example

This example shows how to quickly connect to a remote server. You should connect the ESP8266 module to serial port of your Arduino. Because Arduino uses serial port for program uploaded, it's recommended to adda mosfet to switch on power of ESP8266 module seperately, but this is optional.

First you need to include SoftwareSerial.h because it's required by ArduEsp8266 and an instance of ArduEsp8266

include <SoftwareSerial.h>
ArduEsp8266 wifi;

If you use an external mosfet so switch on power of ESP8266 module, set the pin to ArduEsp8266

wifi.setEnablePin(5);

Now you can initiate the wifi. This opens serial port and tries to get a response from ESP8266

wifi.init();

init() returns true if successful, false otherwise. Next is to connect your ESP8266 to a wifi signal. It saves this and tries to reconnect on every start.

wifi.connectToAP( "ssid", "password" );

Replace ssid and password by your wifi SSID and your password (if required). Again it returns true if successfull. This maybe can need a few seconds. Now can connect to the remote server. By default only a single connection is allowed. You can change this to multiple connection (connection nummber 0-4).

wifi.setMode(ESP8266_MODE_STATION);

Now you can use the connections 0 to 4 to connect to remote server using.

wifi.connect( "IP", PORT, ESP8266_TCP, 0 );

Replace IP and PORT with your servers ip and port. You can use SocketTest for testing client server connection (see http://sockettest.sourceforge.net/). The last number specifies the connection number, if multiple connection are set. Connect returns true if connected successful.

To send data to remote server you can use

wifi.send("Hello World", 0);

Replace Hello World with your string data and number 0 with the connection number you are using for multiple connection.

To receive data, call

wifi.readData();

It returns a string of received data or an empty string if no data received. For more information take a closer look at examples.

Debug interface

The library includes a serial debugging interface thats connected to pin 12 (tx) and 13 (rx) of Arduino board. The baudrate is 115200. The interface shows sended and received data between Arduino and ESP8266, but can also be used to send custom messages by accessing the unterlaying SoftwareSerial instance via

wifi.debug.println(...);