Button with a pin code

Всім привіт!
Хотілось би мати в майбутньому - кнопку з пін кодом.
В мене є головне реле на вхід хати. Іноді мій смартфон попадає до рук маленької дівчинки :slight_smile: І буває так, що ця дівчинка вимикає всю електрику в хаті.
Як би для підтвердження був якийсь пін код, то таких неприємностей можна було б уникнути :slight_smile:
Або кнопка з пін кодом відповідає за якісь важливі критичні налаштування. І мати додатковий захист від змін теж було б не погано.
Чи можливо було б очікувати такий функціонал від віджету кнопки?

Hello everybody!
I would like to have in the future - a button with a PIN code.
I have a main relay at the entrance to the hut. Sometimes my smartphone falls into the hands of a little girl :slight_smile: And it happens that this girl turns off all the electricity in the house.
As if for confirmation was some pin code, such troubles could be avoided :slight_smile:
Or the button with a PIN code is responsible for some critical critical settings. And to have additional protection from changes, too, would not be bad.
Would you expect such a functionality from the button widget?

2 Likes

This is brilliant idea.

Presumably the little girl can’t do anything with your phone as you have it protected with a PIN code, right?

@Costas

Не так. Маленькій дівчинці дозволено ігри та мультики на смартфоні.

Not so. The little girl is allowed to play and cartoons on the smartphone.

Suggest you simply log out of your Blynk account then and this will prevent access to your projects.

A PIN system has been suggested several times before and it would be a useful addition but there are already ways to ensure unauthorised users don’t have access to your Blynk projects.

@Costas все ж таки я наполягаю, що кнопка з пін кодом буде корисним доповненням. Так як, я надаю доступ до проекту членам родини, вмикати і вимикати світло, дивитись температуру і вологість. Але випадково, навіть я, можу натиснути на головне реле і як наслідок знеструмити весь будинок. Увімкнути віддалено я вже не зможу, бо роутер теж живиться від електромережі будинку. Холодильник і обігрів залишиться без живлення на довгий час.

yet I insist that the button with a pin code will be a useful addition. Since, I give family members access to the project, turn on and off the light, watch the temperature and humidity. But by chance, even I, I can click on the main relay and as a result, to exhaust the whole house. I will not be able to turn on remotely, because the router is also powered by the home network. The refrigerator and the heating will be left without power for a long time.

Then you need to build protection into your sketch until such time as a PIN controlled widget becomes available. We use a second confirmation within a short timeout period for critical buttons but equally it could be done with your own pin system.

1 Like

Somewhere in the future…
Until then, you can think of tons of simple ways to restrict access with widgets available at the moment. For example, in one of my projects there are four buttons acting like a pin input. Here is little screen cast: https://www.dropbox.com/s/6i4tdus9wivg75l/IMG_2327.TRIM.MOV?dl=0
Just in case someone finds it useful, here are the code excerpts:

bool alarmAccess;
int alarmMode; // 1 -> ON 2 -> OFF
int alarmState; // 1 -> OPEN 2 -> CLOSED
bool toggle;
int accessCountDown;
String pin = String(11334);
String enteredPin = String();
BlynkTimer timer;
void timerEvent()
{
  updateAccessCountDown();
  updateAlarmState();
  
  if (Blynk.connected()) {
    toggleAlarmLED();
  }
}

void toggleAlarmLED() {
  toggle = !toggle;
  Blynk.virtualWrite(V24, toggle ? 255 : 0);
}

void updateAccessCountDown() {
  
  if (!alarmAccess) {
    return;
  }

  if (accessCountDown > 0) {
    accessCountDown--;
    Blynk.virtualWrite(V25, String("ACCESS GRANTED (") + accessCountDown + ")");
  }
  else {
    updateAlarmAccess(false, false);
  }
}

void updateAlarmAccess(bool newAccess, bool force) {
  
  if (!force && alarmAccess == newAccess) {
    return;
  }
  alarmAccess = newAccess;
  if (alarmAccess) {
    Blynk.setProperty(V21, "color", BLYNK_BLUE);
    Blynk.setProperty(V25, "color", BLYNK_BLUE);
    Blynk.virtualWrite(V25, "ACCESS GRANTED (9)");
    accessCountDown = 10;
  }
  else {
    Blynk.setProperty(V21, "color", BLYNK_GREEN);
    Blynk.setProperty(V25, "color", BLYNK_GREEN);
    Blynk.virtualWrite(V25, " ");
  }
  
  updateStateLabel();
}

