#include <Blynk.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "---------------";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "========";
char pass[] = "0000000";
char server[] = "blynk-cloud.com";
int port = 8080;
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
BLYNK_WRITE(D13) {
if (param.asInt()) {
digitalWrite(1, HIGH);
} else {
digitalWrite(0, LOW);
}
}
void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
Blynk.config(wifi, auth, server, port);
if (Blynk.connectWiFi(ssid, pass)) {
Blynk.connect();
}
}
void loop()
{
if (Blynk.connect()) {
Blynk.run();
}
else {
Blynk.connect();
}
}