Virtual Pin Usage (for display and email address)

I have a couple questions about using virtual pins:

  1. I used virtual pins to display the date and time from my device. But since I’ll also activated the DB I’m finding date and time data the isn’t necessary and will have to be deleted server side. Is there some other way to display the date and time in a ‘label widget’? Or not physically write the records?

  2. I’m finding the need to change email address used in alerts without having to compile firmware each time.

So I came up with the following workaround:
1.Did INSERT in Blynk datebase table to save the email address for pin 30.
2.added code below to device program
BLYNK_WRITE(V30) {
String eMail;
eMail1 = param.asString();
}
then in Setup addded
Blynk.syncAll();

Will this load Pin 30 into the email string?.

Perhaps use the Menu Widget instead, to choose which email address to use.

switch (param.asInt())
  {
    case 1: { // Item 1
      String eAddress = "bob@gmail.com";
      break;
    }
    case 2: { // Item 2
      String aAddress = "fred@gmail.com";
      break;
    }    
  }

Blynk.email(eAddress, "Subject", "Your message goes here");

I suppose you could also use the Terminal input to generate an address on the fly.

Check email widget settings. It has email field of receiver.

Hi:

How do I get the virtual pin’s string value of a non-widget pin?

Stored email address in V30 and want to get the ‘stringvalue’ from the server. Everything I tried gets nothing.

Also not sure I understand what the BLYNK_VIRTUALWRITE does? Read from server or write to sever? ASSUMMING that it’s write to the server so that Blynk UI can use it. Am I correct? If so how can I have it only write ONE record to the DB. I using a Vpin to sending the date and time to UI and am seeing multiple DB records each time is is updated

Dmitriy
I need more than one email receivers. Currently I hard coding four.

Not sure what you mean… perhaps you mean physical pin on the MCU? If so, you would use digitalRead() or analogRead() in this method:

Blynk.virtualWrite(vPin, digitalRead(pin));

If by UI you mean the App, then yes, that is how you send data from Device (sketch) to App (Display Widget). I am not positive concerning the DB, but I am guessing if you have the DB active, then it records all virtual pin data; I am unsure if you can pick and chose.

All four or some of the four?

If it’s all four you can create a new GMail account and forward to the other 4.