Need help connecting Fingerprint Scanner - TTL (GT-511C3) over UART Serial Comms #4627
Replies: 1 comment
-
Posted at 2017-09-22 by @allObjects First the hardware: Your connectivity is just fine with any Espruino board: Espruino talks and listens 3.3V and so does the Finger Print reader. Just make sure you connect the Finger Print Reader Ground to Espruino Ground and then the Finger Print reader power to 3.3 Volt or 5 Volt. I assume you run your Espruino for the beginning on USB as connected to the Espruino Web IDE on your computer. Now that we have done the hardware, we look at the initialization of the serial on Espruino. There is not much to say other than selecting the pins, the baud rate - which is 9600 (default of the finger print reader), and the format. I assume the format is just plain 8 bit with 1 stop and 1 start bit and no parity bit. To write to the device it is simple:
To read from the device, it is a bit more tricky - or better said - elaborate, and for sure different as you may have learned from other environments, such as Arduino. Let me fill you in with a bit background about Espruino. A major goal of Espruino's creator - @gfwilliams Williams - was: tiny, power frugal, easy to use / program micro controller setup. The easy part for programming is for one part JavaScript and for the other - painful - part, handle all the low level hardware stuff under the hood so that you have to act only when something happened that needs your attention - *** without you constantly checking, also called polling - in a program loop (as in Arduino) - every possible thing for which something may have happen ***. In Espruino, everything is Event Driven including your application. So you will never find a command like wait() or delay() or alike. In your case, when the finger print reader sends you - your application code - data, Espruino does it's magic and notifies you - your application code - with the data it received. In order that Espruino can notify - call - you, you have to 'leave your callback number' when you 'install' the communication. And this goes with a piece of code like this:
This tells the serial appliance built into Espruino, that on data reception it should call your function with the received data as parameter value. The (anonymous) function in above example prints the data in the console. That is all there is! ...no kidding... or just a little bit. Being very familiar with JavaScript, you will say "Sure, I can take it from here". Not so familiar, you may ask about some more details... Take a look at Espruino USART. But before going into more programming, lets play a bit and see some action. Reading through AD-TECH GT-511C3 datasheet V2.1, we can quickly see wether the connectivity is up.
For every command sent you get something back: some crazy characters but also a "U" - (0x55) and "0" (0x30). So much for now. Posted at 2017-09-22 by user81574 Thanks, really appreciated. the commands resulted on this response, which I believe is a proper acknowledgement. Finally, how do I display/get data packet in a readable format, like the serial_number and firmware_number in devinfo data packet which is returned by the open command Posted at 2017-09-22 by @allObjects Great! It worked. It is quite an adventure to aim without having things at hand. Something I missed is that you have an Espruino-Wifi (by the way: an excellent choice). But you managed to translate (to the same pins and 5V to VUSB). From now on I know. So let's get started with building up some infrastructure / module that we then want to use this way
And this is some 'get going code' you paste into the right hand pane - the editor - and upload to the board. The last line is there only for development time (EDIT: code fixed based on post #8, thanks @user81574).
This is nowhere near basic... but it is basics... (showing how to implement commands). When uploaded, it should print stuff - including the firmwareVersion, isoAreaMaxSize and device serialNumber in the console. I'm sure you can take it from here and add the .led(on, cb) (w/ on truy/falsy for on and off) and play around. To handle the response, it gets a little bit more tricky, since a response block has to be detected, analyzed, and the application callback be called. In other words the application passed in callback has to be feed then in a promise (fullfilled) based on response block becoming available event. In addition to the 'callback hell' that can be managed with promises - nicely available in Espruino - you have also to deal with timeout, since a response block may not show (corrtectly / completely) within (variably) expected time... The timeout would then have to kill the promise(s) in work. You may for sure take a look at the node.js implementation for guidance - or even more. Just be aware that you deal with less resources than you have in a regular node.js environment. PS: since I do not have a device - and not time to write an emulator for it (I anyway ran out of time already) - this code is not run-tested... so please provide me with feedback (...tested code). Posted at 2017-09-22 by user81574 Thanks! this is already a perfect start (considering I was running round the web and library codes/documentation and datasheets with close to nothing). I'll start extending and run-testing ASAP. Posted at 2017-09-22 by PaddeK I started a while ago a module for this but never got to the finishing touches. I attached the code as is.. let me know if you need help to make sense of the mess :) Attachments: Posted at 2017-09-22 by @allObjects ...oh these late nights, early early mornings lend many hands for a nice tee and coffee and nasty spills there of... But foremost: @PaddeK, thanks for sharing! Looked through the code and - even though not the way I'm used to - I like it and learned a lot from it... including a bug: I treated the checksum as 8 bit instead of 16... ouch. Using a buffer and put 8 and 16 bit views over it is a cool thing... One could even use a clipping one that makes the &0xFF obsolete... @PaddeK, do you have some usage information? From your comment and code I assume you got pretty far with implementing. Yes, images is not the coolest to do... If you would have some SRAM / FRAM / MRAM (able up to 40 MHz clock rate - enough to keep up with measly serial 9600, even with byte-wise addressing versus self-incrementing address) and stream response into those, on serial data receipt and process it form there... Regular information as blocks, and images streamed. Serial (flash) EPROM would work as well used as a Ring buffer, fast enough, cheap, and barely wearing down with the amount of data when going for a large one... The EPROM could then also be used as the 'local Database' in addition to communicating it over Wifi to a networked server (that's what I guess @user81574 has eventually in mind... ( Btw, do you know the size of a so-called profile? Because that is what I guess has to work as minimum to be really useful). @user81574, I would give it a try with @PaddeK's code when given some usage samples. Posted at 2017-09-22 by user81574 So, run-tested the unedited code on the Espruino-Wifi, Uncaught ReferenceError: "id" is not defined it turns out that the tenary expression ?: didn't work so I passed the Id directly main issue:
also, Line 21 and Line 34 has this.open as property and this.open as method respectively.
with printed on console[ 85, 170, 1, 0, 1, 0, 0, 0, 1 ] (was that an error or not?) Posted at 2017-09-22 by user81574 Awesome one @PaddeK! Still going through your code. Posted at 2017-09-22 by PaddeK I cant really test it.. but i looked a bit at the index.js and saw i was testing a function for complete enrollment. A few minor changes i think and you should get it to work. Try this as a replacement for the index.js
The enrollment function itself shows a lot of the usage i had in mind. Btw. pretty much all of the code is based on the documents i found here: --- Edit --- Posted at 2017-09-22 by @allObjects
Posted at 2017-09-22 by PaddeK I was glad too.. i had not much experience with promises at that time but this was my chance to get my feet wet so to speak :) Posted at 2017-09-23 by @allObjects @user81574, I suggest you move on with PaddeK's code. Again, thanks @PaddeK for sharing. It does not need much to get it to completion for enroll and the other functions you would like to have at your (coding-)finger-tips. (Sticking on my path would over several serious transformation steps - such as adding the parser and promise - lead to a solution too... but I like to use invented wheels... in favor of saving the - non-recoverable - resource called Time for getting after the not yet invented ones...). For example, for the enroll function, just add the application callback into the method signature (line 11):
and use it (in lines 21 and 22):
If you want to have your callback execution to happen in its own Espruino JavaScript single-thread 'task', pack the callback invocation in
This will allow other pending - and may be more pressing - 'tasks' to get a chance to do their thing. Applied throughout the whole application makes your application behave like a TSO - (processor) time sharing option - environment for each of the tasks, where you run less into timely-ness contentions (buffer overflow, stacking up to many and/or 'losing' events,...) - from the single core /360 times... For adding more to the module, such as getting the extra information on open, add a method To make operations very robust, always begin with an Putting all in one single module is no difficult either. Just add the code into the first piece of code from @PaddeK. This conversation was great pleasure for me and makes me conclude: Old dog, new tricks? ...still works. Posted at 2017-09-23 by user81574 Big thanks to you guys @PaddeK and @allObjects. I highly appreciate your efforts! Posted at 2017-09-26 by user81574 Hello @PaddeK @allObjects, am having difficulties using the getTemplate() function. It always timesout whenever I call it. Posted at 2017-09-26 by @allObjects ...you mean raw image... 5.22 in .pdf doc? - Is that not what @PaddeK said he struggled with? It is about 20KB and I assume there is a buffer overflow or something else that is going on that it times out. It times out because it does never reach the condition of done... (done receiving the 4 + 19200 + 2 bytes (payload plus the extra 6 bytes for admin). Lookup the flags for buffer overflow when the timeout hits... If you want to fix that, you may need to pre-declare a new, fast, contiguous buffer and place the received data into that buffer rather than do string concatenation and/or reducing the baud rate (for just that particular function). I would see that a only possible solution, if there is a solution at all for this. I'm not sure if you can build a compile function to handle that (see "compiled" for making things faster). Posted at 2017-09-26 by PaddeK The template is just a few bytes.. around 500. This should be no problem.. i guess it is a bug in my code. I am sure it worked at some point but i did some refactoring after that. I ordered a new Posted at 2017-09-26 by user81574 Please do hide that tee :D Posted at 2017-09-26 by PaddeK I will give it a try a soon my new fingerprint sensor arrives. But i guess this will take a week or two. Why do you want to store the template in the first place? The C1 can hold up to 20 templates and the C3 even 200. Posted at 2017-09-26 by user81574 I need a way to store it to an external database because fingerprints data (template) might exceed over 200 and I also need it to make verification remotely. Am assuming the whole image file is converted to a template data. I just need a way to access and extract that data. Posted at 2017-09-26 by user81574 could you please paste a code that should retrieve a given template let me run, maybe my code was bad and didnt implement it way I should;
I also tried this code below, and got a timeout exceeded
Posted at 2017-09-26 by PaddeK Something like this should do the trick.
This example should return you the template in the first slot (slot: 0). Posted at 2017-09-26 by user81574 thats all I get:
I even increased the C.TIMEOUT.RECIEVE_DATA to 7s, yet it still times out Posted at 2017-09-26 by PaddeK If you are sure you previously enrolled a fingerprint into the same slot you try to get the template from then i guess there is a bug. My new sensor is already shipped.. so it should arrive in a few days. Posted at 2017-09-26 by @allObjects @user81574, did you check E.getErrorFlags()? Posted at 2017-09-26 by user81574 No I didn't . I'll check but it just times out. Though the verify function returns some error codes like 4114 which is expected to an extent. I'll just wait for @PaddeK fingerprint to arrive (hopefully soon) so he could test-run too Posted at 2017-09-28 by PaddeK Quick update.. according to the shipment tracking my GT-511C1 is expected to arrive tomorrow. Posted at 2017-09-28 by user81574 Awesome!!! Posted at 2017-09-29 by user81574 @PaddeK have you received the GT-511C1?? Posted at 2017-09-29 by PaddeK jep i am working on the code right now Posted at 2017-09-29 by PaddeK Okay.. i think it works now. I uploaded the module on my github so its easy to share.
And i guess i found a bug in espruino somewhere.. while converting the template back to a Uint8Array i have to remove a trailing zero.. which i have no clue why it is there in the first place. Posted at 2017-09-30 by user81574 Hello @PaddeK, thanks for taking your time to try and sort somethings out.
I have tried several alternatives in calling the getTemplate function, yet it still times out. Also calling the enroll(t) function results in this error:
after setting enroll with enroll = (t) => () => g.enroll(t); and passed it into the GT511.sequence array I got this error
Posted at 2017-09-30 by PaddeK My example was to get the template of slot 0. So you need to have previously enrolled a fingerprint to slot 0. You can check how many templates are stored with getEnrollCount() I will try to make a more complete example later today. Posted at 2017-09-30 by user81574 getEnrollCount works as expected but checkEnrolled returns a 4111 error. looking at the datasheet thats 0x100F which is a NACK_DEV_ERR (device error especially if crypto chip is trouble) I hope this doesn't mean my GT511 has spoilt. Posted at 2017-09-30 by PaddeK You could try to delete all templates and reenroll your finger. I never had a 4111 error so i have no clue what it means or when it happens. Posted at 2017-09-30 by user81574 Hi @PaddeK, were you able to write some complete examples? Posted at 2017-10-01 by PaddeK No something came up and i had to put it on hold. Posted at 2017-10-01 by user81574 Thanks @PaddeK for all your assist...finally its working all thanks to your efforts, one which involved to change minification in WebIDE settings from Esprima to Closure (online) - Simple Minification. @allObjects my appreciation goes to you too. Posted at 2017-10-02 by @allObjects fyi: ...this avaScript for Microcontrollers and IoT (Part 4): Espruino and the ESP8266 just flickered over my screen... and it uses the ZFM-20 Series Posted at 2017-10-02 by PaddeK Well after a a long private message session user81574 and i figured it out and the GT511-xx series should work. Of course i had a few bugs in my code but at the end it was the minification with Esprima that roadblocked us. But i guess at least in part thats my fault too.. poor esprima cant make sense of my mess i think. Next i want to try do display the captured images of the sensor on a eink display i have for a while now. I never used it so far.. so first step would be to get the display going and then see how i.. preferably stream.. images from the fingerprint scanner to it. Posted at 2017-10-02 by @allObjects @PaddeK and @user81574, do you plan to share your final finger print reader code? I think e-ink is a good application for displaying figer printes... after all, it is line graphics... (and not shades). Resolution though may be a challenge depending on the resolution of the e-ink display (you 'afforded'). Posted at 2017-10-02 by PaddeK The code is on my github repo here. Posted at 2017-10-02 by user81574 hi guys, so I was looking at the template data and am deducing (maybe wrong) that each fingerprint pattern (lets say index finger) will return different template data independent of how many times it was enrolled (3 times enrollment). So I would like to know how the scanner identifies and verifies a user print. P.S what I want to try and do is run identification and verification not on the inbuilt template database but on a template itself. Posted at 2017-10-02 by @allObjects I m not an expert in the matter, nor do I know the algorithms. But the triple take and some calculation makes sense to me... for different reasons: first, enrollment has to show 3 times 'the same' - the same with 'tolerable variation'. Second, when validating, the template with variation is used to detect 'identity'. The triple take allows to calculate a mean and some deviation to be stored in a 'verification matrix' which then is used on identity check. You can give it a shot by messing with the enrollment... I'm pretty sure, if you do not use the same finger for all tree takes, enrollment will show error. But it would be interesting to see how much 'has to be the same' or 'present' over all 3 takes to make it still a successful enrollment, and at the reverse: how much can be different - not just 'absent'. The same is for checking identity: how much can be absent, how much can be different... When this technology was introduced at the US borders, we - my wife and I - entered in some northern station middle in the winter. For me the readers worked perfect... for my wife not at all... with winter dry and 'cold' hands/fingers, the reader 'failed' completely... not even warming up with under warm water did help. In the end they let us pass without being able identify by finger print reader... It is know that some refugees burn / mutilate their skin to make finger print identification fail... for different reasons... Posted at 2017-10-02 by PaddeK In each step of the enrollment the template gets refined so to speak.. after the 3 captures at enrollment you get one template. At verify/identify the finger is captured once, some kind of match rating is calculated and then matched (match rating > some threshold) You can fill the sensor DB with your stored templates and use identify.. or if you know which template should match just validate against a single template. Look at the datasheets i linked. The functions are Verify/Identify/VerifyTemplate/IdentifyTemplate -- Edit -- Posted at 2017-10-02 by user81574 I have played with the identify/verify, makes sense what you guys said. My concern now is, it limits me to doing identification and verification within the GT-511C3, which was how it was designed. Posted at 2017-10-02 by PaddeK I think both are not feasible. Your best bet would be to upload templates to DB check against it and repeat until you found the right one. But this could take quite a while.. so this might not be feasible too. -- Edit -- -- Edit 2 -- Even better GT-521F52. Posted at 2017-10-02 by user81574 GT-521F52 is a beast on a fingerprin (; Posted at 2017-10-02 by PaddeK Checking the datasheet for it right as we "speak". Posted at 2017-10-02 by user81574 just came across this Fim50 series Posted at 2017-10-03 by user81574 Just learnt that the GT511C3 uses the SmackFinger 3.0 Algorithm for identification. @PaddeK any other info on the GT-521F52 shared database on a network? Posted at 2017-10-03 by PaddeK I did not find anything about that in the datasheets. But it acts as an usb drive so there are sure ways to do this. I ordered one because i am very interested in the touch wake up feature. About the algorithm.. i dont think this will help. The matching of a fingerprint is not like simple string matching. You cant just let the fingerprint generate a template and then search for a match in a database. There is all kinds of magic and fairy dust involved :) Posted at 2017-10-05 by PaddeK My GT-521F52 arrived today.. i hope i can find some time this weekend to test it. Posted at 2018-04-13 by user88797 can I know which are the 12 bytes you send to sensor for EnrollStart() and also for Enrollchecked(). Posted at 2018-04-13 by user88797 Can You please help by giving me answer of which are the commands goes to sensor for 12 bytes to startEnroll() and CheckedEnroll Posted at 2018-04-13 by user88797 int i = 0;
can you please send command of 12 bytes for enrollstart and enrollechecked Posted at 2018-04-16 by @gfwilliams It looks like you're posting C code, not JS. Did you want this converted to run on Espruino, or are you actually using an Arduino? If so, you'd need to find an Arduino forum to post on. Posted at 2018-04-16 by user88797 I am using C# code and I want to start enroll part of FPS_GT511C1R using C# language. Posted at 2018-04-16 by user88797 Can u please help Posted at 2018-04-16 by @gfwilliams I'm afraid we can't help - this is a forum for Espruino, which is JavaScript. I'd suggest that you contact the company you purchased it from. For instance Sparkfun sells those sensors and has a forum. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-09-22 by user81574
Hello, this is my first usage of the Espruino Wifi board.
I'm having trouble connecting/reading data from Fingerprint Scanner - TTL (GT-511C3).
I have already connected RX-TX, TX-RX pins from FPS to board, but am confused how to read/write data using the Serial class.
I know there is a Nodejs library https://github.com/the-AjK/GT-511C3/blob/master/lib/gt511c3.js for it but I dont know how to use it with the Serial class.
Please any help or comment will be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions