Offline
Newbie
Karma: 0
Posts: 14
|
 |
« on: April 23, 2012, 10:46:24 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #1 on: April 23, 2012, 10:51:25 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #2 on: April 24, 2012, 08:45:18 am » |
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
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #3 on: April 24, 2012, 09:10:19 am » |
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
Brattain Member
Karma: 269
Posts: 17032
Available for Design & Build services
|
 |
« Reply #4 on: April 24, 2012, 09:21:11 am » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #5 on: April 24, 2012, 07:35:32 pm » |
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 ? 
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 269
Posts: 17032
Available for Design & Build services
|
 |
« Reply #6 on: April 24, 2012, 10:28:11 pm » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 14
|
 |
« Reply #7 on: April 25, 2012, 03:20:29 am » |
#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
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #8 on: April 25, 2012, 06:49:36 am » |
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
Brattain Member
Karma: 269
Posts: 17032
Available for Design & Build services
|
 |
« Reply #9 on: April 25, 2012, 05:36:55 pm » |
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
|
|
|
|
|
|