Virtual pins definition

Can you explain how virtual pins are defined? I assume that each virtual pin is a variable.
Where is the declaration of V1? if all virtual pins are pre define how many are there ? V100 is OK?

Thanks
Johanan

There are either 32 (0 to 31) or 128 (0 to 127) depending on your hardware.

It’s a component of the Blynk library, so you don’t have to declare anything. Just use them :slight_smile:

Thanks.
I just started to look into Blynk, and I like to understand what am I doing…

Johanan

i realised that Blynk is not like many other things, you dont have to do as much because the Blynk server does a lot of the hard work.

so my advice (as a n00b) is to follow the examples as closely as possible…

1 Like

Yes, but some (or good) understanding of what is “under the hood”, makes you a better programmer on any environment.
I would like to know how Blink.run() binds all the staff, so I can write my code in an efficient and elegant way.
Johanan

The thing is, you have to let go of that idea. Blynk is made for everyone who wants to do stuff with IoT enviroments. I couldn’t care less about what Blynk.run() does. It’s also of no consquence. People like @vshymanskyy and @Dmitriy are way better in doing the “under the hood stuff”. I can focus entirely on functionality instead of solving complicated coding issues. The first thing you want to do is keep the void loop() clean. And above that, avoid delays. In the loop you start your timers and Blynk.run() and that’s it.

Let the magic be there where it needs to be :wink:

3 Likes

OK, assume I accept this. Now I would like to build a very simple watering system, so I can set the time of a valve to open, the time it stays open and day of week for it to work.
This is a very simple task. I thought that I could do this with Blynk in 30 minutes. But it looks like it can’t be done. There is no simple way to set up these parameters. (sliders are not a solution)
I can write the whole thing in 2 hrs using web-server and a simple HTML page on Arduino, but then I have to setup my router NAT, some way (dynDNS) to get to my router etc., all the staff that Blynk i is very good at.
Quite disappointing. (and if I would like to check the weather, and open one mor TCP socket, I don’t see how it can be done)

Johanan

This is all possible in Blynk. I don’t really see your point. There is an RTC widget which does exactly what you want. And sliders are one possible answer. You could use increment buttons, terminal input … there is much more to be explored, so yes, it can be done, in more ways than one. There are a couple of examples on the forum of what you want to build. Some automated watering systems etc.

The old saying is “can’t see the forest for the trees” comes to mind…

There are several automatic watering systems described on this forum, have none of these that you have reviewed provided any insight?

Thanks ( Lichtsignaal, Dave1829) for your replies. I hope I jumped into conclusions too fast.
Will search for examples.
Still a simple input box widget will be very handy.
Johanan

How often will you be changing the day/time the watering goes on/off?

Not very often. The point is that I don’t want to do that, I want my wife to do it from her phone :slight_smile:

Ha, lazy as me! I can appreciate that :wink:

I’m still contemplating building an automated greenhouse and there are many many examples out there. “Blynkifying” existing Arduino code is also not very difficult and from what I gather you know your way around code. Blynk is not the magic answer to all your needs, but it saves a hell of a lot of time :slight_smile:

Lazy guys invent things. All others just do everything the old way…:sunglasses:

Below is a screenshot of a “wife proof” interface. Not pretty, not difficult but it works. Sliders as shown are 12:39. You can always hide the ugly interface on a sundry tab.

1 Like

Use small sliders with range of 1-24 and 0-59 and then have it format the time and send it back to a value widget too… then she can see the formatted time. If you use “send without release” feature on the slider it will almost update as you slide it. Slick!

/*
  Virtual Ports:
  V0 = Value 
  V1 = Slider 0-23 Send Values on release OFF
  V2 = Slider 0-59 Send Values on release OFF
*/
/****************************************************************************/
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
/****************************************************************************/
char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxxxxx"; 
char pass[] = "xxxxxxxx"; 
/****************************************************************************/
SimpleTimer timer_formatTime;
int hours;
int mins;
String formatedTime;
/****************************************************************************/
BLYNK_WRITE(1) {
  hours = param.asInt();
}
BLYNK_WRITE(2) {
  mins = param.asInt();
}

void formatTime(){
  formatedTime = hours;
  formatedTime += ':';
  formatedTime += mins;
  Blynk.virtualWrite(0,formatedTime);
}

/****************************************************************************/
void setup() {
  WiFi.mode(WIFI_STA);
  Blynk.begin(auth, ssid, pass);
  while (Blynk.connect() == false) {}
  //ArduinoOTA.setHostname("Bathroom-Brain"); // OPTIONAL
  ArduinoOTA.begin();
  timer_formatTime.setInterval(100L, formatTime);
}
/****************************************************************************/
void loop() {
  Blynk.run();
  ArduinoOTA.handle();
  timer_formatTime.run();
}

Small sliders from 0 to 59 are unusable if you want to set the variable any time soon.

She can see the time on the hardware in front of her.

@Jamin 2 variables (hours 1-24 and minutes 0-59) would work well with 2 Menu widgets for a “wife proof” interface. I like the super fast roll in the menus. Would be nice if we could copy menu’s from place to place as creating 84 menu items (24 + 60) on a Smartphone is not fun for developers.

I just find menus waaay to clunky… too many gestures… much much easier to use sliders to select menu items and output the title to a value widget in real time