BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Home automation monitor 8+ sensors and control 4CH relay using Blynk app+ physical buttons with NODEMCU

I’m using nodemcu with Blynk server
Aim:
1)To read 8 different sensor values.
2) read temperature and humidity using DHT11.
3) control 4ch relay using physical push button+ Blynk application (virtual buttons).

Procedure:
1)To read 8 different sensor values, since nodemcu has only one analog input pin so I used
8-1multiplexer(4051be) that uses digital pins to switch between different sensors.
2)Read temperature and humidity with DHT11 sensor
3)Control 4 relays with 4 physical buttons and also via Blynk application include relaystate sync with virtual buttons in the Blynk application…

here i’m giving 3 programs i want to merge all these 3 programs in to single program…please help me to merge
program no (1)

[using physical 4 buttons using Nodemcu esp8266 to switch relays]
digital pin D5,D6,D7,D8,D9,D10,SD2,SD3 pins were used
D9,D10,SD2,SD3 as INPUT push buttons
D5,D6,D7,D8 as OUTPUT to 4ch relay

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = “auth”;
char ssid[] = “ssid”;
char pass[] = “password”;
// Set your LED and physical button pins here
const int ledPin1 = 12;
const int ledPin2 = 13;
const int ledPin3 = 14;
const int ledPin4 = 15;
const int btnPin1 = 3;
const int btnPin2 = 1;
const int btnPin3 = 9;
const int btnPin4 = 10;

BlynkTimer timer;
void checkPhysicalButton();

int led1State = LOW;
int btn1State = HIGH;

int led2State = LOW;
int btn2State = HIGH;

int led3State = LOW;
int btn3State = HIGH;

int led4State = LOW;
int btn4State = HIGH;

// Every time we connect to the cloud…
BLYNK_CONNECTED() {
// Request the latest state from the server
Blynk.syncVirtual(V12);
Blynk.syncVirtual(V13);
Blynk.syncVirtual(V14);
Blynk.syncVirtual(V15);

// Alternatively, you could override server state using:
//Blynk.virtualWrite(V12, led1State);
//Blynk.virtualWrite(V13, led2State);
//Blynk.virtualWrite(V14, led3State);
//Blynk.virtualWrite(V15, led4State);

}

// When App button is pushed - switch the state
BLYNK_WRITE(V12) {
led1State = param.asInt();
digitalWrite(ledPin1, led1State);
}

BLYNK_WRITE(V13) {
led2State = param.asInt();
digitalWrite(ledPin2, led2State);
}
BLYNK_WRITE(V14) {
led3State = param.asInt();
digitalWrite(ledPin3, led3State);
}
BLYNK_WRITE(V15) {
led4State = param.asInt();
digitalWrite(ledPin4, led4State);
}

void checkPhysicalButton()
{
if (digitalRead(btnPin1) == LOW) {
// btn1State is used to avoid sequential toggles
if (btn1State != LOW) {

  // Toggle LED state
  led1State = !led1State;
  digitalWrite(ledPin1, led1State);

  // Update Button Widget
  Blynk.virtualWrite(V12, led1State);
}
btn1State = LOW;
} else {
btn1State = HIGH;
}

if (digitalRead(btnPin2) == LOW) {
// btnState is used to avoid sequential toggles
if (btn2State != LOW) {

  // Toggle LED state
  led2State = !led2State;
  digitalWrite(ledPin2, led2State);

  // Update Button Widget
  Blynk.virtualWrite(V13, led2State);
}
btn2State = LOW;
} else {
btn2State = HIGH;
}

if (digitalRead(btnPin3) == LOW) {
// btnState is used to avoid sequential toggles
if (btn3State != LOW) {

  // Toggle LED state
  led3State = !led3State;
  digitalWrite(ledPin3, led3State);

  // Update Button Widget
  Blynk.virtualWrite(V14, led3State);
}
btn3State = LOW;
} else {
btn3State = HIGH;
}

if (digitalRead(btnPin4) == LOW) {
// btnState is used to avoid sequential toggles
if (btn4State != LOW) {

  // Toggle LED state
  led4State = !led4State;
  digitalWrite(ledPin4, led4State);

  // Update Button Widget
  Blynk.virtualWrite(V15, led4State);
}
btn4State = LOW;
} else {
btn4State = HIGH;
}
}

