ESP8266 and Blynk connected

Hello blynkers

I have this code… and i want to close all relays when the internet is offline (with send to the server true and false) if the esp take false to close all relays… I have try to do this ( check code) with LOW and HIGH but when I close the wifi the esp do not close the relays… Do you have to suggest changes to work this project? If you want an other similar project with this commands post it :slight_smile: thanks you

/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = "*******************";

/* WiFi credentials */
char ssid[] = "******";
char pass[] = "*****";

/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

//BlynkTimer timer;

float temp_0;
float temp_1;
float temp_2;
boolean connected_blynk;        //an exei epikoinonia me ton server

BLYNK_CONNECTED()  //sygxronizei to esp otan bgei apo to reuma stis leitoyrgies poy eixe stamatisi

void setup() 
  Blynk.begin(auth, ssid, pass);
  Serial.println(" ");
  Serial.println("Testing Dual Sensor data");

void loop() 
{; // Initiates SimpleTimer;

 * Send Sensor data to Blynk
void getSendData()
  temp_0 = DS18B20.getTempCByIndex(0); // Sensor 1 will capture Temp in Celcius
  temp_1 = DS18B20.getTempCByIndex(1); // Sensor 2 will capture Temp in Celcius
  temp_2 = DS18B20.getTempCByIndex(2); // Sensor 3 will capture Temp in Celcius
  Blynk.virtualWrite(1, temp_0); //virtual pin V1
  Blynk.virtualWrite(2, temp_1); //virtual pin V2
  Blynk.virtualWrite(3, temp_2); //virtual pin V3

  Serial.print("temp_0= ");
  Serial.print("temp_1= ");
  Serial.print("temp_2= ");

void check_online()
  connected_blynk = Blynk.connected();
  if (connected_blynk==false)

I’d say that the first thing to do is to stop using the blocking Blynk.begin command, then move to managing your own WiFi connection (in a non-blocking way) then use Blynk.config and Blynk.connect.


ohh sorry but i dont understood very well what changes should i make… if i don keep the

how the esp will going conect with ssid, pass and auth? … Could you please post here this change so that i add it this in my code? thanks you, i am very new in this world sorry

You manage the WiFi connection, which uses the SSID and WiFi password.
The auth token is defined in Blynk.config.

No, I’m not going to write your code for you.


very good :slight_smile: