Image gallery not updating

I’m simply trying to change image gallery photo using a button connected to V3. But it’s not working. The photo is not changing.

My code is:

#include <Arduino.h>


// *** MAIN SETTINGS ***
// Replace this block with correct template settings.
// You can find it for every template here:
//
//   https://blynk.cloud/dashboard/templates

#define BLYNK_TEMPLATE_ID "TMPL5-swU26dE"
#define BLYNK_TEMPLATE_NAME "LED ESP32"


#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"

#define LED_PIN 2  // Use pin 2 for LED (change it, if your board uses another pin)


// V0 is a datastream used to transfer and store LED switch state.
// Evey time you use the LED switch in the app, this function
// will listen and update the state on device
BLYNK_WRITE(V0)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    digitalWrite(LED_PIN, HIGH);
    Serial.print("value V0 = ");
    Serial.println(value);
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.print("value V0 = ");
    Serial.println(value);
  }
}

BLYNK_WRITE(V3)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    Blynk.setProperty(V3, "urls", "https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png");
    Serial.print("value V3 = ");
    Serial.println(value);
   
  } else {
    Blynk.setProperty(V3, "urls", "https://seeklogo.com/images/Y/yahoo-new-2019-logo-FE1BC0938E-seeklogo.com.png");
 
  }

}

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  
  // Debug console. Make sure you have the same baud rate selected in your serial monitor
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
  
}

void loop() {
  BlynkEdgent.run();
  delay(10);

}

And my image gallery settings are attached:

@gavishka10 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.

Edited.

What process is triggering your BLYNK_WRITE(V3) function?

Why are you using "urls" but only specifying one url?

Why do you have this in your void loop?..

Pete.

Hi Pete,

  1. A switch connected with V3 DataStream. V3 is also connected to the image gallery.
  2. I used the following line but it’s not working either
Blynk.setProperty(V3, "url", 0 ,"https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png");
  1. It was just there in the example code in the official blynk library.

I think I’d use a switch attached to a different datastream to do that.

Are any of your images displaying?
If not then it may be an issue with accessing them. Some people use this topic to make their images accessible…

Pete.

1 Like

Tried all the methods you mentioned but still no luck.

If anyone was able to change the image gallery photo via setProperty function please be kind enough to share the code.

Thanks

But you didn’t answer my question, and you didn’t upload your images to the topic I suggested.

Pete.

I did. I used an already uploaded image to Blynk community.

And changed datastreams.

[Screenshot of code removed by moderator]

Please don’t post screenshots of code. Post the text and use triple backticks.

You’ve declined to answer this question so far…

Without that info I can’t begin to understand what the issue(s) might be.

Pete.

Sorry about that Pete.
Images are displaying when i manually give the link in the web dashboard image gallery settings. But not when i use the setProperty function.

Thanks

If you edit your previous post and insert the actual code rather than a screenshot then I’ll do some testing based on the image urls you’ve tried to use.

Pete.

BLYNK_WRITE(V2)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    Blynk.setProperty(V3, "url", 1, "https://community.blynk.cc/uploads/default/original/2X/b/bfe53d09be202d13304ee085e1491ccb2c599e73.gif");
    Serial.print("value V2 = ");
    Serial.println(value);
  } else {
    Blynk.setProperty(V3, "url", 1, "https://community.blynk.cc/uploads/default/original/2X/3/32e4b6de68f113e83a4e0f6f66fc838ffaa7985c.gif");
    
  
  }

}

Try this approach…

#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_TEMPLATE_NAME "REDACTED"
#define BLYNK_AUTH_TOKEN "REDACTED"

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

int image_index = 0;

BlynkTimer timer;

void setup()
{
  Serial.begin(74880);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1000L, toggle_image);
}

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

BLYNK_CONNECTED()
{
  // urls string cannot exceed 255 characters
  // fierts urle gets innex number zero...
  Blynk.setProperty(V0, "urls","https://community.blynk.cc/uploads/default/original/2X/b/bfe53d09be202d13304ee085e1491ccb2c599e73.gif", "https://community.blynk.cc/uploads/default/original/2X/3/32e4b6de68f113e83a4e0f6f66fc838ffaa7985c.gif");
}

void toggle_image()
{
  Blynk.virtualWrite(V0, image_index);


  // switch to the other image index number...
  if(image_index == 0)
  {
    image_index = 1;
  }
  else
  {
    image_index = 0;    
  }
}

Note that this uses an Image gallery widget attached to V0

Pete.

Thanks a ton! It’s working now.

#include <Arduino.h>


// *** MAIN SETTINGS ***
// Replace this block with correct template settings.
// You can find it for every template here:
//
//   https://blynk.cloud/dashboard/templates

#define BLYNK_TEMPLATE_ID "TMPL5-swU26dE"
#define BLYNK_TEMPLATE_NAME "LED ESP32"


#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"

#define LED_PIN 2  // Use pin 2 for LED (change it, if your board uses another pin)


// V0 is a datastream used to transfer and store LED switch state.
// Evey time you use the LED switch in the app, this function
// will listen and update the state on device
BLYNK_WRITE(V0)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    digitalWrite(LED_PIN, HIGH);
    Serial.print("value V0 = ");
    Serial.println(value);
  } else {
    digitalWrite(LED_PIN, LOW);
    Serial.print("value V0 = ");
    Serial.println(value);
  }
}

BLYNK_WRITE(V3)
{
  // Local variable `value` stores the incoming LED switch state (1 or 0)
  // Based on this value, the physical LED on the board will be on or off:
  int value = param.asInt();

  if (value == 1) {
    Blynk.setProperty(V2, "urls", "https://community.blynk.cc/uploads/default/original/2X/b/bfe53d09be202d13304ee085e1491ccb2c599e73.gif", "https://community.blynk.cc/uploads/default/original/2X/3/32e4b6de68f113e83a4e0f6f66fc838ffaa7985c.gif");
    Serial.print("value V3 = ");
    Serial.println(value);
    Blynk.virtualWrite(V2, 0);
  } else {
    Blynk.setProperty(V2, "urls", "https://community.blynk.cc/uploads/default/original/2X/b/bfe53d09be202d13304ee085e1491ccb2c599e73.gif", "https://community.blynk.cc/uploads/default/original/2X/3/32e4b6de68f113e83a4e0f6f66fc838ffaa7985c.gif");
    Blynk.virtualWrite(V2, 1);
  
  }

}

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  
  // Debug console. Make sure you have the same baud rate selected in your serial monitor
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
  
}

void loop() {
  BlynkEdgent.run();
  delay(10);

}

I was just missing the lines:

   Blynk.virtualWrite(V2, 0);

   Blynk.virtualWrite(V2, 1);

1 Like