What is Virtual Pins Exchange Any Data Between Blynk App & Your Hardware – Pavel

Virtual pins are different than  Digital and Analog Input/Output (I/O) pins. They are physical pins on your microcontroller board where you connect sensors and actuators.

Blynk lets you control any hardware connected to Digital and Analog pins without having to write any additional code.

For example, if you need to turn On/Off LED connected to Digital pin, you don’t have to write any code:

  1. Just use BlynkBlink code for your hardware.
  2. In the Blynk app – add Button Widget and set it to pin D8
  3. That’s it! No additional code is required. Simply press Play in the app.

That was, easy, right? But what if you need more flexibility?

Virtual Pins

Virtual pins allow you to interface with any sensor, any library, any actuator.

Imagine that there are “virtual” pins that you can use

Think about Virtual Pins as a box where you can put any value, and everyone who has access to this box can see this value.

It’s a very powerful feature to display and send any data from your hardware to Blynk app.

☝️ Remember, that virtual pins have no physical properties.

There are two fundamental commands you need to know to use Virtual Pins:

To read data from Blynk app widgets

Use this block of code:

BLYNK_WRITE(V5) // V5 is the number of Virtual Pin  
  int pinValue = param.asInt();

Where param.asInt()  is the value from V5.

👉 Full article: How to control anything with Blynk

To send data from your hardware to Blynk app

Use this command Blynk.virtualWrite(V5) where V5 is the Virtual Pin you are using.

Don’t place
Blynk.virtualWrite(V5) inside  void loop()

– Why?
– Read here

👉 Full article: How to display any sensor data with Blynk

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: