#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[] = "eb072d5fba39400596b7084397e37597";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Nak";
char pass[] = "1234567890";
// 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 9600
ESP8266 wifi(&EspSerial);
const int relay_pin = 12;
const int ldr_pin = 2;
const int lamp = 13;
void setup(){
pinMode(ldr_pin,INPUT);
pinMode(relay_pin,OUTPUT);
pinMode(lamp,OUTPUT);
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);}
void loop(){
Blynk.run();
int value_ldr = digitalRead(ldr_pin);
Serial.println(value_ldr);
if(value_ldr==HIGH){
digitalWrite(relay_pin,HIGH);
digitalWrite(lamp,HIGH);
delay(10);
}
else {
digitalWrite(relay_pin,LOW);
digitalWrite(lamp,LOW);
}
}
i have try this code is working fine without the blynk code inside. but when i include the blynk code the program seems to b not working. even the arduino board is not connected to the internet. i have follow from the example on code to connect to internet