brianrho / FPM

Arduino library for the R30x/ZFMxx/FPMxx optical fingerprint sensors
103 stars 41 forks source link

Change the LED Color or turn it off #4

Closed Omega236 closed 6 years ago

Omega236 commented 6 years ago

Hello, i see pictures where the LED is Red, my FPM is green.

is it possible to change the color? so if it read a finger it switch to red or turn off the LED?

brianrho commented 6 years ago

Your module is a ZFM60? There are 6 wires in total coming out of the module, right?

On Dec 18, 2017 09:50, "Omega236" notifications@github.com wrote:

Hello, i see pictures where the LED is Red, my FPM is green.

is it possible to change the color? so if it read a finger it switch to red or turn off the LED?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/brianrho/FPM/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ANjKtccFRYLa-MY1xFxhk6sr57EZBWp6ks5tBic9gaJpZM4RFJL3 .

Omega236 commented 6 years ago

oh sorry, it is a FPM10A from Aliexpress.

But yes it has 6 wires

edit:maybe it's a zfm60, but I bought a fpm10a

brianrho commented 6 years ago

Okay I suspect it has the same interface as a ZFM60 anyways. So the LED colour is fixed in all modules actually, at least as far as I know. Theres a way to turn on/off the LED though. But the LED must be on for enrollment/matching since its what illuminates the finger to be scanned (hence the name, optical scanner). So if you turn off the LED with a command, you must ensure you have some other way to know when a finger is placed or about to be placed (a keypad or RFID card input, for instance), so that you can then turn on the LED to begin scanning else fingers wont be recognized or matched correctly.

On Dec 18, 2017 10:26, "Omega236" notifications@github.com wrote:

oh sorry, it is a FPM10A from Aliexpress.

But yes it has 6 wires

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brianrho/FPM/issues/4#issuecomment-352370929, or mute the thread https://github.com/notifications/unsubscribe-auth/ANjKtb7wyOqNdmFsQcyRkdkJX_jPUj0nks5tBi-9gaJpZM4RFJL3 .

Omega236 commented 6 years ago

Ok this is what i want. How do i turn off/on the led?

brianrho commented 6 years ago

I've added 3 new methods: led_on(), led_off() and getImageNL(). The last method does the same job as the old getImage() except this one does not control the LED at all; it's left to you to turn on/off the LED as needed. You can try them out with the enrollNL example, which I haven't tested yet.

On Dec 18, 2017 14:03, "Omega236" notifications@github.com wrote:

Ok this is what i want. How do i turn off/on the led?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brianrho/FPM/issues/4#issuecomment-352419725, or mute the thread https://github.com/notifications/unsubscribe-auth/ANjKtfgGZcujXGAhA4AThgK2zFvJ2tU1ks5tBmKsgaJpZM4RFJL3 .

Omega236 commented 6 years ago

Unfortunately, led_off () does not work. The LED remains active.

On the Board is DY50_MAIN_V3 and it has 6 red wires like in this PDF https://cdn-learn.adafruit.com/downloads/pdf/adafruit-optical-fingerprint-sensor.pdf

brianrho commented 6 years ago

Then it means it doesn't work for your module. I've only tested it successfully on a ZFM60 (actually found the commands in its datasheet). I tried it today on my second module which is an FPM10A and neither led_on(), led_off() nor getImageNL() worked. Recognized commands depend on the device firmware so if you want to control the LED, it's best you buy a ZFM60.

edautz commented 5 years ago

Great library. Good job.

Today I tested a FPM10A module marked with DY50-2V1 on the circuit board. It has also two extra touch pins called T-out and T-3,3V. The LED control functions worked out of the box using the led commands. The LED Control and touch control are easely integrated in the example code and usefull to trigger the sensor readout. Did a test with the enroll function and the search database function and encounterred no issues with Serial monitor.

I used an NodeMcu 1.0 ESP8266 with board version 2.4.2 and IDE 1.6.13

I will do some more testing with the other functions mentioned in the example code. After that I going to develop by using WiFi, ESPWebserver and websockets, an webinterface to create a browser based menu to use this sensor as a part of my alarm subsystem of my domotic system.

edautz commented 5 years ago

Tested other functions like delete and empty database, workes fine, sometimes a time-out, could be caused by softserial library.

Did a quick test on a ESP32 devkit-V1. First test with enroll, match, delete database, count fingerprints etc, looked good. Touch and ledcontrol working fine.

brianrho commented 5 years ago

Great. Maybe you can also test the image download to RAM on the ESP32, should have the needed 37k I think. How often do you get the timeouts and for which commands? Do you have debugging enabled when they happen?

edautz commented 5 years ago

Ok. What do you mean with “test the image download to RAM”, like the finger.loadModel(fid, 2); function like in the match_pair.ino example?

