Arduino Uno +ESP8266 01 8 relay over esp + temperature+physical button

/********ESP 01 arduino UNO BLYNK***************************************/
#define BLYNK_PRINT Serial
#include <SimpleTimer.h>

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxx";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial  //0- RX  , 1-TX

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600//115200

ESP8266 wifi(&EspSerial);
/********************************/
const int relay1 = 2;
const int relay2 = 3;
const int relay3 = 7;
const int relay4 = 8;
const int relay5 = 9;
const int relay6 = 10;
const int relay7 = 11;
const int relay8 = 12;
/*******************************/
SimpleTimer timer;
WidgetLED led5(V9);//led online
/*****************************************/
BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6);
  Blynk.syncVirtual(V7);
  Blynk.syncVirtual(V8);
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V1)
{
  if (param.asInt()) {
    digitalWrite(relay1, HIGH);
    delay(1000);
    digitalWrite(relay1, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V2)
{
  if (param.asInt()) {
    digitalWrite(relay2, HIGH);
    delay(1000);
    digitalWrite(relay2, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V3)
{
  if (param.asInt()) {
    digitalWrite(relay3, HIGH);
    delay(1000);
    digitalWrite(relay3, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V4)
{
  if (param.asInt()) {
    digitalWrite(relay4, HIGH);
    delay(1000);
    digitalWrite(relay4, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V5)
{
  if (param.asInt()) {
    digitalWrite(relay5, HIGH);
    delay(1000);
    digitalWrite(relay5, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V6)
{
  if (param.asInt()) {
    digitalWrite(relay6, HIGH);
    delay(1000);
    digitalWrite(relay6, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V7)
{
  if (param.asInt()) {
    digitalWrite(relay7, HIGH);
    delay(1000);
    digitalWrite(relay7, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V8)
{
  if (param.asInt()) {
    digitalWrite(relay8, HIGH);
    delay(1000);
    digitalWrite(relay8, LOW);
  }
}
/***ONLINE*************/
void ledonline()
{
  if (led5.getValue()) {
    led5.off();
    Serial.println("LED on V9: off");
  } else {
    led5.on();
    Serial.println("LED on V9: on");
  }
}
/*****************************************/
void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  /**********************************/
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
  digitalWrite(relay5, LOW);
  digitalWrite(relay6, LOW);
  digitalWrite(relay7, LOW);
  digitalWrite(relay8, LOW);
  /*************************************************/
  timer.setInterval(1000L, ledonline);
  /*******************************************/
}

void loop()
{
  Blynk.run();
  timer.run();
}

[

> http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmwarehttps://github.com/2017dman/ESP-01-AI-Cloud-Black-Drivers

](http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware)`[Preformatted text](1 upload firmware GPIO0 –GND !!! https://github.com/2017dman/ESP-01-AI-Cloud-Black-Drivers BIN: boot_v1.2+.bin 0x00000 user1.1024.new.2.bin 0x01000 esp_init_data_default.bin 0x1fc000 blank.bin 0x1fe000 2 serial monitor AT AT+CWMODE=3 // send AT+CIPMUX=1 // send AT+UART_DEF=9600,8,1,0,0 // send)``

` //physical button

/********ESP 01 arduino UNO BLYNK TLACITKA***************************************/
#define BLYNK_PRINT Serial
#include <SimpleTimer.h>

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "XXXXXXXXXXXXXXXXXXXXX";
char ssid[] = "XXXXXXXXXXXXX";
char pass[] = "XXXXXXXXXXXXXXXXXX";

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial  //0- RX  , 1-TX

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600//115200

ESP8266 wifi(&EspSerial);
/********************************/
const int relay1 = 2;
const int relay2 = 3;
const int relay3 = 7;
const int relay4 = 8;
const int relay5 = 9;
const int relay6 = 10;
const int relay7 = 11;
const int relay8 = 12;
/*******************************/
const int button1 = A0;
const int button2 = A1;
const int button3 = A2;
const int button4 = A3;
const int button5 = A4;
const int button6 = A5;
const int button7 = 6;
const int button8 = 5;
/***************************************************************/
SimpleTimer timer;
/**********************************/
void physicalbutton();  //physical button
/************************************/
int relaystate3 = LOW;
int relaystate4 = LOW;
int relaystate5 = LOW;
int relaystate6 = LOW;
int relaystate7 = LOW;
int relaystate8 = LOW;
/***************************************/
int buttonstate1 = HIGH;
int buttonstate2 = HIGH;
int buttonstate3 = HIGH;
int buttonstate4 = HIGH;
int buttonstate5 = HIGH;
int buttonstate6 = HIGH;
int buttonstate7 = HIGH;
int buttonstate8 = HIGH;
/***************************************/
WidgetLED led5(V9);//led online
/*****************************************/
BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6);
  Blynk.syncVirtual(V7);
  Blynk.syncVirtual(V8);
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V1)
{
  if (param.asInt()) {
    digitalWrite(relay1, HIGH);
    delay(1000);
    digitalWrite(relay1, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V2)
{
  if (param.asInt()) {
    digitalWrite(relay2, HIGH);
    delay(1000);
    digitalWrite(relay2, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V3)
{
  if (param.asInt())
  {
    digitalWrite(relay3, HIGH);
  }
  else
  {
    digitalWrite(relay3, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V4)
{
  if (param.asInt())
  {
    digitalWrite(relay4, HIGH);
  }
  else
  {
    digitalWrite(relay4, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V5)
{
  if (param.asInt())
  {
    digitalWrite(relay5, HIGH);
  }
  else
  {
    digitalWrite(relay5, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V6)
{
  if (param.asInt())
  {
    digitalWrite(relay6, HIGH);
  }
  else
  {
    digitalWrite(relay6, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V7)
{
  if (param.asInt())
  {
    digitalWrite(relay7, HIGH);
  }
  else
  {
    digitalWrite(relay7, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V8)
{
  if (param.asInt())
  {
    digitalWrite(relay8, HIGH);
  }
  else
  {
    digitalWrite(relay8, LOW);
  }
}
/**********************************************/
void physicalbutton()
{
  int sensorVal = digitalRead(A0);
  Serial.println(sensorVal);
  if (sensorVal == HIGH) {
    digitalWrite(2, LOW);
    Blynk.virtualWrite(V1, LOW);
  } else {
    digitalWrite(2, HIGH);
    Blynk.virtualWrite(V1, HIGH);
  }
  /**********MONOSTABIL*************/
  int sensor1Val = digitalRead(A1);
  Serial.println(sensor1Val);
  if (sensor1Val == HIGH) {
    digitalWrite(3, LOW);
    Blynk.virtualWrite(V2, LOW);
  } else {
    digitalWrite(3, HIGH);
    Blynk.virtualWrite(V2, HIGH);
  }
  /**********BISTABIL**************/
  if (digitalRead(button3) == LOW) {
    if (buttonstate3 != LOW) {
      relaystate3 = !relaystate3;
      digitalWrite(relay3, relaystate3);
      Blynk.virtualWrite(V3, relaystate3);
    }
    buttonstate3 = LOW;
  } else {
    buttonstate3 = HIGH;
  }
  /**********BISTABIL***************/
  if (digitalRead(button4) == LOW) {
    if (buttonstate4 != LOW) {
      relaystate4 = !relaystate4;
      digitalWrite(relay4, relaystate4);
      Blynk.virtualWrite(V4, relaystate4);
    }
    buttonstate4 = LOW;
  } else {
    buttonstate4 = HIGH;
  }
/**********BISTABIL***************/
if (digitalRead(button5) == LOW) {
  if (buttonstate5 != LOW) {
    relaystate5 = !relaystate5;
    digitalWrite(relay5, relaystate5);
    Blynk.virtualWrite(V5, relaystate5);
  }
  buttonstate5 = LOW;
} else {
  buttonstate5 = HIGH;
}
/**********BISTABIL***************/
if (digitalRead(button6) == LOW) {
  if (buttonstate6 != LOW) {
    relaystate6 = !relaystate6;
    digitalWrite(relay6, relaystate6);
    Blynk.virtualWrite(V6, relaystate6);
  }
  buttonstate6 = LOW;
} else {
  buttonstate6 = HIGH;
}
/**********BISTABIL***************/
if (digitalRead(button7) == LOW) {
  if (buttonstate7 != LOW) {
    relaystate7 = !relaystate7;
    digitalWrite(relay7, relaystate7);
    Blynk.virtualWrite(V7, relaystate7);
  }
  buttonstate7 = LOW;
} else {
  buttonstate7 = HIGH;
}
/**********BISTABIL***************/
if (digitalRead(button8) == LOW) {
  if (buttonstate8 != LOW) {
    relaystate8 = !relaystate8;
    digitalWrite(relay8, relaystate8);
    Blynk.virtualWrite(V8, relaystate8);
  }
  buttonstate8 = LOW;
} else {
  buttonstate8 = HIGH;
}
}
/***ONLINE*************/
void ledonline()
{
  if (led5.getValue()) {
    led5.off();
    Serial.println("LED on V9: off");
  } else {
    led5.on();
    Serial.println("LED on V9: on");
  }
}
/*****************************************/
void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  /**********************************/
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
  digitalWrite(relay5, LOW);
  digitalWrite(relay6, LOW);
  digitalWrite(relay7, LOW);
  digitalWrite(relay8, LOW);
  /*************************************************/
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);
  pinMode(button5, INPUT_PULLUP);
  pinMode(button6, INPUT_PULLUP);
  pinMode(button7, INPUT_PULLUP);
  pinMode(button8, INPUT_PULLUP);
  /*************************************/
  digitalWrite(relay3, relaystate3);
  digitalWrite(relay4, relaystate4);
  digitalWrite(relay5, relaystate5);
  digitalWrite(relay6, relaystate6);
  digitalWrite(relay7, relaystate7);
  digitalWrite(relay8, relaystate8);
  /****************************************/
  timer.setInterval(1000L, ledonline);
  timer.setInterval(1000L, physicalbutton);
  /*******************************************/
}

void loop()
{
  Blynk.run();
  timer.run();
*****************************************************************************************************************************************
****************************+temperature******************************
**+TEMPERATURE**
/********ESP 01 arduino UNO BLYNK TLACITKA+TEPLOTA2***************************************/
#define BLYNK_PRINT Serial
#include <SimpleTimer.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "XXXXXXXXXXXXXXXXXXXXXX";
char ssid[] = "XXXXXX";
char pass[] = "XXXXXXX";
/***********************************************/
#define ONE_WIRE_BUS 6
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
/***********************************************/
DeviceAddress tempSensor1 = { 0x28, 0x7F, 0xB8, 0xB0, 0x01, 0x00, 0x00, 0xE9 };

int temperature1;
/***********************************/
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial  //0- RX  , 1-TX

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600//115200

ESP8266 wifi(&EspSerial);
/********************************/
const int relay1 = 2;
const int relay2 = 3;
const int relay3 = 7;
const int relay4 = 8;
const int relay5 = 9;
const int relay6 = 10;
const int relay7 = 11;
const int relay8 = 12;
/*******************************/
const int button1 = A0;
const int button2 = A1;
const int button3 = A2;
const int button4 = A3;
const int button5 = A4;
const int button6 = A5;
const int button7 = 5;

/***************************************************************/
SimpleTimer timer;
/**********************************/
void physicalbutton();  //physical button
/************************************/
int relaystate3 = LOW;
int relaystate4 = LOW;
int relaystate5 = LOW;
int relaystate6 = LOW;
int relaystate7 = LOW;
int relaystate8 = LOW;
/***************************************/
int buttonstate1 = HIGH;
int buttonstate2 = HIGH;
int buttonstate3 = HIGH;
int buttonstate4 = HIGH;
int buttonstate5 = HIGH;
int buttonstate6 = HIGH;
int buttonstate7 = HIGH;
int buttonstate8 = HIGH;
/***************************************/
WidgetLED led5(V9);//led online
// temperature1 V10
/*****************************************/
BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1);
  Blynk.syncVirtual(V2);
  Blynk.syncVirtual(V3);
  Blynk.syncVirtual(V4);
  Blynk.syncVirtual(V5);
  Blynk.syncVirtual(V6);
  Blynk.syncVirtual(V7);
  Blynk.syncVirtual(V8);
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V1)
{
  if (param.asInt()) {
    digitalWrite(relay1, HIGH);
    delay(1000);
    digitalWrite(relay1, LOW);
  }
}
/************MONOSTABIL push button android*************/
BLYNK_WRITE(V2)
{
  if (param.asInt()) {
    digitalWrite(relay2, HIGH);
    delay(1000);
    digitalWrite(relay2, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V3)
{
  if (param.asInt())
  {
    digitalWrite(relay3, HIGH);
  }
  else
  {
    digitalWrite(relay3, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V4)
{
  if (param.asInt())
  {
    digitalWrite(relay4, HIGH);
  }
  else
  {
    digitalWrite(relay4, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V5)
{
  if (param.asInt())
  {
    digitalWrite(relay5, HIGH);
  }
  else
  {
    digitalWrite(relay5, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V6)
{
  if (param.asInt())
  {
    digitalWrite(relay6, HIGH);
  }
  else
  {
    digitalWrite(relay6, LOW);
  }
}
/*****************BISTABIL  switch button android***************/
BLYNK_WRITE(V7)
{
  if (param.asInt())
  {
    digitalWrite(relay7, HIGH);
  }
  else
  {
    digitalWrite(relay7, LOW);
  }
}
/**************BISTABIL switch button android**************/
BLYNK_WRITE(V8)
{
  if (param.asInt())
  {
    digitalWrite(relay8, HIGH);
  }
  else
  {
    digitalWrite(relay8, LOW);
  }
}
/**********************************************/
void physicalbutton()
{
  int sensorVal = digitalRead(A0);
  Serial.println(sensorVal);
  if (sensorVal == HIGH) {
    digitalWrite(2, LOW);
    Blynk.virtualWrite(V1, LOW);
  } else {
    digitalWrite(2, HIGH);
    Blynk.virtualWrite(V1, HIGH);
  }
  /**********MONOSTABIL*************/
  int sensor1Val = digitalRead(A1);
  Serial.println(sensor1Val);
  if (sensor1Val == HIGH) {
    digitalWrite(3, LOW);
    Blynk.virtualWrite(V2, LOW);
  } else {
    digitalWrite(3, HIGH);
    Blynk.virtualWrite(V2, HIGH);
  }
  /**********BISTABIL**************/
  if (digitalRead(button3) == LOW) {
    if (buttonstate3 != LOW) {
      relaystate3 = !relaystate3;
      digitalWrite(relay3, relaystate3);
      Blynk.virtualWrite(V3, relaystate3);
    }
    buttonstate3 = LOW;
  } else {
    buttonstate3 = HIGH;
  }
  /**********BISTABIL***************/
  if (digitalRead(button4) == LOW) {
    if (buttonstate4 != LOW) {
      relaystate4 = !relaystate4;
      digitalWrite(relay4, relaystate4);
      Blynk.virtualWrite(V4, relaystate4);
    }
    buttonstate4 = LOW;
  } else {
    buttonstate4 = HIGH;
  }
/**********BISTABIL***************/
if (digitalRead(button5) == LOW) {
  if (buttonstate5 != LOW) {
    relaystate5 = !relaystate5;
    digitalWrite(relay5, relaystate5);
    Blynk.virtualWrite(V5, relaystate5);
  }
  buttonstate5 = LOW;
} else {
  buttonstate5 = HIGH;
}
/**********BISTABIL***************/
if (digitalRead(button6) == LOW) {
  if (buttonstate6 != LOW) {
    relaystate6 = !relaystate6;
    digitalWrite(relay6, relaystate6);
    Blynk.virtualWrite(V6, relaystate6);
  }
  buttonstate6 = LOW;
} else {
  buttonstate6 = HIGH;
}
/**********BISTABIL***************/
if (digitalRead(button7) == LOW) {
  if (buttonstate7 != LOW) {
    relaystate7 = !relaystate7;
    digitalWrite(relay7, relaystate7);
    Blynk.virtualWrite(V7, relaystate7);
  }
  buttonstate7 = LOW;
} else {
  buttonstate7 = HIGH;
}

}
/***ONLINE*************/
void ledonline()
{
  if (led5.getValue()) {
    led5.off();
    Serial.println("LED on V9: off");
  } else {
    led5.on();
    Serial.println("LED on V9: on");
  }
}
/*****************************************/
/*****************************************/
void sendSensor1() {
  sensors.requestTemperatures();
  temperature1 = sensors.getTempC(tempSensor1);
  Blynk.virtualWrite(V10, temperature1);
}
void setup()
{
  // Debug console
  Serial.begin(9600);
   
  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  /**********************************/
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
  digitalWrite(relay5, LOW);
  digitalWrite(relay6, LOW);
  digitalWrite(relay7, LOW);
  digitalWrite(relay8, LOW);
  /*************************************************/
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);
  pinMode(button5, INPUT_PULLUP);
  pinMode(button6, INPUT_PULLUP);
  pinMode(button7, INPUT_PULLUP);
    /*************************************/
  digitalWrite(relay3, relaystate3);
  digitalWrite(relay4, relaystate4);
  digitalWrite(relay5, relaystate5);
  digitalWrite(relay6, relaystate6);
  digitalWrite(relay7, relaystate7);
    /****************************************/
  timer.setInterval(1000L, ledonline);
  timer.setInterval(1000L, physicalbutton);
  
  /*******************************************/
  sensors.begin();
  sensors.setResolution(tempSensor1, 10);   
  /***************************************/
  timer.setInterval(5000L, sendSensor1);
}
void loop()
{

  Blynk.run();
  timer.run();
}

@krc I am unsure what you are posting about… is this an issue, a project, a tutorial?

I cleaned up as much of your post as I could, but there are some parts where I just don’t know what you were trying to display, so perhaps you can clean it up? Thanks

project

i tried it on arduino board and work well done

Well, please clean up your first post and explain a bit more about whatever it is about, thanks.