How can i make an if conditions on 2 devices then do something?

I have 2 units on water tanks and a relay with a pump connected to 1 of the units. is there a way to make it do if tank percentage is greater than a set value on tank1 and percentage is lower than set value on the tank2 then trigger the relay on tank 1 board? but if conditions not met then do nothing?
if so then how please? this is my sketch so far that i put on both boards and just change the char auth when altering anything as have had no reason for the images to be any different as of yet.

  Download latest Blynk library here:

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials:
    Sketch generator: 
    Blynk community:  
    Follow us:        

  Blynk library is licensed under MIT license
  This example code is in public domain.

  This example runs directly on ESP8266 chip.

  Note: This requires ESP8266 support package:

  Please be sure to select the right ESP8266 module
  in the Tools -> Board menu!

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!-

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266mDNS.h>  // For OTA w/ ESP8266
#include <WiFiUdp.h>  // For OTA
#include <ArduinoOTA.h>  // For OTA

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
// char auth[] = "oiXdJdY-cmz1WbZfr7o1SdUgncXJBCQF";// House Tank
char auth[] = "x3HDpMHpx8odgd2aKsSSR-d_TeYxWWjR";// Garage Tank

// Your WiFi credentials.
// Set password to "" for open networks.
// char ssid[] = "Idamo"; // House Tank
char ssid[] = "Idamo Garage"; // Garage Tank
char pass[] = "gareth10";
int port = 8080;
// defines pins numbers
// trigpin on board is d14, echo is d15
const int trigPin = 4;
const int echoPin = 5;
int relayPin = 13;// define output pin for relay (13 = MOSI)
// defines variables
BlynkTimer timer; // Announcing the timer

long duration;
float sheight;
float capacity;
float height;
float pumptime;
float distance;
float percentageFull;
float finalPercentage;
float finalcapacity;

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,84), 8080);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Inputs
  pinMode(relayPin, OUTPUT); // Sets the relayPin as an Output
  digitalWrite(relayPin, HIGH); // Sets relayPin to HIGH
  timer.setInterval(15000L, sensorDataSend); //timer will run every sec (changed 500 1/2 a sec to 15000 15 secs)
//  ArduinoOTA.setHostname("House Tank");
  ArduinoOTA.setHostname("Garage Tank");
  ArduinoOTA.begin();  // For OTA



void sensorDataSend()
digitalWrite(trigPin, LOW);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
distance= distance-sheight;
finalcapacity= (1-percentageFull)*(capacity*100);  
/* Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.print("percentagefull: ");
Serial.print("finalPercentage: ");
Serial.print("finalcapacity: ");
Blynk.virtualWrite(V0, finalPercentage);
Blynk.virtualWrite(V1, finalcapacity);
// distance= 0;
// percentageFull= 0;
// finalPercentage= 0;
// finalcapacity= 0;

BLYNK_WRITE(V2)  // Virtual button on Vx to activate action
  int pinvalue = param.asInt();
  int buttonState = param.asInt();
     if (pinvalue == 1) {
     digitalWrite(relayPin, LOW);  // Set pin low
     Blynk.virtualWrite(V2, 1);
     timer.setTimeout((pumptime*60000L), relayOFF);  // Run ActionOFF function in 5 seconds
     if (pinvalue == 0) {
     digitalWrite(relayPin, HIGH);  // Set pin high
     Blynk.virtualWrite(V2, 0);

void relayOFF()
  digitalWrite(relayPin, HIGH);  // Set pin high
  Blynk.virtualWrite(V2, 0);

BLYNK_WRITE(V3) // Reset
if (param.asInt()==1) {
BLYNK_WRITE(V4) //input from Numeric Widget for time pump runs
  pumptime = param.asInt();                            // Assigning incoming value from pin V4 to variable
  Blynk.virtualWrite(V14, pumptime);                   // V14 just to test it's working

BLYNK_WRITE(V5) //input from Numeric Widget for height of sensor above max water level
  sheight = param.asInt();                            // Assigning incoming value from pin V5 to variable
  Blynk.virtualWrite(V11, sheight);                   // V11 just to test it's working

BLYNK_WRITE(V6) //input from Numeric Widget for max capacity of tank in L
  capacity = param.asInt();                            // Assigning incoming value from pin V6 to variable
  Blynk.virtualWrite(V12, capacity);                   // V12 just to test it's working

BLYNK_WRITE(V7) //input from Numeric Widget for height of water from bottom of tank to max water level
  height = param.asInt();                            // Assigning incoming value from pin V7 to variable
  Blynk.virtualWrite(V13, height);                   // V13 just to test it's working

BLYNK_WRITE(V99)  // Virtual button on Vx to activate action
  int pinvalue = param.asInt();
     if (pinvalue == 1) {
     digitalWrite(relayPin, LOW);  // Set pin low
     if (pinvalue == 0) {
     digitalWrite(relayPin, HIGH);  // Set pin high

void loop()
{;        // run Blynk magic;        // run timer every second
  ArduinoOTA.handle();  // For OTA


Why yes! With enough skill in C++ you could land a space ship in the moon! (I guess) However that skill isn’t gained in 1 day or 1 sketch.

There is a relay off function in your code that appears to be called one time. A good practice would be to use it everywhere and have a corresponding relayOn function. If that’s to difficult right now use the digitalWrite HIGH/LOW commands.

In your question I believe you are talking about communicating between two boards. You can do this via Blynk bridge or another option is ESPnow but first I think you need to figure out a basic if, else if, else statement which is the very base of computer logic. So create a pumpONOFF function called every second that tests your percentage and triggers a relay HIGH or LOW. Your relay may be active high or active low. Let us know how that works.