Virtual pin doesn't seem to update values

Greetings everybody! I am working on a project where I require to send sensor value from an FSR to a virtual pin (V2)
• Hardware model + communication type: Arduino UNO Wifi Rev2
• Blynk server
• Blynk Library version 1.2.0

The problem is, the virtual pin doesnt seem to register/update the values when I press my FSR.
here’s the code :

/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPLQoMt10rp"
#define BLYNK_TEMPLATE_NAME "Servo Control and FSR"
#define BLYNK_AUTH_TOKEN "REDACTED"

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


#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "JioFiber";
char pass[] = "REDACTED";

int fsrPin = 0;     // the FSR and 10K pulldown are connected to A0
int fsrReading;     // the analog reading from the FSR resistor divider
 
void setup(void) 
{
  Serial.begin(115200);   
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

}

BLYNK_WRITE(V2) 
{
  fsrReading = analogRead(fsrPin);
  //Serial.println(fsrReading);
  Blynk.virtualWrite(V2, fsrReading);  
}  

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

any help will be most appreciated. Thanks.

This makes no sense
In your code, V2 is a virtual button

how should I tweak my code it so that my sensor data gets pushed to v2?

@Nishit Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

// Set password to “” for open networks.
char ssid[] = “JioFiber”;
char pass[] = “REDACTED”;

int fsrPin = 0; // the FSR and 10K pulldown are connected to A0
int fsrReading; // the analog reading from the FSR resistor divider

BlynkTimer timer; // <---

void setup(void)
{
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(5000L, fsr);//<--
}

void fsr()
{
fsrReading = analogRead(fsrPin);
//Serial.println(fsrReading);
Blynk.virtualWrite(V2, fsrReading);
}

void loop()
{
Blynk.run();
timer.run();
}
1 Like

Chef’s kiss. Thanks. That’s the solution.

1 Like