arduino with fingerprint

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 (847 KB)

I connect the microcontroller with a fingerprint cama-sm20

How did you connect the fingerprint scanner to the Arduino?

the microcontroller needs to send data

Use Serial.write() to send an array.

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?

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

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.

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

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

#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

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.

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?