Hi,
Virtual pins are separate entities and do not relate to harware pins.
You can assign widgets to either hardware pins OR any virtual pins.
Hardware pin control does just that without software intervention. (Simple control of on/off, pwm output, adc reading etc}
Virtual pin control infers the use of related software routines, in the form of a reading response if data is being sent (Button / Slider / Terminal etc) or sending data to widgets ( led, value, LCD, terminal)
Reading data sent by the app uses BLYNK_WRITE(V’pin no’) as in for example
BLYNK_WRITE(V21){
String pinData = param.asStr(); // data comingin
slidV21val = param.asInt();
lastVal21=slidV21val;
const char* slid_dat = pinData.c_str();
}
If you only have two gpio pins, you can still use as many Virtual pins as you like.
The above reading of the app widget could be a button or a slider using V21 etc, then you can do want you want with it. If you set a gpio as an output you could control it according to what has been received and any conditions that might need to be met. ie. your GPIO0.
In your program you would set GPIO2 as an input.
This would be fed by some connection to the light source. (hardwired, LDR etc)
The level sensed by GPIO2 now needs to be sent to the app, and displayed in some format.
You want to use the LED widget. Ok… select it and assign any available Virtual pin number.
Assign a name to the led widget …
WidgetLED led1(0) //note that led widget in app has V0 assigned to it
You can now switch the app’s led on or off by using within your program.
led1.off() or led1.on()
For testing … in the BLYNK_WRITE, if the received value is 1 from the button, switch the light on. Then sense your GPIO2 pin, and according to the conditions, use led1.on() of .off().
Similarly you could use the LCD widget and send “Light is on (Off)”. etc.
Remember you also have the adc pin, which can either be directly used and displayed in a Value box, or the data could be sent to a Virtual pin via software.
I use the hard version to take a reading every 5 secs. In my ESP12, the reading is reversed, so for a scale of 0 - 100, in the app set up of a Value box, adc0 is selected as the pin, and the range value set as 100 /~/ 0. Where /~/ represents the selection of the bridging wire between the boxes. The time is set for how often it it is required to be read.
You could also display the signal strength that the esp receiving, which can be useful.
Have a value button on say V30, set to 1 second or whatever, then in your program …
BLYNK_READ(V30)
{
Blynk.virtualWrite(V30, WiFi.RSSI() );
}
Hope this helps a little