You are on page 1of 4

Arduino UNO + ESP8266 ESP-12E UART WIFI Shield

Desenvolvido por

WangTongze

SOBRE O DIP SWITCH

1 2 3 4 FUNÇÃO
DOWN DOWN UP UP Permite gravar no ESP8266 via PORT DEBUG – O dip 4
é apenas para permitir acender o LED
UP UP DOWN DOWN Permite conectar o ESP8266 no ARDUINO via TX/RX
usando a LIB SoftSerial
DOWN DOWN DOWN DOWN Permite gravar o ARDUINO sem remover o SHIELD

1- Para gravar o ESP8266, ajuste os parâmetros da IDE ARDUINO para a placa ESP8266 e a
porta serial correspondente ao conversor que está conectado no barramento debug do
shield e a USB do PC. Ao final do UPLOAD, confirme o funcionamento através do monitor
serial.
Atenção: o shield deve esta desconectado no ARDUINO

Na IDE ARDUINO, selecionar a placa;

ESPino(ESP-12-Module)

PORT DEBUG

Debug Port 3,3V – para programar o ESP8266 3,3V


USB/TTL

Debug Port TX => Uno Pin 1 (TX) GND


SHIELD
CONV

LADO
LADO

Debug Port RX => Uno Pin 0 (RX) 5V


Debug Port GND => Uno GND RX
Debug Port 5V => Para programar ARDUINO Uno 5V TX
Para o ESP8266 usar o 3,3V e para o Arduino usar o 5V.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASS";
ESP8266WebServer server(80); // HTTP server on port 80
void setup() {
Serial.begin(115200);
WiFi.disconnect(); // Disconnect AP
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); // Connect to WIFI network
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println(".");
}
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", [](){
server.send(200, "text/plain", "Hello World");
});
server.begin(); // Start HTTP server
Serial.println("HTTP server started.");
}
void loop() {
server.handleClient();
}

2- Para gravar o ARDUINO, instale na IDE ARDUINO a LIB SoftSerial e no SKETCH inclua:
a. #include <SoftSerial.h>
b. Inicialise a SoftSerial – SoftSerial myserial(0,1)//TX e RX
c. Myserial.begin(115200);

Naturalmente, no hardware do shield o TXD e o RXD do EXP8266 estão conectados aos pinos
1 e 0 do shield, respectivamente.

0 ---------- RXD

1 ---------- TXD
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX on Arduino
void setup() {
Serial.begin(115200);
mySerial.begin(115200);
}
void loop() {
if (mySerial.available()) {
String msg = mySerial.readString();
Serial.print(“Data received: “);
Serial.println(msg);
}
}

Aqui está uma URL do site oficial do Arduino, onde você pode ler mais informações
sobre o SoftwareSerial

https://www.arduino.cc/en/Reference/SoftwareSerial
Para conectar o ESP8266 do shied com o ARDUINO

Outros detalhes

You might also like