title: esp8266 does not communicate with fingerprint sensor R305
body: <p>hello my problem is that when i connect my fingerprint sensor with my esp8266 it does not work!
  i am using the adafruit fingerprint sensor R305 and an esp module esp8266 cp2102.
  i have connect the vcc pin to the 3.3v pin and the ground pin to the groung ,then i connect the rx to the rx pin and tx to tx pin.
  i use the adafruit sensor library but it does do any thing when i connect the fingerprint.
  i am planning to create a simple fingerprint attendance system with these 2 components and i created a data base with the IFTTT app.there is the code .</p>
  
  <pre><code>#include &lt;BearSSLHelpers.h&gt;
  #include &lt;CertStoreBearSSL.h&gt;
  #include &lt;ESP8266WiFi.h&gt;
  #include &lt;ESP8266WiFiAP.h&gt;
  #include &lt;ESP8266WiFiGeneric.h&gt;
  #include &lt;ESP8266WiFiMulti.h&gt;
  #include &lt;ESP8266WiFiScan.h&gt;
  #include &lt;ESP8266WiFiSTA.h&gt;
  #include &lt;ESP8266WiFiType.h&gt;
  #include &lt;WiFiClient.h&gt;
  #include &lt;WiFiClientSecure.h&gt;
  #include &lt;WiFiClientSecureAxTLS.h&gt;
  #include &lt;WiFiClientSecureBearSSL.h&gt;
  #include &lt;WiFiServer.h&gt;
  #include &lt;WiFiServerSecure.h&gt;
  #include &lt;WiFiServerSecureAxTLS.h&gt;
  #include &lt;WiFiServerSecureBearSSL.h&gt;
  #include &lt;WiFiUdp.h&gt;
  
  
  
  #include &lt;SoftwareSerial.h&gt;
  
  #include &lt;Adafruit_Fingerprint.h&gt;
  
  #define rxPin 2
  #define txPin 3
  
  const char* NAME; // the name will be gievn in the code for each ID saved
  const char* ID; // the ID that are save into the fingerprint sensor
  
  
  String Event_Name = "FINGERPRINT "; // this is the name of the file of the database
  
  String Key = "beStaVRpfye6wtonedU"; // this is my unique key for the database created
  
  // Replace with your unique IFTTT URL resource
  String resource = "/trigger/" + Event_Name + "/with/key/" + Key;
  
  // Maker Webhooks IFTTT
  const char* server = "maker.ifttt.com"; // here database is store
  
  // Replace with your SSID and Password
  char* ssid     = "Telecom-2"; //wifi name
  char* pass = "X5NVY53V236k"; // wifi password
  SoftwareSerial mySerial (rxPin, txPin);
  Adafruit_Fingerprint finger = Adafruit_Fingerprint(&amp;mySerial); // communcation with the IoT and fingerprint sensor
  
  void setup()
  {
    Serial.begin(57600);
    mySerial.begin(57600);
    while (!Serial);  // For Yun/Leo/Micro/Zero/...
    delay(100);
    Serial.println("\n\nAdafruit finger detect test");
  
    // set the data rate for the sensor serial port
    finger.begin(57600);
    delay(5);
    if (finger.verifyPassword()) {
      Serial.println("Found fingerprint sensor!");
    } else {
      Serial.println("Did not find fingerprint sensor :(");
      while (1) {
        delay(1);
      }
    }
  // the fingerpprint sensor will first starts
    finger.getTemplateCount();
    Serial.print("Sensor contains ");
    Serial.print(finger.templateCount);
    Serial.println(" templates");
    Serial.println("Waiting for valid finger...");
  
  // meanwhile the esp8266 wifi module will start and conect to the wifi data given
    Serial.print("Connecting to: "); // connecting to a wifi avaible
    Serial.print(ssid);             // connecting to the given wifi name  
    WiFi.begin(ssid, pass);    // connection in progress 
  
    int timeout = 10 * 4; // 10 seconds
    while (WiFi.status() != WL_CONNECTED  &amp;&amp; (timeout-- &gt; 0)) {
      delay(250);
      Serial.print("Attempting to connect to SSID");
    }
    Serial.println("Connected");
  
    if (WiFi.status() != WL_CONNECTED) {
      Serial.println("Failed to connect");
    }
  
    Serial.print("WiFi connected in: ");
    Serial.print(millis());
    Serial.print(", IP address: ");
    Serial.println(WiFi.localIP());
  }
  
  void loop()                     // run over and over again
  { // now the finger print sensor will wait for a register ID
    getFingerprintIDez();
    if (finger.fingerID == 1) //mean if the ID correspond to ID 1
    {
  
      Serial.print("!!--");
      Serial.println(finger.fingerID);
      NAME = "Sailen"; //therefore the name of sailen will appear as ID 1
      ID = "1";
      if (finger.confidence &gt;= 60) // fingerprint test must over 60% of confidence
      {
        Serial.print("Attendace Marked for ");
        Serial.println(NAME);
        makeIFTTTRequest();
        // digital write - open the attendance
      }
  
    }
  
    if (finger.fingerID == 2 ) {
      Serial.print("!!--");
      Serial.println(finger.fingerID);
      digitalWrite(5, LOW);
      NAME = "Bob"; // therefore the name of bob will appear for ID 2
      ID = "2";
      if (finger.confidence &gt;= 60) // fingerprint test must over 60% of confidence
      {
        Serial.print("Attendace Marked for ");
        Serial.println(NAME);
        makeIFTTTRequest();
        // digital write - open the door
      }      //don't ned to run this at full speed.
  
    }
  
  }
  
  uint8_t getFingerprintID() {
    uint8_t p = finger.getImage();
    switch (p) {
      case FINGERPRINT_OK:
        Serial.println("Image taken");
        break;
      case FINGERPRINT_NOFINGER:
        Serial.println("No finger detected");
        return p;
      case FINGERPRINT_PACKETRECIEVEERR:
        Serial.println("Communication error");
        return p;
      case FINGERPRINT_IMAGEFAIL:
        Serial.println("Imaging error");
        return p;
      default:
        Serial.println("Unknown error");
        return p;
    }
  
    // OK success!
  
    p = finger.image2Tz();
    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!
    p = finger.fingerFastSearch();
    if (p == FINGERPRINT_OK) {
      Serial.println("Found a print match!");
    } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
      Serial.println("Communication error");
      return p;
    } else if (p == FINGERPRINT_NOTFOUND) {
      Serial.println("Did not find a match");
      return p;
    } else {
      Serial.println("Unknown error");
      return p;
    }
  
    // found a match!
    Serial.print("Found ID #"); Serial.print(finger.fingerID);
    Serial.print(" with confidence of "); Serial.println(finger.confidence);
  
    return finger.fingerID;
  }
  
  // returns -1 if failed, otherwise returns ID #
  int getFingerprintIDez() {
    uint8_t p = finger.getImage();
    if (p != FINGERPRINT_OK)  return -1;
  
    p = finger.image2Tz();
    if (p != FINGERPRINT_OK)  return -1;
  
    p = finger.fingerFastSearch();
    if (p != FINGERPRINT_OK)  return -1;
  
    // found a match!
    Serial.print("Found ID #"); Serial.print(finger.fingerID);
    Serial.print(" with confidence of "); Serial.println(finger.confidence);
    return finger.fingerID;
  }
  
  // Make an HTTP request to the IFTTT web service
  void makeIFTTTRequest() {
    Serial.print("Connecting to "); // means connecting to my google database
    Serial.print(server);
  
    WiFiClient client;
    int retries = 5;
    while (!!!client.connect(server, 80) &amp;&amp; (retries-- &gt; 0)) {
      Serial.print(".");
    }
    Serial.println();
    if (!!!client.connected()) {
      Serial.println("Failed to connect...");
    }
  
    Serial.print("Request resource: ");
    Serial.println(resource);
  
  // now that the IoT has access to the data base
  // value 1 will be use for name and value 2 for which ID it is
  
    String jsonObject = String("{\"value1\":\"") + NAME + "\",\"value2\":\"" + ID
                        + "\"}"; // name and id is registered in the database
  
    client.println(String("POST ") + resource + " HTTP/1.1");
    client.println(String("Host: ") + server);
    client.println("Connection: close\r\nContent-Type: application/json");
    client.print("Content-Length: ");
    client.println(jsonObject.length());
    client.println();
    client.println(jsonObject);
  
    int timeout = 5 * 10; // 5 seconds
    while (!!!client.available() &amp;&amp; (timeout-- &gt; 0)) {
      delay(100);
    }
    if (!!!client.available()) {
      Serial.println("No response...");
    }
    while (client.available()) {
      Serial.write(client.read());
    }
  
    Serial.println("\nclosing connection");
    client.stop();
  }`
  </code></pre>
  
  <p>is there something wrong?
  i watch a video like this on youtube but mine is a bit different
  <a href="https://techiesms.com/iot-projects/iot-attendance-system-without-website/" rel="nofollow noreferrer">https://techiesms.com/iot-projects/iot-attendance-system-without-website/</a></p>