BLYNK_WRITE not being called

I am currently using a NodeMCU to control some rgb lights in my room, and I’m having some trouble with the BLYNK_WRITE functions.

My NodeMCU is connected to the Blynk server, and I can see that the device is online in the app:

For now I’m just using the example code:

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

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

Everything should be good, but when I move the slider attached to V1, nothing appears in the serial monitor. I have made sure that the app is running and the slider is attached to the NodeMCU device.

If anyone has any insight as to what’s going on here, it would greatly be appreciated. Thanks!

Can you post a screenshot of the widget setup in the app?

As you are using Blynk Legacy, you should be using library version 0.6.1, not 1.0.1

Pete.

Here’s the setup I’m using now:

I also just made sure to downgrade to 0.6.1, but the issue persists.

My guess is that the device you have selected (circled in red) is not the same one as the Auth token that you’re using in your sketch.

Pete.

I double checked and that device has the correct auth token as I was using. Just to be sure I refreshed the token and put the new one in the sketch, but still nothing.

Post the latest auth token that you put in the sketch, you can always refresh it again once we’ve checked it.

Pete.

The token is ZcEh0pYCJTMMn9mng_47os1GojpyY8W0

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

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

I have no idea while this isn’t working.

I’d suggest that you delete the project from the app and add a single new device and one widget attached to V1. Use the new Auth token 8n your sketch and see if it works.

Pete.

Have you tried to comment out the #define BLYNK_PRINT Serial ?

Seems like starting a new project in the app did the trick. Thanks for your help!

1 Like