How to Create Blynk Virtual Pin This Code

hi guys

ı am using this code but ı don’t know how can ı add virtual pin this code please help me.

#include <SoftwareSerial.h>
#include <ModbusMaster.h>

SoftwareSerial mySerial(13, 15); // RX, TX

#define MAX485_DE      5
#define MAX485_RE_NEG  4

ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  // Init in receive mode
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
  Serial.println("start init serial 0");
  Serial.begin(9600);
  
  while (!Serial) {
    Serial.println("loop for init serial 0"); 
  }
  Serial.println("start init software serial");
  mySerial.begin(9600);
  while (!mySerial) {
    Serial.println("loop for init software serial");
  }
  
  node.begin(1, mySerial);  
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

}

void loop()
{
  uint8_t result;
  uint16_t data[2];
   
  Serial.println("get data");
  result = node.readInputRegisters(1, 2);
  if (result == node.ku8MBSuccess)
  {
    Serial.print("Temp: ");
    Serial.println(node.getResponseBuffer(0)/10.0f);
    Serial.print("Humi: ");
    Serial.println(node.getResponseBuffer(1)/10.0f);
    Serial.println();
  
  }
  delay(1000);
}

This code is not complete. You should study more (Blynk version <= 1.0.1 can use BlynkTimer)

#include <SoftwareSerial.h>


//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>
BlynkTimer timer;






#include <ModbusMaster.h>

SoftwareSerial mySerial(13, 15); // RX, TX

#define MAX485_DE      5
#define MAX485_RE_NEG  4

ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);
  // Init in receive mode
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
  Serial.println("start init serial 0");
  Serial.begin(9600);

  while (!Serial) {
    Serial.println("loop for init serial 0");
  }
  Serial.println("start init software serial");
  mySerial.begin(9600);
  while (!mySerial) {
    Serial.println("loop for init software serial");
  }

  node.begin(1, mySerial);
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

  timer.setInterval(2000L, ReqadT_H);  //Function internetcheck


}

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

}


void ReqadT_H() {

  uint8_t result;
  uint16_t data[2];

  Serial.println("get data");
  result = node.readInputRegisters(1, 2);
  if (result == node.ku8MBSuccess)
  {

    data[0] = node.getResponseBuffer(0) / 10.0f;
    Serial.print("Temp: ");
    Serial.println(data[0]);
    Blynk.virtualWrite(V1, data[0]);

    data[1] = node.getResponseBuffer(1) / 10.0f;
    Serial.print("Humid: ");
    Serial.println(data[1]);
    Serial.println();
    Blynk.virtualWrite(V2, data[1]);

    //    Serial.print("Temp: ");
    //    Serial.println(node.getResponseBuffer(0) / 10.0f);
    //    Serial.print("Humi: ");
    //    Serial.println(node.getResponseBuffer(1) / 10.0f);
    //    Serial.println();

  }

}












ı am using blynk ver 2.0 and esp 8266 node mcu. ı found this code from this site,

https://www.cybertice.com/article/451/%E0%B8%AA%E0%B8%AD%E0%B8%99%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-esp8266-%E0%B9%80%E0%B8%8B%E0%B9%87%E0%B8%99%E0%B9%80%E0%B8%8B%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B8%A7%E0%B8%B1%E0%B8%94%E0%B8%AD%E0%B8%B8%E0%B8%93%E0%B8%AB%E0%B8%A0%E0%B8%B9%E0%B8%A1%E0%B8%B4%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%8A%E0%B8%B7%E0%B9%89%E0%B8%99-xy-md02-sht20-temperature-and-humidity-rs485