user52874: I'm getting the following error when I try to enroll fingerprints using the Arduino Mega 2560 microcontroller along with a Fingerprint Scanner:

Did not find fingerprint sensor :(

The exact devices I'm using are as shown in the links below:
https://www.gearbest.com/development-boards/pp_70487.html?lkid=11637831
https://www.gearbest.com/boards-shields/pp_009769796663.html?wid=1433363
My circuit connection is:

(Green) TX    =>  Pin 0 [PWM]
(White) RX    =>  Pin 1 [PWM]

//It doesn't respond when connected to 5V, it only heats up

(Red) VCC     =>  3.3v
(Black) GND   =>  GND

The connection is illustrated below:

The code is shown below:
#include <Adafruit_Fingerprint.h>

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
 #define mySerial Serial1

// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// comment these two lines if using hardware serial
//#include <SoftwareSerial.h>
//SoftwareSerial mySerial(10, 11);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

uint8_t id;

void setup()  
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

  // set the data rate for the sensor serial port
  finger.begin(57600);

  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }
}

uint8_t readnumber(void) {
  uint8_t num = 0;

  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

void loop()                     // run over and over again
{
  Serial.println("Ready to enroll a fingerprint!");
  Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
  id = readnumber();
  if (id == 0) {// ID #0 not allowed, try again!
     return;
  }
  Serial.print("Enrolling ID #");
  Serial.println(id);

  while (!  getFingerprintEnroll() );
}

uint8_t getFingerprintEnroll() {

  int p = -1;
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  Serial.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  Serial.print("ID "); Serial.println(id);
  p = -1;
  Serial.println("Place same finger again");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  Serial.print("Creating model for #");  Serial.println(id);

  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    Serial.println("Prints matched!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    Serial.println("Fingerprints did not match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   

  Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    Serial.println("Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
}

I used the Adafruit Fingerprint library found here:
https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library
I also soldered the wires from the sensor onto Male Pin Headers for greater connection stability.
All I get is the fingerprint sensor blinking continuously which makes me think it's not faulty but when I try to run the enroll code I get the error message highlighted above.
I also tried connecting using the Software Serial approach like below but that wasn't the solution either:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);

What could be the problem? Is my connection and code okay? Anyone have an idea on how to fix this?
The heat occurs on the encircled area below:


user52874: Thanks for your responses @HavocRC and @Juraj
I've successfully come to the following working parameters that I have tested and have given positive results:

When using Arduino Mega 2560 with the SFG Demo, we use:
(Green) TX    =>  Pin 1
(White) RX    =>  Pin 0
(Red) VCC     =>  5V
(Black) GND   =>  GND
When using Arduino Mega 2560 with the Adafruit Library, we use:
Using Hardware Serial Port (Serial1) [Recommended]
(Green) TX    =>  Pin 19
(White) RX    =>  Pin 18
(Red) VCC     =>  5V
(Black) GND   =>  GND
//Note that you'll comment out the Software Serial initialization
//as directed by the code in the Adafruit Library
#define mySerial Serial1

When using Arduino Mega 2560 with the Adafruit Library, we use:
Using Software Serial
(Green) TX    =>  Pin 10
(White) RX    =>  Pin 11
(Red) VCC     =>  5V
(Black) GND   =>  GND
//The order of the PINs in the code is 
SoftwareSerial mySerial(10, 11);


In the process of testing I also used an older version of Arduino IDE, version 1.0.5 which may have helped to get the sensor working (just a hunch). It turns out the sensor only works with 5V although it heats up a bit (not to fiery levels at a go but I wouldn't leave it turned on if I was away from my laptop for a while).
By the way, for the SFG Demo to work, upload the 'blank' example first, close Arduino and then run SFG Demo. If it works then your fingerprint scanner is in working order.
For the hardware Serial options you can also use alternative PINs as follows:

Serial2 on pins 17 (RX) and 16 (TX) 
Serial3 on pins 15 (RX) and 14(TX)

Links
http://www.adafruit.com/datasheets/SFGDemoV2.0.rar
https://www.arduino.cc/en/main/OldSoftwareReleases
https://www.arduino.cc/reference/en/language/functions/communication/serial/

52874: <p>I'm getting the following error when I try to enroll fingerprints using the Arduino Mega 2560 microcontroller along with a Fingerprint Scanner:</p>

<blockquote>
  <p>Did not find fingerprint sensor :(</p>
</blockquote>

<p>The exact devices I'm using are as shown in the links below:</p>

<p><a href="https://www.gearbest.com/development-boards/pp_70487.html?lkid=11637831" rel="nofollow noreferrer">https://www.gearbest.com/development-boards/pp_70487.html?lkid=11637831</a>
<a href="https://www.gearbest.com/boards-shields/pp_009769796663.html?wid=1433363" rel="nofollow noreferrer">https://www.gearbest.com/boards-shields/pp_009769796663.html?wid=1433363</a></p>

<p>My circuit connection is:</p>

<ul>
<li><p>(Green) TX    =>  Pin 0 [PWM]</p></li>
<li><p>(White) RX    =>  Pin 1 [PWM]</p></li>
</ul>

<p>//It doesn't respond when connected to 5V, it only heats up</p>

<ul>
<li><p>(Red) VCC     =>  3.3v</p></li>
<li><p>(Black) GND   =>  GND</p></li>
</ul>

<p>The connection is illustrated below:</p>

<p><a href="https://i.stack.imgur.com/fn5wj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fn5wj.png" alt="enter image description here"></a></p>

<p>The code is shown below:</p>

<pre><code>#include &lt;Adafruit_Fingerprint.h&gt;

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
 #define mySerial Serial1

// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// comment these two lines if using hardware serial
//#include &lt;SoftwareSerial.h&gt;
//SoftwareSerial mySerial(10, 11);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&amp;mySerial);

uint8_t id;

void setup()  
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

  // set the data rate for the sensor serial port
  finger.begin(57600);

  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }
}

uint8_t readnumber(void) {
  uint8_t num = 0;

  while (num == 0) {
    while (! Serial.available());
    num = Serial.parseInt();
  }
  return num;
}

void loop()                     // run over and over again
{
  Serial.println("Ready to enroll a fingerprint!");
  Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
  id = readnumber();
  if (id == 0) {// ID #0 not allowed, try again!
     return;
  }
  Serial.print("Enrolling ID #");
  Serial.println(id);

  while (!  getFingerprintEnroll() );
}

uint8_t getFingerprintEnroll() {

  int p = -1;
  Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  Serial.println("Remove finger");
  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }
  Serial.print("ID "); Serial.println(id);
  p = -1;
  Serial.println("Place same finger again");
  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:
      Serial.println("Unknown error");
      break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  Serial.print("Creating model for #");  Serial.println(id);

  p = finger.createModel();
  if (p == FINGERPRINT_OK) {
    Serial.println("Prints matched!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_ENROLLMISMATCH) {
    Serial.println("Fingerprints did not match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   

  Serial.print("ID "); Serial.println(id);
  p = finger.storeModel(id);
  if (p == FINGERPRINT_OK) {
    Serial.println("Stored!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_BADLOCATION) {
    Serial.println("Could not store in that location");
    return p;
  } else if (p == FINGERPRINT_FLASHERR) {
    Serial.println("Error writing to flash");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }   
}
</code></pre>

<p>I used the Adafruit Fingerprint library found here:</p>

<p><a href="https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library" rel="nofollow noreferrer">https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library</a></p>

<p>I also soldered the wires from the sensor onto Male Pin Headers for greater connection stability.</p>

<p>All I get is the fingerprint sensor blinking continuously which makes me think it's not faulty but when I try to run the enroll code I get the error message highlighted above.</p>

<p>I also tried connecting using the Software Serial approach like below but that wasn't the solution either:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(10, 11);
</code></pre>

<p>What could be the problem? Is my connection and code okay? Anyone have an idea on how to fix this?</p>

<p>The heat occurs on the encircled area below:
<a href="https://i.stack.imgur.com/EhdCJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EhdCJ.jpg" alt="enter image description here"></a></p>
 52874: <p>Thanks for your responses @HavocRC and @Juraj</p>

<p>I've successfully come to the following working parameters that I have tested and have given positive results:</p>

<blockquote>
  <p><strong>When using Arduino Mega 2560 with the SFG Demo, we use:</strong></p>
  
  <p>(Green) TX    =>  Pin 1</p>
  
  <p>(White) RX    =>  Pin 0</p>
  
  <p>(Red) VCC     =>  5V</p>
  
  <p>(Black) GND   =>  GND</p>
  
  <p><strong>When using Arduino Mega 2560 with the Adafruit Library, we use:</strong></p>
  
  <p><strong>Using Hardware Serial Port (Serial1) [Recommended]</strong></p>
  
  <p>(Green) TX    =>  Pin 19</p>
  
  <p>(White) RX    =>  Pin 18</p>
  
  <p>(Red) VCC     =>  5V</p>
  
  <p>(Black) GND   =>  GND</p>
  
  <p>//Note that you'll comment out the Software Serial initialization</p>
  
  <p>//as directed by the code in the Adafruit Library</p>

<pre><code>#define mySerial Serial1
</code></pre>
  
  <p><strong>When using Arduino Mega 2560 with the Adafruit Library, we use:</strong></p>
  
  <p><strong>Using Software Serial</strong></p>
  
  <p>(Green) TX    =>  Pin 10</p>
  
  <p>(White) RX    =>  Pin 11</p>
  
  <p>(Red) VCC     =>  5V</p>
  
  <p>(Black) GND   =>  GND</p>
  
  <p>//The order of the PINs in the code is </p>

<pre><code>SoftwareSerial mySerial(10, 11);
</code></pre>
</blockquote>

<p>In the process of testing I also used an older version of Arduino IDE, version 1.0.5 which may have helped to get the sensor working (just a hunch). It turns out the sensor only works with 5V although it heats up a bit (not to fiery levels at a go but I wouldn't leave it turned on if I was away from my laptop for a while).</p>

<p>By the way, for the SFG Demo to work, upload the 'blank' example first, close Arduino and then run SFG Demo. If it works then your fingerprint scanner is in working order.</p>

<p>For the hardware Serial options you can also use alternative PINs as follows:</p>

<blockquote>
  <p><strong>Serial2 on pins 17 (RX) and 16 (TX)</strong> </p>
  
  <p><strong>Serial3 on pins 15 (RX) and 14(TX)</strong></p>
</blockquote>

<p>Links</p>

<p><a href="http://www.adafruit.com/datasheets/SFGDemoV2.0.rar" rel="nofollow noreferrer">http://www.adafruit.com/datasheets/SFGDemoV2.0.rar</a></p>

<p><a href="https://www.arduino.cc/en/main/OldSoftwareReleases" rel="nofollow noreferrer">https://www.arduino.cc/en/main/OldSoftwareReleases</a></p>

<p><a href="https://www.arduino.cc/reference/en/language/functions/communication/serial/" rel="nofollow noreferrer">https://www.arduino.cc/reference/en/language/functions/communication/serial/</a></p>
