Documente Academic
Documente Profesional
Documente Cultură
RESUMO
Este documento apresenta uma forma simples de utilizao da IDE do Arduino para
o mdulo ESP8266. Com um passo a passo de configurao da IDE como tambm
um exemplo simples da sua utilizao, todo o processo sendo demostrado atravs
de imagens.
Palavras-chave: ESP8266; IDE Arduino.
ABSTRACT
This document presents a simple way to use the Arduino IDE for ESP8266 module.
With a step by step of the IDE configuration as well a simple example of its use, the
process being shown with images.
Keywords: ESP8266; IDE Arduino.
INTRODUO
Promovendo uma soluo de baixo custo para projetos de Internet das Coisas
com soluo de comunicao Wi-Fi, o mdulo ESP8266 chegou no mercado no final
de 2014, criado pela empresa chinesa Espressif Systems. Existem vrios mdulos
disponveis no mercado, alguns com preos menores que 5 dlares.
Mas uma das maiores dificuldades ainda encontrada como utilizar esta
ferramenta da melhor forma possvel e como ela pode encaixar em seu projeto.
Existem vrios firmwares disponveis no mercado, cada qual com uma forma
_____________
1Graduando do Curso de Bacharel em Cincia da Computao do Instituto Federal de Educao,
Cincia e Tecnologia Catarinense - Cmpus Videira, elitontiagoguzi@gmail.com;
Videira SC, Julho de 2016.
Fonte: arduino.cc.
Fonte: O autor.
CONFIGURANDO A IDE
Fonte: O autor.
Ao abrir o gerenciador de placas deve haver novas entradas alm das placas
Arduino padro. Procure por ESP8266 (figura 4) e clique na entrada, em seguida,
selecione instalar.
Figura 4: Tela para adio das placas do ESP8266.
Fonte: O autor.
Fonte: O autor.
Fonte: O autor.
EXEMPLOS DE UTILIZAO
WiFi.begin(ssid, pass);
Serial.println("");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
printWifiStatus();
void loop() {
WiFiClient client = server.available(); // listen for incoming clients
if (client) {
// if you get a client,
Serial.println("new client");
// print a message out the serial port
String currentLine = "";
// make a String to hold incoming data from the client
while (client.connected()) {
// loop while the client's connected
if (client.available()) {
// if there's bytes to read from the client,
char c = client.read();
// read a byte, then
Serial.write(c);
// print it out the serial monitor
if (c == '\n') {
// if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
// the content of the HTTP response follows the header:
client.print("<font size=\"7\">Click <a href=\"/H\">here</a> turn the LED on pin 2 on<br><br>");
client.print("Click <a href=\"/L\">here</a> turn the LED on pin 2 off<br>");
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
}
else {
// if you got a newline, then clear currentLine:
currentLine = "";
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c;
// add it to the end of the currentLine
}
// Check to see if the client request was "GET /H" or "GET /L":
if (currentLine.endsWith("GET /H")) {
digitalWrite(2, HIGH);
// GET /H turns the LED on
}
if (currentLine.endsWith("GET /L")) {
digitalWrite(2, LOW);
// GET /L turns the LED off
}
}
}
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
// print where to go in a browser:
Serial.print("To see this page in action, open a browser to http://");
Serial.println(ip);
}
Fonte: O autor.
Fonte: O autor.
RESULTADOS E DISCUSSO
10
REFERNCIAS