I'm trying to test my fingerprint sensor, it shows up on the terminal too, but when I run this code this error shows up:
Traceback (most recent call last):
File "<string>", line 9, in <module>
AttributeError: module 'adafruit_fingerprint' has no attribute 'Adafruit_Fingerprint'
And the library has already been installed using pip, I checked the adafruit official code also does not work, same error.
The code:
import time
import serial
import adafruit_fingerprint
# Open serial port
uart = serial.Serial("/dev/ttyS0", baudrate=57600, timeout=1)
# Initialize fingerprint sensor
finger = adafruit_fingerprint.Adafruit_Fingerprint(uart)
def get_fingerprint():
"""Get a finger print image, template it, and see if it matches!"""
print("Waiting for image...")
while finger.get_image() != adafruit_fingerprint.OK:
pass
print("Templating...")
if finger.image_2_tz(1) != adafruit_fingerprint.OK:
return False
print("Searching...")
if finger.finger_search() != adafruit_fingerprint.OK:
return False
return True
# Test the function
while True:
if get_fingerprint():
print("Fingerprint found!")
else:
print("Fingerprint not found.")
time.sleep(1)
Expected the code to work.
A quick look at the documentation shows that the class is named AdafruitFingerprint, without an underscore