void setup()
{
// Debug console
Serial.begin(9600);

Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, “blynk-cloud.com”, 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

pinMode(ledPin1, OUTPUT);
pinMode(btnPin1, INPUT_PULLUP);
digitalWrite(ledPin1, led1State);

pinMode(ledPin2, OUTPUT);
pinMode(btnPin2, INPUT_PULLUP);
digitalWrite(ledPin2, led2State);

pinMode(ledPin3, OUTPUT);
pinMode(btnPin3, INPUT_PULLUP);
digitalWrite(ledPin3, led3State);

pinMode(ledPin4, OUTPUT);
pinMode(btnPin4, INPUT_PULLUP);
digitalWrite(ledPin4, led4State);

// Setup a function to be called every 100 ms
timer.setInterval(500L, checkPhysicalButton);
}

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

/***
program no (2)

[using DHT11 sensor to collect temperature and humidity]

Digital pin 4 was used as input ***/

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

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

/***
program no (3)

[using 8-1 multiplexer (4051be) to reading 8_sensor values]

D1,D2,D3 & A0 pins used
D1,D2,D3 as OUTPUT
A0 as INPUT***/

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "auth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ssid";
char pass[] = "password";
int Sensor_1;
int Sensor_2;
int Sensor_3;
int Sensor_4;
int Sensor_5;
int Sensor_6;
int Sensor_7;
int Sensor_8;
int Pin_D5 = 5; //14 is a Gpio pin number label as D5
int Pin_D6 = 4; //12 is a Gpio pin number label as D6
int Pin_D7 = 0; //13 is a Gpio pin number label as D7



void setup() {

  Serial.begin(9600);   //Start serial monitor
  pinMode(Pin_D5,OUTPUT);
  pinMode(Pin_D6,OUTPUT);
  pinMode(Pin_D7,OUTPUT);
  pinMode(A0,INPUT);
  Blynk.begin(auth, ssid, pass);
  
}

void loop() {
  
  Blynk.run();
  //for Sensor_1
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(100);                    //Wait for sensor
  Sensor_1 = analogRead(0);      //Read Analog pin as SENSOR1
  //Repeat for sensor_2
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(100);                    //Wait for sensor
  Sensor_2 = analogRead(0);      //Read Analog pin as SENSOR2
  //Repeat for sensor_3
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(100);                    //Wait for sensor
  Sensor_3 = analogRead(0);      //Read Analog pin as SENSOR3
  //Repeat for sensor_4
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(100);                    //Wait for sensor
  Sensor_4 = analogRead(0);      //Read Analog pin as SENSOR4
  //Repeat for sensor_5
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(100);                    //Wait for sensor
  Sensor_5 = analogRead(0);      //Read Analog pin as SENSOR5
  //Repeat fo 
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(100);                    //Wait for sensor
  Sensor_6 = analogRead(0);      //Read Analog pin as SENSOR6
  //Repeat for sensor_7
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(100);                    //Wait for sensor
  Sensor_7 = analogRead(0);      //Read Analog pin as SENSOR7
  //Repeat for sensor_8
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(100);                    //Wait for sensor
  Sensor_8 = analogRead(0);      //Read Analog pin as SENSOR8

  //Print the results to the serial monitor
  Serial.print(" / Sensor1=");   
  Serial.print(Sensor_1);
  Serial.print(" / Sensor2=");   
  Serial.print(Sensor_2);
  Serial.print(" / Sensor3=");   
  Serial.print(Sensor_3);
  Serial.print(" / Sensor4=");   
  Serial.print(Sensor_4);
  Serial.print(" / Sensor5=");   
  Serial.print(Sensor_5);
  Serial.print(" / Sensor6=");   
  Serial.print(Sensor_6);
  Serial.print(" / Sensor7=");   
  Serial.print(Sensor_7);
  Serial.print(" / Sensor8=");   
  Serial.print(Sensor_8);
  
  
  Blynk.virtualWrite(V18, Sensor_1);  //Write values to Blynk server
  Blynk.virtualWrite(V19, Sensor_2);  //Write values to Blynk server
  Blynk.virtualWrite(V20, Sensor_3);  //Write values to Blynk server
  Blynk.virtualWrite(V21, Sensor_4);  //Write values to Blynk server
  Blynk.virtualWrite(V22, Sensor_5);  //Write values to Blynk server
  Blynk.virtualWrite(V23, Sensor_6);  //Write values to Blynk server
  Blynk.virtualWrite(V24, Sensor_7);  //Write values to Blynk server
  Blynk.virtualWrite(V25, Sensor_8);  //Write values to Blynk server

}