The tests on the ESP8266 was only a test to check if this library works on my purchased fingerprint sensor. I didn’t turn debugging on, because I suspect the softserial library cannot chatch up all the time when using the highest baudrate. I had to use it because of the lack of two hardware serials on the Esp8266 when testing your examples modified with the touch en the led functions.

On the ESP32 I used two hardware serials. I Will do some more testing before moving on with my project.

brianrho commented 5 years ago

Yes, high baud rates will also cause timeouts, has to do with the nature of timing with SoftwareSerial, compared to Serial. Regarding the image download, I was referring to the image_to_pc example. It can be modified to write the entire image to a buffer in RAM rather than to the Serial port.

edautz commented 5 years ago

OK. I see what you mean.

I think from the example the function: void stream_image(void) has te be altered or replaced to do the image download to RAM.

Frankly I don't have any experience to program such an task. If you provide a code example, I can test it out in my ESP32 setup.

brianrho commented 5 years ago

Okay, try this out when you can: https://pastebin.com/YXDgEhdV. If it works, it should take about 6 secs to read in the entire 37k image into the buffer (at 57600 baud) and then print the total size read

edautz commented 5 years ago

Very good. I will try this code soon. I noticed on the ESP32 also random time-outs. Mostly when I am using the sensor to verify a print. After that I am not able to communicatie with the sensor anymore and have to reset it. I am going to enable debug and try to catch an error. But it is hard to reproduce. The sensor operates on the default baudrate of 57600 bps 8N1. Does it matter to lower it to 38400 bps or even lower?

I power the sensor through the 3,3V pin of the ESP module. Could it be that pin doesn’t supply enough power?

brianrho commented 5 years ago

My FPM10 needs 5V, is yours labelled 3.3V? Debugging will probably hide the issue, the way its written at the moment. Send a screenshot of what you see when the timeouts occur, probably best to create a new issue

edautz commented 5 years ago

Here are results of the image download test:

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1100 load:0x40078000,len:10088 load:0x40080400,len:6380 entry 0x400806a4 SEND IMAGE TO PC test Found fingerprint sensor! Capacity: 150 Packet length: 128 Packet length set to 128 bytes Waiting for a finger... Image taken Starting image stream... Timestamp: 4719

Timestamp: 12444 36864 bytes read. Image stream complete.

Took about 7,7 seconds

If I can do some more testing let me know. Today no timeouts .........

brianrho commented 5 years ago

Okay then, good to know the image download to a buffer works. If you get any timeouts in future, create a new issue and provide screenshots of the serial output.

brianrho commented 5 years ago

Also make sure that your sensor really works with 3.3V and not 5V.

edautz commented 5 years ago

It is a 3,3V for shure. It is printed on the PCB. One of the connection is labeled 3V3 and the touch power connection is labeled T-3V3.

On this moment I am embedding this sensor in my code, so I can use WiFi and a webinterface to enroll and delete the prints. I use a remote debug library, so I don’t need the second serialport for debugging and can do a WiFi based debug at any place.

Together with a OLED display and a 4 digit touchpad, I wil integrate this in my alarm system.

I have to do a lot of more testing to get a stable system.

I noticed that the example codes contains yield statement, but these don’t prevents watchdog time-outs in a ESP32. I replaced them with delay(1), that proves for now preventing the watchdog time-outs.

When the time-out errors persist I going to add a mosfet to my setup, so I can switch the power for the fingerprint sensor to hardware reset is.

Do you know a way to software reset the fingerprint sensor? That would be a simpeler solution.

brianrho commented 5 years ago

Wait, I thought the timeouts you spoke of were for the FPM commands. You mean, the ESP32 itself restarts from a watchdog reset?

edautz commented 5 years ago

Both situations have occurred. When I used only code based on Serial communication, some time-outs occurs in the Serial communication to the fingerprint sensor.

After bringing the WiFi code and a webserver live, watchdog errors start to occur, causing by while loops and yield combinations. Solved this to replace the yields by a delay(1).

brianrho commented 5 years ago

The ESP32 generally isnt vulnerable to WDT resets like the ESP8266, a separate core is used for WiFi tasks, it doesnt need those yield() statements, so I was surprised when you said it timed out because of the WDT.

But if it works now, thats fine then

kennethallag commented 5 years ago

hello, how to use the ledOn(), ledOff()... I'm using the ZFM040_V1.6 fingerprint sensor. I want to know how to control the led. I'm only a newbie. thanks I just need to prove if I can turn off the Led or not.

brianrho commented 5 years ago

Try the enroll_with_led_control example. If it raises errors and doesn't work for you, then your sensor doesn't support those commands. So far, the commands have only worked with the ZFM60 and DY50 sensors though.

kennethallag commented 5 years ago

Where can I find these "enroll_with_led_control" example?? can you give me the link? Thanks How to download the library

brianrho commented 5 years ago

It's in the examples folder.

kennethallag commented 5 years ago

Got it. Thanks. It works on my ZFMO40_V1.6 fingerprint sensor.