Clearing string input after password sent

I did review the documents and the forums but couldn’t find anything on this subject.

OK so I send a password string from my phone to my device. I do not want the string to remain in the widget on the phone once it is sent. How do I clear the widget’s string field that displays the password after it is sent?

I know I can use a default string after the time limit in the data stream but this doesn’t update the display of the password on the phone.

Anyone have example code or recommendations?

Regards,

Roger

Use Blynk.virtualWrite(vPin) to write an empty string value (“ “) to the widget.
You’d probably put this in your BLYNK_WRITE(vPin) function, after you’ve grabbed the incoming value and saved it to a string variable.

Pete.

Thanks for the response Pete, I will give it a try.

Regards,

Roger

Pete,
I tried but the widget still displays the password; code below.

Regards,

Roger

//**************************************************************
//Virtual Variable (V2)- Handling the password to open the door.
//**************************************************************
BLYNK_WRITE(V2)
{
  // Get the password for opening the door.
  password = param.asStr();
  // Convert the password to an array of characters;
  // this is necessary for comparing the sent password
  // to the stored password.
  int sent_password = password.toInt();
  //Serial.println (sent_password);
  int stored_password = 888888;
  // Compare the passwords, if they match set 
  // password_enabled_for_open_command variable.
  if( sent_password == stored_password)
  {
   password_enabled_for_open_command = 1; 
   //Turn ON the Password Accepted LED
   Blynk.virtualWrite(V4,ON);
   Blynk.virtualWrite(V2,"");  //Here is where I try to clear the widget.
  }//End of if( sent_password == stored_password)

  // Clear the received password.
  password = "";
}

I’d actually suggested “ “ rather than “”

But, are you sure that you’re reaching the Blynk.virtualWrite command?
Maybe try adding a serial print command within the if statement.

Pete.

Pete,

Thank you. I put the space between the quotes as you suggested, and it now works.

Regards,
Roger

1 Like