I’ve edited you post to add triple backticks at the beginning and end of each section of code, as explained in the instructions when you created your post. Please add these yourself in future posts, otherwise your unformatted code will be deleted.
Triple backticks look like this:
```

I’ve also merged this thread in with another of the threads you created on the same topic, and deleted a third thread that you created with seemingly duplicate information and (unformatted) code.

Please don’t create multiple threads on the same topic, otherwise they will be deleted, and your user account will be suspended.

Do you really think that a Blynk Community member is going to do all of this work for you?
Is this a personal project, or a school/college assignment?

Pete.

1 Like

Thanks for splitting 3 programs.
I strongly believe Blynk Community member will be helpful.
This is my personal project.
I want to collect moisture level,temperature and humidiy from different sensors and control 4 different appliances in my home.
can anyone please help to to me.

We try to help you learn, not be your code monkey :stuck_out_tongue:

Ohhh, that 3rd program… bad loop is bad :scream:

1 Like

Bad loop.yes😅 but it’s works without any issuees

Then you are good to go, without any help needed… carry on :rofl:

1 Like

nope i need help
all three programs works fine separately
when i tried to combine three programs in to one one program i ended up getting lot of errors i’m new to Blynk Community.

You’re obviously new to coding, and new to the Blynk community.

Developing, testing, debugging, maintaining and improving a project like this is a major undertaking. It’s not something that a beginner should tackle, and it’s not something that a friendly community member will knock-up for you in an hour or two on a spare evening.

If this is a home automation project then using a single NodeMCU with a multiplexer most likely isn’t the best approach. For sensors to give meaningful results then they usually need to be in physically different locations around the home. If this is the case then running long wires carrying analogue signals isn’t practical or desirable.
You’d be much better-off using a modular approach where you have one sensor per NodeMCU, and have the sensors talking to each other either via the Blynk server or using MQTT messaging. If it’s a system that needs to work even when the Internet is down then you’re going to need a local Blynk server, or a local MQTT server.

You need to learn how to write C++ code, and start experimenting with small projects. If you go for a modular approach with dispersed MCUs then it’s easier to practice with one sensor then expand your project.
You should also use decent sensors, rather than the crappy DHT11 or DHT22.

Here’s the approach I take with my home automation system:

Pete.

3 Likes

In my home automation project its just for a single room
all sensors placed in same location so there is no much difference that will give inaccurate results
yes using multiplexer isn’t a best approach to extend analog pins…
for next time i willl use arduino with esp8266 and blynk local server
what else i can use instead of DHT11 to monitor temperature and humidity?

I have completed my code but there is some delay while i’m switching physical buttons to turn ON or turn OFF digital pins.
if anyone can re-program my code to work more efficient please let me know… thanks🙂

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
// https://github.com/adafruit/DHT-sensor-library
//https://github.com/adafruit/Adafruit_Sensor
#define DHTPIN 2          // What digital pin we're connected to
#define DHTTYPE DHT11     // DHT 11

DHT dht(DHTPIN, DHTTYPE);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

char auth[] = "auth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ssid";
char pass[] = "pass";


// Set your LED and physical button pins here
const int ledPin1 = 12;
const int ledPin2 = 13;
const int ledPin3 = 14;
const int ledPin4 = 15;
const int btnPin1 = 10;
const int btnPin2 = 9;
const int btnPin3 = 3;
const int btnPin4 = 1;
int Sensor_1;
int Sensor_2;
int Sensor_3;
int Sensor_4;
int Sensor_5;
int Sensor_6;
int Sensor_7;
int Sensor_8;
int Pin_D5 = 5; // 5 is a Gpio pin number label as D5
int Pin_D6 = 4; // 4is a Gpio pin number label as D6
int Pin_D7 = 0; // 0 is a Gpio pin number label as D7

BlynkTimer timer;
void checkPhysicalButton();

int led1State = LOW;
int btn1State = HIGH;

int led2State = LOW;
int btn2State = HIGH;

int led3State = LOW;
int btn3State = HIGH;

int led4State = LOW;
int btn4State = HIGH;

// Every time we connect to the cloud...
BLYNK_CONNECTED() {
  // Request the latest state from the server
  Blynk.syncVirtual(V12);
  Blynk.syncVirtual(V13);
  Blynk.syncVirtual(V14);
  Blynk.syncVirtual(V15);

  // Alternatively, you could override server state using:
  //Blynk.virtualWrite(V12, led1State);
  //Blynk.virtualWrite(V13, led2State);
  //Blynk.virtualWrite(V14, led3State);
  //Blynk.virtualWrite(V15, led4State);

}

// When App button is pushed - switch the state
BLYNK_WRITE(V12) {
  led1State = param.asInt();
  digitalWrite(ledPin1, led1State);
}
  
 BLYNK_WRITE(V13) {
  led2State = param.asInt();
  digitalWrite(ledPin2, led2State);
 }
BLYNK_WRITE(V14) {
  led3State = param.asInt();
  digitalWrite(ledPin3, led3State);
}
BLYNK_WRITE(V15) {
  led4State = param.asInt();
  digitalWrite(ledPin4, led4State);
}

void checkPhysicalButton()
{
  if (digitalRead(btnPin1) == LOW) {
    // btn1State is used to avoid sequential toggles
    if (btn1State != LOW) {

      // Toggle LED state
      led1State = !led1State;
      digitalWrite(ledPin1, led1State);

      // Update Button Widget
      Blynk.virtualWrite(V12, led1State);
    }
    btn1State = LOW;
  } else {
    btn1State = HIGH;
  }

  if (digitalRead(btnPin2) == LOW) {
    // btnState is used to avoid sequential toggles
    if (btn2State != LOW) {

      // Toggle LED state
      led2State = !led2State;
      digitalWrite(ledPin2, led2State);

      // Update Button Widget
      Blynk.virtualWrite(V13, led2State);
    }
    btn2State = LOW;
  } else {
    btn2State = HIGH;
  }

  if (digitalRead(btnPin3) == LOW) {
    // btnState is used to avoid sequential toggles
    if (btn3State != LOW) {

      // Toggle LED state
      led3State = !led3State;
      digitalWrite(ledPin3, led3State);

      // Update Button Widget
      Blynk.virtualWrite(V14, led3State);
    }
    btn3State = LOW;
  } else {
    btn3State = HIGH;
  }

  if (digitalRead(btnPin4) == LOW) {
    // btnState is used to avoid sequential toggles
    if (btn4State != LOW) {

      // Toggle LED state
      led4State = !led4State;
      digitalWrite(ledPin4, led4State);

      // Update Button Widget
      Blynk.virtualWrite(V15, led4State);
    }
    btn4State = LOW;
  } else {
    btn4State = HIGH;
  }
}
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);   //Start serial monitor
  pinMode(Pin_D5,OUTPUT);
  pinMode(Pin_D6,OUTPUT);
  pinMode(Pin_D7,OUTPUT);
  pinMode(A0,INPUT);
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
    dht.begin();
  timer.setInterval(1000L, sendSensor);
   
  pinMode(ledPin1, OUTPUT);
  pinMode(btnPin1, INPUT_PULLUP);
  digitalWrite(ledPin1, led1State);
  

  pinMode(ledPin2, OUTPUT);
  pinMode(btnPin2, INPUT_PULLUP);
  digitalWrite(ledPin2, led2State);
  

  pinMode(ledPin3, OUTPUT);
  pinMode(btnPin3, INPUT_PULLUP);
  digitalWrite(ledPin3, led3State);
  

  pinMode(ledPin4, OUTPUT);
  pinMode(btnPin4, INPUT_PULLUP);
  digitalWrite(ledPin4, led4State);

  // Setup a function to be called every 100 ms
  timer.setInterval(500L, checkPhysicalButton);
}

void loop()
{
  Blynk.run();
  //for Sensor_1
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(50);                    //Wait for sensor
  Sensor_1 = analogRead(0);      //Read Analog pin as SENSOR1
  //Repeat for sensor_2
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(50);                    //Wait for sensor
  Sensor_2 = analogRead(0);      //Read Analog pin as SENSOR2
  //Repeat for sensor_3
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(50);                    //Wait for sensor
  Sensor_3 = analogRead(0);      //Read Analog pin as SENSOR3
  //Repeat for sensor_4
  digitalWrite(Pin_D5, LOW);     //Turn D5 Off
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(50);                    //Wait for sensor
  Sensor_4 = analogRead(0);      //Read Analog pin as SENSOR4
  //Repeat for sensor_5
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(50);                    //Wait for sensor
  Sensor_5 = analogRead(0);      //Read Analog pin as SENSOR5
  //Repeat for sensor_6
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, LOW);     //Turn D6 Off
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(50);                    //Wait for sensor
  Sensor_6 = analogRead(0);      //Read Analog pin as SENSOR6
  //Repeat for sensor_7
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, LOW);     //Turn D7 Off
  delay(50);                    //Wait for sensor
  Sensor_7 = analogRead(0);      //Read Analog pin as SENSOR7
  //Repeat for sensor_8
  digitalWrite(Pin_D5, HIGH);    //Turn D5 On
  digitalWrite(Pin_D6, HIGH);    //Turn D6 On
  digitalWrite(Pin_D7, HIGH);    //Turn D7 On
  delay(50);                    //Wait for sensor
  Sensor_8 = analogRead(0);      //Read Analog pin as SENSOR8

  //Print the results to the serial monitor
  Serial.print(" / Sensor1=");   
  Serial.print(Sensor_1);
  Serial.print(" / Sensor2=");   
  Serial.print(Sensor_2);
  Serial.print(" / Sensor3=");   
  Serial.print(Sensor_3);
  Serial.print(" / Sensor4=");   
  Serial.print(Sensor_4);
  Serial.print(" / Sensor5=");   
  Serial.print(Sensor_5);
  Serial.print(" / Sensor6=");   
  Serial.print(Sensor_6);
  Serial.print(" / Sensor7=");   
  Serial.print(Sensor_7);
  Serial.print(" / Sensor8=");   
  Serial.print(Sensor_8);
  
  
  Blynk.virtualWrite(V18, Sensor_1);  //Write values to Blynk server
  Blynk.virtualWrite(V19, Sensor_2);  //Write values to Blynk server
  Blynk.virtualWrite(V20, Sensor_3);  //Write values to Blynk server
  Blynk.virtualWrite(V21, Sensor_4);  //Write values to Blynk server
  Blynk.virtualWrite(V22, Sensor_5);  //Write values to Blynk server
  Blynk.virtualWrite(V23, Sensor_6);  //Write values to Blynk server
  Blynk.virtualWrite(V24, Sensor_7);  //Write values to Blynk server
  Blynk.virtualWrite(V25, Sensor_8);  //Write values to Blynk server
  timer.run();
}

My preference is the BME280.
You can also get these sensors on boards that provide digital or I2C bus interfacing. The majority of these boards only have 2 I2C bus addresses available, so 4 sensors would need 2 I2C buses.

You also need to read and understand the “keep your void loop clean” document that @GunnerTechTools linked to earlier, then implement the principals outlined in it.
If you don’t, you will get Blynk disconnections, and your home automation system will be useless.

Pete.

BME280 I²C bus thanks :smiley:
Is it possible to get void loop clean at the same time all this code works fine?
What modifications I can do after clearing void loop and to get the same out come?