void updateStateLabel() {
  
  if (alarmMode == 2) {
    Blynk.setProperty(V22, "color", BLYNK_GREEN);
    Blynk.virtualWrite(V22, "OFF");
  }
  else if (alarmState == 2) {
    Blynk.setProperty(V22, "color", BLYNK_GREEN);
    Blynk.virtualWrite(V22, "ON AND CLOSED");
  }
  else {
    Blynk.setProperty(V22, "color", BLYNK_RED);
    Blynk.virtualWrite(V22, "ON AND OPEN!");
  }
}

void updateEnteredPin() {

  if (pin == enteredPin) {
    enteredPin = String();
    updateAlarmAccess(true, false);
    return;
  }
  else if (enteredPin.length() <= 6) {
    String hiddenPin = enteredPin;
    hiddenPin.replace("1", " * ");
    hiddenPin.replace("2", " * ");
    hiddenPin.replace("3", " * ");
    hiddenPin.replace("4", " * ");
    Blynk.virtualWrite(V25, hiddenPin);
  }
  else {
    enteredPin = String();
    Blynk.virtualWrite(V25, " ");
  }
}

// MENU - ALARM ON/OFF
BLYNK_WRITE(V21) {
  if (!alarmAccess) {
    Blynk.virtualWrite(V21, alarmMode);
    Blynk.virtualWrite(V25, "ACCESS DENIED");
    return;
  }
  
  int newAlarmMode = param.asInt();
  if (alarmMode == newAlarmMode) {
    return;
  }

  alarmMode = newAlarmMode;
  Blynk.virtualWrite(V100, alarmMode);
  updateStateLabel();
}


BLYNK_WRITE(V11) {
  if (!param.asInt()) {
    return;
  }
  enteredPin = enteredPin + String(1);
  updateEnteredPin();
}
BLYNK_WRITE(V12) {
  if (!param.asInt()) {
    return;
  }
  enteredPin = enteredPin + String(2);
  updateEnteredPin();
}
BLYNK_WRITE(V13) {
  if (!param.asInt()) {
    return;
  }
  enteredPin = enteredPin + String(3);
  updateEnteredPin();
}
BLYNK_WRITE(V14) {
  if (!param.asInt()) {
    return;
  }
  enteredPin = enteredPin + String(4);
  updateEnteredPin();
}

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V100);
}

BLYNK_WRITE(V100)
{
  alarmMode = param.asInt() ?: 1; 
  updateAlarmState();
  updateAlarmAccess(false, true);
}


void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, timerEvent);
}

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

i agree with the pin protection too, it is good idea.

until that, you could use the terminal to activate critical events with special commands.

this way, you do not use buttons for sensitive events, rather “secret” commands :wink:

1 Like

@wanek, так, термінал багато в чому може допомогти. В принципі написати свою мову команд і використовувати лише термінал, теж можливо. Та хіба в цьому напрямку розвивається blynk? Початкове повідомлення було не як претензія, а як ідея для майбутніх покращень функціоналу. Мені не терміново. Почекаю коли з’явиться така кнопка з пін кодом :smile:

@wanek, yes, the terminal can help a lot. In principle, write your own command language and use only the terminal, it is also possible. But does blynk develop in this direction? The initial message was not as a claim, but as an idea for future functional improvements. I am not urgent. Waiting for the following button to appear with the pin code :smile:

3 Likes

Very good idea. We need to some mechanism to protect some widgets from our children. It may be useful to protect a fully tab. Or make trimmed desktop for some users.

Terminal or example shown from screencast too difficult and are similar to crutches. My wife (as legitimate user) will never can use it.

What about FingerPrint instead of pin? Typing pin code is very boring. Fingerprint is super easy and secure at same time.

3 Likes

This I can sign. :stuck_out_tongue: :point_up:

My vote would be for a PIN code over fingerprint recognition.

2 Likes

My vote - pin code.

fingerprint is much practical and secure, but most phones does not have fingerprint scanner. yet.

also, the pin code has an advantage that one can easily share with other users.

i would vote for both. fingerprint and pincode. so everyone can use what he prefers

Be honest with us - you just don’t have finger scanners, don’t you :slight_smile: ?

In 2 years every phone will have it.

sure, but we hope that this new feature will be implemented somewhat sooner than 2 years :slight_smile:

2 Likes

Can’t even begin to imagine what a new phone will cost in 2 years.

Luckily my Galaxy S5 has one (fingerprint scanner). I am pretty sure I will still be using it two years from now.

yeah, i have s5 too. they are great phones, if will not break, i will be using for 2 years.