Cannot communicate with Grow r503 fingerprint sensor after setting password

I am constructing a fingerprint reader device for opening and closing doors. As the sensor and the NodeMCU controlling it will be placed outside, it needs to be tamper resistant. One of the measures is setting the password for the Grow R503 sensor.

I debugged my code first, so I had a working sensor. Then I added the “new_password” to the code, flashed and then changed the clause to “password”. Now I have lost communication to the sensor.

Serial debug log shows:

[09:41:51][E][fingerprint_grow:410]: Unknown response received from reader: 33
[09:41:51][E][fingerprint_grow:317]: Try led_control instead
[09:41:51][E][fingerprint_grow:410]: Unknown response received from reader: 33
[09:41:51][E][fingerprint_grow:317]: Try led_control instead
[09:41:51][E][fingerprint_grow:410]: Unknown response received from reader: 33
[09:41:51][E][fingerprint_grow:317]: Try led_control instead
[09:41:51][E][fingerprint_grow:198]: Wrong password
[09:41:51][E][component:112]: Component fingerprint_grow was marked as failed.
Serial port closed!

I have defined the password in the secrets file like this:
fingerprint_scanner: "0x01234567"

And then in the code for the NodeMCU first:
new_password: !secret fingerprint_scanner

and then
password: !secret fingerprint_scanner

I can see two possible issues with this:

  1. I shouldn’t have added the quotes around the password
  2. Does the secrets mechanism work with these commands

I tried converting the strings !secret, 0x01234567 and "0x01234567" to Hex and used the start of the result as password, but no luck.

Did I break my sensor, any tips anyone?

I modified the C-source to print the password when checking. The int32 I see in the debug log is the INT value of the HEX value of the value in my secrets file. So something must have gone wrong setting the password. Any ideas? (I debugged before setting the password. At the end of debug I set my logging to WARN, so I didn’t the the actual value set in the logs when setting the password)

Did some debugging in the code to force the setting of the password, it will fail, but at least I get to see what password is set.

The password that is set, is different from the password used for access. And the password changes when I change something random in the Yaml file….

This doesn’t look good. Someone got any advice?

OK, I got it back. Eventually I rolled back to the exact YAML I had when setting the password and changed the source of fingerprint_grow.cpp to and set the password when checking the mail password failed (by adding a ! to the relevant if clause) and changed a log message to output on WARN.

This gave me yet a new password (probably a pointer address instead of the password), which I then tried. To my joy this did work. I guess I should make a bug report out of this.

See Setting the password for a Grow fingerprint sensor bricks the sensor · Issue #3387 · esphome/issues · GitHub for the bug report.