Virtual Pin Not declared in this scope

Hello good day ! , I used blynk more than 2 years ago, I already believe, I put it together and installed it and set it up for my house and I never touch it again now I am going to add many more things to put together but when compiling my old code it throws this error that I cannot know why.

The truth I have lost libraries and many more things from the arduino since in 2 years I reinstalled the pc several times.

I use Arduno Mega + Ethernet Shield W5100.
Compile with arduino 1.8.13

Error: ‘V73’ was not declared in this scope
Line: : WidgetTerminal terminal(V73);


#include <Blynk.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <DHT.h>
#include <Wire.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

#define DHTPIN 23
#define DHTTYPE DHT11
#define BLYNK_PRINT Serial

char auth[] = "";

#define W5100_CS  10
#define SDCARD_CS 4

BlynkTimer timer;
WidgetTerminal terminal(V73);
WidgetLED ledbomba(V72);
DHT dht(DHTPIN, DHTTYPE);
WidgetRTC rtc;
bool Connected2Blynk = false;

const int BombaAgua = 22;
const int ReflectorPatio = 24;
const int Presurizadora = 26;
const int NivelTanke = 28;
const int SensorPorton = 52;
const int BotonCuarto = 50;

const int ReflectorPorton = 53;
const int ReflectorTerreno = 51;
const int AperturaPorton = 49;
const int LuzCuarto = 47;

int EstadoBombaAgua = LOW;
int EstadoReflectorPatio = LOW;
int EstadoPresurizadora = LOW;
int EstadoNivelTanke = LOW;

bool isFirstConnect = false;

int EstadoLuzCuarto, EstadoBotonCuarto, EstadoReflectorPorton, EstadoReflectorTerreno, EstadoAperturaPorton, EstadoSensorPorton;

int HoraDia = 5;
int HoraNoche = 20;

void setup()
{
	Serial.begin(9600);
	
	pinMode(SDCARD_CS, OUTPUT);
	digitalWrite(SDCARD_CS, HIGH);
	
	Blynk.begin(auth, IPAddress(192, 168, 1, 14), 8080);
	
	pinMode(BombaAgua, OUTPUT);
	pinMode(ReflectorPatio, OUTPUT);
	pinMode(Presurizadora, OUTPUT);
	
	pinMode(LuzCuarto, OUTPUT);
	pinMode(ReflectorPorton, OUTPUT);
	pinMode(ReflectorTerreno, OUTPUT);
	pinMode(AperturaPorton, OUTPUT);
	
	pinMode(BotonCuarto, INPUT_PULLUP);
	pinMode(SensorPorton, INPUT_PULLUP);
	pinMode(NivelTanke, INPUT_PULLUP);
	
	
	//dht.begin();
	//rtc.begin();
	// setSyncInterval(10 * 60);
	//terminal.clear();
	//terminal.println(F("Jarvis Home Iniciado V2"));
	//terminal.println(F("-------------"));
	//terminal.println(F("Version: " BLYNK_VERSION));
	//terminal.flush();
	timer.setInterval(11000L, CheckConnection); 
	timer.setInterval(1400L, botonluzcuarto);
	//timer.setInterval(15000L, temperaturayhumedad);
	//timer.setInterval(13200L, sensorporton);

}

void CheckConnection(){
	Connected2Blynk = Blynk.connected();
	if(!Connected2Blynk){
		Serial.println("Not connected to Blynk server");
	}
	else{
		Serial.println("Still connected to Blynk server");    
	}
}

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

BLYNK_CONNECTED() {
	
	if (isFirstConnect) {
		Blynk.syncAll();
		isFirstConnect = false;
	}
	
	Blynk.syncVirtual(V1);
	Blynk.syncVirtual(V2);
	Blynk.syncVirtual(V3);
}

BLYNK_WRITE(V1) {
	EstadoBombaAgua = param.asInt();
	digitalWrite(BombaAgua, EstadoBombaAgua);
	
	if (EstadoBombaAgua == 0) {
		ledbomba.on();
		terminal.println(F("Bomba Encendida"));
		terminal.flush();
	}
	else {
		ledbomba.off();
		terminal.println(F("Bomba Apagada"));
		terminal.flush();
	}
}

BLYNK_WRITE(V2) {
	EstadoReflectorPatio = param.asInt();
	digitalWrite(ReflectorPatio, EstadoReflectorPatio);
	terminal.println(F("Reflector Patio: "));
	terminal.println(EstadoReflectorPatio);
	terminal.flush();
}
BLYNK_WRITE(V3) {
	EstadoPresurizadora = param.asInt();
	digitalWrite(Presurizadora, EstadoPresurizadora);
	
	if (EstadoPresurizadora == 0) {
		Blynk.virtualWrite(V103, "Presurizada");
	}
	else {
		Blynk.virtualWrite(V103, "Normal");
	}
	
}

