Pages: [1]   Go Down
Author Topic: arduino with fingerprint  (Read 1170 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hai. I kifli from Indonesia
I connect the microcontroller with a fingerprint cama-sm20
datasheet
Check connection to the microcontroller needs to send data to a fingerprint xx55 xx50 xx01 xx00 xx00 xxAA xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx50 xx01.
fingerprint will send a response xx55 xx50 xx01 xx04 xxAA xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx00 xx54 xx01

how to send commands from the microcontroller to the fingerprint.
please help
sorry if my english is not good

* CAMA SM Series Manual new.pdf (846.98 KB - downloaded 28 times.)
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50912
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I connect the microcontroller with a fingerprint cama-sm20
How did you connect the fingerprint scanner to the Arduino?

Quote
the microcontroller needs to send data
Use Serial.write() to send an array.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I connect the serial
I make the program as follows:


#include <NewSoftSerial.h>
byte query[24] = {
  0x55, 0xAA, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01};

#define rxPin 2
#define txPin 3

NewSoftSerial fingerprint( rxPin, txPin );

void setup() {
  Serial.begin(115200);
  fingerprint.begin(9600);
}

byte val;
int i ;
void loop() {
  for (i=0 ; i<24 ; i++){
    fingerprint.print(query) ;
  }
  delay(50);
  while(fingerprint.available()>0){
    val=fingerprint.read();
    Serial.print(val, HEX);
    Serial.print(" ");
  }
  delay(1000);
  Serial.println("--");
}

but the fingerprint does not give any reply.
whether serial.print serial.write replaced with?
« Last Edit: April 24, 2012, 08:52:49 am by mhdkifli » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50912
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The print() and write() methods do very different things. The write() methods send the data as-is. The print method converts the value to a string to send.

It's not surprising that print()ing to it does not work.

You MUST use write().
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is not quite right:

  for (i=0 ; i<24 ; i++){
    fingerprint.print(query) ;
  }

needs to be:

 fingerprint.print(query [ i ] ) ;

to call out the different bytes. Otherwise I think you only send out query[0] 24 times.
You could loop pins 2/3 back to 0/1 & confirm.

I have not used NewSoftSerial, maybe
 
fingerprint.write (query [ i ] ) ;

is the correct format also.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have replaced

for (i=0 ; i<24 ; i++){
    fingerprint.print(query) ;
  }

with

for (i=0 ; i<24 ; i++){
    fingerprint.print(query,BYTE) ;
  }

fingerprint does not respond

with
for (i=0 ; i<24 ; i++){
    fingerprint.write(query) ;
  }

fingerprint does not respond

why ? smiley-cry
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, one last time:

for (i=0 ; i<24 ; i++){
    fingerprint.write ( query [ i ] ) ;  // query [ x ] is what pulls up the 0x55, 0xAA, etc as 'i' goes from 0,1,2,3 ...
  }

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

#include <NewSoftSerial.h>
byte query[24] = {
  0x55, 0xAA, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x01};

#define rxPin 2
#define txPin 3

NewSoftSerial fingerprint( rxPin, txPin );

void setup() {
  Serial.begin(115200);
  fingerprint.begin(9600);
}

byte val;
int i ;
void loop() {
  for (i=0 ; i<24 ; i++){
    fingerprint.write(query[i]) ;
  }
 
  while(fingerprint.available()>0){
    val=fingerprint.read();
    Serial.print(val, HEX);
    Serial.print(" ");
  }
  delay(1000);
  Serial.println("--");
}


fingerprint does not respond
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50912
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

According to the user manual, the baud rate is 115200, not 9600.

You should, initially, send the command in setup(). All loop() does is print any response received.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Will NewSoftSerial do 115,200? That's fast for software controlled read & writes.

The part needs 3.3V and uses 3.3V interface. Are you running the arduino at 3.3V, or do you have a voltage translator chip?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: