Go Down

Topic: arduino with fingerprint (Read 1 time) previous topic - next topic

mhdkifli

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

PaulS

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.

mhdkifli

#2
Apr 24, 2012, 03:45 pm Last Edit: Apr 24, 2012, 03:52 pm by mhdkifli Reason: 1
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?

PaulS

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().

CrossRoads

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.
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.

mhdkifli

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 ? =(

CrossRoads

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 ...
 }

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.

mhdkifli

Code: [Select]


#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

PaulS

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.

CrossRoads

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?
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.

Go Up