BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Image Gallery

rpi
ios

#1

Hello there, I am trying to add to my project an Image Gallery widget and I cant fully understand how it works… I have found some information(peace’s of code) in the information about the widget in the app but they are for Arduino-IDE coded devices and not python…
Any links that can put me on the right direction would be great!
Thanks!

-EDIT:
If there isn’t any examples for python code I would like one example for the esp8266…


#2

First, your image needs to be available to the App via whatever network it connects to. You can use whatever URL you need and as long as the Widget sees it, it should work.

For example: On my Local Server I use SimpleHTTPServer and run this in my /etc/rc.local

cd /home/gunner/Blynk/images/
sudo python -m SimpleHTTPServer &

Then I put all my wanted images in the server’s Image folder .

In the App, I point to said file location as such (currently only visible when inside my network)…

Then I can change which image I want shown via code like this…

Arduino/ESP code:

BLYNK_WRITE(V4) {  // Button widget on V4
  if (param.asInt() == 1) {
     Blynk.virtualWrite(V3,1);  // Show image 1 - Widget on V3
  } else {
     Blynk.virtualWrite(V3,2);  // Show image 2 - Widget on V3
  }
}

Python code:

@blynk.VIRTUAL_WRITE(4) # Button Widget on V4
def my_write_handler(value):
    if int(value) == 1:
	blynk.virtual_write(3,1) # Show image 1 - Widget on V3
    else:
	blynk.virtual_write(3,2) # Show image 2 - Widget on V3

As of yet, or at least as far as i have tested, there is no way to send the image URL directly from the script, or to populate the Widgets image collection from the script. So far it must be all manually entered in the App… but then it is still in Beta


Blynk Button State in Python
#3

A post was split to a new topic: Help me to rotating this fan