BLYNK_WRITE(V4) {
	EstadoLuzCuarto = param.asInt();
	digitalWrite(LuzCuarto, EstadoLuzCuarto);
}
BLYNK_WRITE(V5) {
	EstadoReflectorPorton = param.asInt();
	digitalWrite(ReflectorPorton, EstadoReflectorPorton);
}
BLYNK_WRITE(V6) {
	EstadoReflectorTerreno = param.asInt();
	digitalWrite(ReflectorTerreno, EstadoReflectorTerreno);
}

BLYNK_WRITE(V7) {
	EstadoAperturaPorton = param.asInt();
	digitalWrite(AperturaPorton, EstadoAperturaPorton);
}

BLYNK_WRITE(V8)
{
	HoraNoche = param.asInt();
	terminal.println("Hora Noche Modificada: ");
	terminal.println(HoraNoche);
	terminal.flush();
}

BLYNK_WRITE(V9)
{
	HoraDia = param.asInt();
	terminal.println("Hora Dia Modificada: ");
	terminal.println(HoraDia);
	terminal.flush();
}

void sensorporton()
{
	
	EstadoSensorPorton = digitalRead(SensorPorton);
	
	int hora = hour();
	if (hora >= HoraDia && hora <= HoraNoche) {
		terminal.println("Sensonr Porton Activo");
		terminal.flush();
		if (EstadoSensorPorton != 0) {
			Blynk.virtualWrite(V5, "1");
		}
		else
		{
			Blynk.virtualWrite(V5, "0");
		}
		
	}
}

void botonluzcuarto()
{
	if (digitalRead(BotonCuarto) == LOW) {
		if (EstadoBotonCuarto != LOW) {
			EstadoLuzCuarto = !EstadoLuzCuarto;
			digitalWrite(LuzCuarto, EstadoLuzCuarto);
			Blynk.virtualWrite(V4, EstadoLuzCuarto);
		}
	EstadoBotonCuarto = LOW;
	} else {
		EstadoBotonCuarto = HIGH;
	}
}

void temperaturayhumedad()
{
	float h = dht.readHumidity();
	float t = dht.readTemperature();
	if (isnan(h) || isnan(t)) {
		String currentTime = String(hour()) + ":" + minute() + ":" + second();
		String currentDate = String(day()) + "/" + month() + "/" + year();
		terminal.println("Error Temperatura Cuarto Kevin: ");
		terminal.print(currentTime);
		terminal.print(" ");
		terminal.print(currentDate);
		terminal.println();
		terminal.flush();
		return;
	}
	Blynk.virtualWrite(V10, h);
	Blynk.virtualWrite(V11, t);
	
}
void sensortanque()
{
	EstadoNivelTanke = digitalRead(NivelTanke);
	
	if (EstadoBombaAgua != 0) {
		Blynk.virtualWrite(V1, 1);
	} else
	{
		Blynk.virtualWrite(V1, 0);
	}
}

@Kevin_Escudero: Which version of the Blynk library do you use? (https://github.com/blynkkk/blynk-library/releases)

@IBK v0.6.1 Last.

Are you sure you chose Arduino Mega as your board type when compiling, not Uno?

Pete.

1 Like

@PeteKnight That was the problem, but I don’t understand what influences if I was just “Compiling” to see if it was ok, the code wasn’t uploading it.

Thx mate, idk if u can close this th.

The library limits the number of virtual pins to 32 (0-31) for the Uno, as it doesn’t have sufficient memory to handle the 128 pins that the Mega can (just about) handle.

Pete.

1 Like

Just to elaborate on this a bit more…

When you choose a board within the Arduino IDE, it changes the way that the compiler works. I’ve never delved into the details of how this is done within the IDE, but it changes the paths so that different ‘cores’ that are used during compilation, and the board type is set so that it can be read by the libraries in use.

Blynk has a library file called BlynkDetectDevice.h which reads the board type from the IDE and configures certain parameters.

The entry for the Uno looks like this:

#define BLYNK_INFO_DEVICE  "Arduino Uno"

and the entry for the Mega looks like this:

#define BLYNK_INFO_DEVICE  "Arduino Mega"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024

As you can see, the Uno has no entries to override the default number of virtual pins (32), but the Mega does.

As a result, when the compiler finds a line that references a virtual pin number greater than 31 for a board that uses the default maximum of 32 virtual pins (numbered 0-31) then the compiler throws an error, because that number of pins inst compatible with that hardware.

Pete.