Buzzer won't on my code; i testes it by itself and its working but when i put it on my main code i does not work;

i tried to figure out from where the problem is and i concluded its from the fingerprint sensor it makes no sense but it's happennenig and now am really confused
PS : void buzzer() and the pinMode in void configurationBroche() are the ones wich concerne the buzzer the rest of the code is working properly
PS 2: the buzzer is just an alarme when the door still open after a specified delay thats all

#include <Adafruit_Fingerprint.h>
#include <LiquidCrystal_I2C.h>
#include <HardwareSerial.h>
#include <ESP8266WiFi.h>
//#include <WiFi.h>
const char* NOM;
const char* SALLE;


String Event_Name = "historique des entrés";

String Key = "cmzj-mXCZk0corohNRlWAMndXnKjDLqJIjwlslpECJ7";

String resource = "/trigger/" + Event_Name + "/with/key/" + Key;

// Maker Webhooks IFTTT
const char* server = "maker.ifttt.com";

// Replace with your SSID and Password
const char* utilisateur     = "Orange-BFAA";
const char* mdp = "topnetbnh";

LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_Fingerprint empreinte = Adafruit_Fingerprint(&Serial1);
int BouttonBas = 13;
int BouttonHaut = 26;
int BouttonSelect = 33;
int menu = 1;
int EtatdePorte;
void setup() 
 {
  initialisation(); 
  configurationBroche();
 }
void loop() 
 {
  Empreinte();
  Bouttons();
  buzzer();
 }
 
void initialisation(){
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.print("Placer votre empreinte");
  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
  empreinte.begin(57600);
  delay(5);
  if (empreinte.verifyPassword()) {
    Serial.println("capteur d'empreinte detecté");
  } else {
    Serial.println("aucune capteur d'empreinte detecté");
    while (1) { delay(1); }
  }

  Serial.println(F("Reading sensor parameters"));
  empreinte.getParameters();
  Serial.print(F("Status: 0x")); Serial.println(empreinte.status_reg, HEX);
  Serial.print(F("Sys ID: 0x")); Serial.println(empreinte.system_id, HEX);
  Serial.print(F("Capacity: ")); Serial.println(empreinte.capacity);
  Serial.print(F("Security level: ")); Serial.println(empreinte.security_level);
  Serial.print(F("Device address: ")); Serial.println(empreinte.device_addr, HEX);
  Serial.print(F("Packet len: ")); Serial.println(empreinte.packet_len);
  Serial.print(F("Baud rate: ")); Serial.println(empreinte.baud_rate);

  empreinte.getTemplateCount();

  if (empreinte.templateCount == 0) {
    Serial.print("aucun empreinte enregistré dans la capteur, essayez de faire l'exemple (enroll)");
  }
  else {
    Serial.println("attendre pour une empreinte validé");
      Serial.print("capteur contien "); Serial.print(empreinte.templateCount); Serial.println(" templates");
  }
   Serial.print("Connection a: ");
  Serial.print(utilisateur);
  WiFi.begin(utilisateur, mdp);

  int timeout = 10 * 4; // 10 seconds
  while (WiFi.status() != WL_CONNECTED  && (timeout-- > 0)) {
    delay(250);
    Serial.print(".");
  }
  Serial.println("");

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("erreur de connexion");
  }

  Serial.print("WiFi connecte a: ");
  Serial.print(millis());
  Serial.print(",IP address : ");
  Serial.println(WiFi.localIP()); 

}
 


void configurationBroche() {
  pinMode(BouttonHaut, INPUT_PULLUP);
  pinMode(BouttonBas, INPUT_PULLUP);
  pinMode(BouttonSelect, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);


}
void Empreinte(){  
{   
  getFingerprintID();
  if (empreinte.fingerID == 1) {

    Serial.print("!!--");
    Serial.println(empreinte.fingerID);
    NOM = "ahmed benhamad";
}
    if (empreinte.confidence >= 60) {
      Serial.print("Attendace Marked for "); Serial.println(NOM);
      // digital write - open the door
    }
delay(50);
  }

  if (empreinte.fingerID == 88 ) {
    Serial.print("!!--");
    Serial.println(empreinte.fingerID);
    digitalWrite(2, LOW);
    NOM = "mondher ayeb";
    if (empreinte.confidence >= 60) {
      Serial.print("Empreinte marqué pour "); Serial.println(NOM);
      
      // digital write - open the door
    }      //don't ned to run this at full speed.

  }
  empreinte.fingerID = 0;
}
void Bouttons() {
  if (!digitalRead(BouttonBas)){
    menu++;
    MAJMenu();
    delay(100);
    while (!digitalRead(BouttonBas));
  }
  if (!digitalRead(BouttonHaut)){
    menu--;
    MAJMenu();
    delay(100);
    while(!digitalRead(BouttonHaut));
  }
  if (!digitalRead(BouttonSelect)){
    executionAction();
    MAJMenu();
    delay(100);
    while (!digitalRead(BouttonSelect));
  }
}

void buzzer(){
  EtatdePorte=digitalRead(12);
  
  if (EtatdePorte == HIGH){
    tone(14, 400);
  }
  else{
    noTone(14);
  }
  delay(200);
}
void MAJMenu() {
  switch (menu) {
    case 0:
      menu = 1;
      break;
    case 1:
      lcd.clear();
      lcd.print(">Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 2:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(">Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 3:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(">Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 4:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(">Annuler");
      break;
    case 5:
      menu = 4;
      break;
  }
}


uint8_t getFingerprintID() {
  uint8_t p = empreinte.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image prise");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("aucune empreinte détecté");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("erreur de lire de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }
  

  // OK success!

  p = empreinte.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converti");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("l'image est malpropre");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }

  // OK converted!
  p = empreinte.fingerSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("correspondance trouvé");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("erreur de communication");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    lcd.clear();
    lcd.println("aucune correspondance");
    delay(3000);
    lcd.clear();
    lcd.println("Ressayer une autre fois");
    return p;
  } else {
    Serial.println("erreur de communication");
    return p;
  }

  // found a match!
  lcd.clear();
  lcd.print("Empreinte validee");
  delay(2000);
  lcd.clear();
  MAJMenu();
  return empreinte.fingerID;
 
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = empreinte.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
  return empreinte.fingerID;
}
void executionAction() {
  switch (menu) {
    case 1:
      action1();
      break;
    case 2:
      action2();
      break;
    case 3:
      action3();
      break;
    case 4:
      action4();
      break;
  }
}
void action1() {
  lcd.clear();
  lcd.print("Salle 1 est ouvert");
  delay(1500);
  SALLE="salle 1";
  IFTTTRequete();
  ESP.restart();
}
void action2() {
  lcd.clear();
  lcd.print("Salle 2 est ouvert");
  delay(1500);
  SALLE="salle 2";
   IFTTTRequete();
  ESP.restart();
}
void action3() {
  lcd.clear();
  lcd.print("Salle 3 est ouvert");
  delay(1500);
  SALLE="salle 3";
 IFTTTRequete();
 ESP.restart();
}
void action4() {
  lcd.clear();
  lcd.print("Annulation...");
  delay(1500);
  ESP.restart();
}
void  IFTTTRequete() {
  Serial.print("Connection Ă  ");
  Serial.print(server);

  WiFiClient client;
  int retries = 5;
  while (!!!client.connect(server, 80) && (retries-- > 0)) {
    Serial.print(".");
  }
  Serial.println();
  if (!!!client.connected()) {
    Serial.println("erreur de connexion...");
  }

  Serial.print("Request resource: ");
  Serial.println(resource);

  String jsonObject = String("{\"value1\":\"") + NOM + "\",\"value2\":\"" + SALLE
                       +"\"}";

  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() && (timeout-- > 0)) {
    delay(100);
  }
  if (!!!client.available()) {
    Serial.println("No response...");
  }
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("\nclosing connection");
  client.stop();
}
````````

if (!client.available()) {

void Bouttons() {
  if (!digitalRead(BouttonBas))menu++;
  if (!digitalRead(BouttonHaut))menu--;
  if (!digitalRead(BouttonSelect))executionAction();
  delay(100);
  while (!digitalRead(BouttonBas) || !digitalRead(BouttonHaut) || !digitalRead(BouttonSelect));
  MAJMenu();
}
1 Like

really appreciate that but please read my actual problem

Put some serial prints in (start with buzzer) to see what's going on.

@ahmed6666 UPD try if this edition does alternative

#include <Adafruit_Fingerprint.h>
#include <LiquidCrystal_I2C.h>
#include <HardwareSerial.h>
#include <ESP8266WiFi.h>
//#include <WiFi.h>
const char* NOM;
const char* SALLE;

String Event_Name = "historique des entrés";
String Key = "cmzj-mXCZk0corohNRlWAMndXnKjDLqJIjwlslpECJ7";
String resource = "/trigger/" + Event_Name + "/with/key/" + Key;

// Maker Webhooks IFTTT
const char* server = "maker.ifttt.com";

// Replace with your SSID and Password
const char* utilisateur     = "Orange-BFAA";
const char* mdp = "topnetbnh";

LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_Fingerprint empreinte = Adafruit_Fingerprint(&Serial1);
const int BouttonBas = 13;
const int BouttonHaut = 26;
const int BouttonSelect = 33;
int menu = 1;
int EtatdePorte;

void setup(){
  initialisation();
  configurationBroche();
}

void loop(){
  Empreinte();
  Bouttons();
  buzzer();
}

void initialisation() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.print("Placer votre empreinte");
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  yield(100);
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  empreinte.begin(57600);
  yield(5);
  if (empreinte.verifyPassword()) {
    Serial.println("capteur d'empreinte detecté");
  } else {
    Serial.println("aucune capteur d'empreinte detecté");
    while (1) {
      yield(1);
    }
  }

  Serial.println(F("Reading sensor parameters"));
  empreinte.getParameters();
  Serial.print(F("Status: 0x")); Serial.println(empreinte.status_reg, HEX);
  Serial.print(F("Sys ID: 0x")); Serial.println(empreinte.system_id, HEX);
  Serial.print(F("Capacity: ")); Serial.println(empreinte.capacity);
  Serial.print(F("Security level: ")); Serial.println(empreinte.security_level);
  Serial.print(F("Device address: ")); Serial.println(empreinte.device_addr, HEX);
  Serial.print(F("Packet len: ")); Serial.println(empreinte.packet_len);
  Serial.print(F("Baud rate: ")); Serial.println(empreinte.baud_rate);

  empreinte.getTemplateCount();

  if (empreinte.templateCount == 0) {
    Serial.print("aucun empreinte enregistré dans la capteur, essayez de faire l'exemple (enroll)");
  }
  else {
    Serial.println("attendre pour une empreinte validé");
    Serial.print("capteur contien "); Serial.print(empreinte.templateCount); Serial.println(" templates");
  }
  Serial.print("Connection a: ");
  Serial.print(utilisateur);
  WiFi.begin(utilisateur, mdp);

  int timeout = 10 * 4; // 10 seconds
  while (WiFi.status() != WL_CONNECTED  && (timeout-- > 0)) {
    yield(250);
    Serial.print(".");
  }
  Serial.println("");

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("erreur de connexion");
  }

  Serial.print("WiFi connecte a: ");
  Serial.print(millis());
  Serial.print(",IP address : ");
  Serial.println(WiFi.localIP());

}



void configurationBroche() {
  pinMode(BouttonHaut, INPUT_PULLUP);
  pinMode(BouttonBas, INPUT_PULLUP);
  pinMode(BouttonSelect, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);


}
void Empreinte() {
  {
    getFingerprintID();
    if (empreinte.fingerID == 1) {

      Serial.print("!!--");
      Serial.println(empreinte.fingerID);
      NOM = "ahmed benhamad";
    }
    if (empreinte.confidence >= 60) {
      Serial.print("Attendace Marked for "); Serial.println(NOM);
      // digital write - open the door
    }
    yield(50);
  }

  if (empreinte.fingerID == 88 ) {
    Serial.print("!!--");
    Serial.println(empreinte.fingerID);
    digitalWrite(2, LOW);
    NOM = "mondher ayeb";
    if (empreinte.confidence >= 60) {
      Serial.print("Empreinte marqué pour "); Serial.println(NOM);

      // digital write - open the door
    }      //don't ned to run this at full speed.

  }
  empreinte.fingerID = 0;
}
void Bouttons() {
  if (!digitalRead(BouttonBas))menu++;
  if (!digitalRead(BouttonHaut))menu--;
  if (!digitalRead(BouttonSelect))executionAction();
  yield(100);
  while (!digitalRead(BouttonBas) || !digitalRead(BouttonHaut) || !digitalRead(BouttonSelect));
  MAJMenu();
}

void buzzer() {
  EtatdePorte = digitalRead(12);
  if (EtatdePorte == HIGH)tone(14, 400,1000, BUZZER_CHANNEL);
  else noTone(14);
  yield(200);
}
void MAJMenu() {
  switch (menu) {
    case 0:
      menu = 1;
      break;
    case 1:
      lcd.clear();
      lcd.print(">Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 2:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(">Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 3:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(">Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 4:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(">Annuler");
      break;
    case 5:
      menu = 4;
      break;
  }
}


uint8_t getFingerprintID() {
  uint8_t p = empreinte.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image prise");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("aucune empreinte détecté");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("erreur de lire de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }


  // OK success!

  p = empreinte.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converti");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("l'image est malpropre");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }

  // OK converted!
  p = empreinte.fingerSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("correspondance trouvé");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("erreur de communication");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    lcd.clear();
    lcd.println("aucune correspondance");
    yield(3000);
    lcd.clear();
    lcd.println("Ressayer une autre fois");
    return p;
  } else {
    Serial.println("erreur de communication");
    return p;
  }

  // found a match!
  lcd.clear();
  lcd.print("Empreinte validee");
  yield(2000);
  lcd.clear();
  MAJMenu();
  return empreinte.fingerID;

}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = empreinte.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
  return empreinte.fingerID;
}
void executionAction() {
  switch (menu) {
    case 1:
      action1();
      break;
    case 2:
      action2();
      break;
    case 3:
      action3();
      break;
    case 4:
      action4();
      break;
  }
}
void action1() {
  lcd.clear();
  lcd.print("Salle 1 est ouvert");
  yield(1500);
  SALLE = "salle 1";
  IFTTTRequete();
  ESP.restart();
}
void action2() {
  lcd.clear();
  lcd.print("Salle 2 est ouvert");
  yield(1500);
  SALLE = "salle 2";
  IFTTTRequete();
  ESP.restart();
}
void action3() {
  lcd.clear();
  lcd.print("Salle 3 est ouvert");
  yield(1500);
  SALLE = "salle 3";
  IFTTTRequete();
  ESP.restart();
}
void action4() {
  lcd.clear();
  lcd.print("Annulation...");
  yield(1500);
  ESP.restart();
}
void  IFTTTRequete() {
  Serial.print("Connection Ă  ");
  Serial.print(server);

  WiFiClient client;
  int retries = 5;
  while (!client.connect(server, 80) && (retries-- > 0)) {
    Serial.print(".");
  }
  Serial.println();
  if (!client.connected()) {
    Serial.println("erreur de connexion...");
  }

  Serial.print("Request resource: ");
  Serial.println(resource);

  String jsonObject = String("{\"value1\":\"") + NOM + "\",\"value2\":\"" + SALLE
                      + "\"}";

  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() && (timeout-- > 0)) {
    yield(100);
  }
  if (!client.available()) {
    Serial.println("No response...");
  }
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("\nclosing connection");
  client.stop();
}

1 Like

me either thats why it confuses me
is there any possibility that the problem is from the ESP8266 ?

its the same

and you say if anything else is disconnected the buzzer start to work, yes?

Which ESP8266 are you using?

Post an image of your wiring with the buzzer connected.

Post a schematic.

Post, below, the latest version of the code you are using.

no, as i said the code but the buzzer work properly thats why i didnt connect the fingerprint sensor i just connected le LCD and it works, what i meant is that i built the buzzer code out of my main code and it worked (thats how i built my code step by step and then it ends in a single file) so i tried to put the buzzer in every single file and it worked except in the test of fingerprint file

#include <Adafruit_Fingerprint.h>
#include <LiquidCrystal_I2C.h>
#include <HardwareSerial.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
//#include <WiFi.h>
const char* NOM;
const char* SALLE;
const int buzzer = 14; 
const int sensor = 12;

String Event_Name = "historique des entrés";

String Key = "cmzj-mXCZk0corohNRlWAMndXnKjDLqJIjwlslpECJ7";

String resource = "/trigger/" + Event_Name + "/with/key/" + Key;


const char* server = "maker.ifttt.com";


const char* utilisateur     = "Orange-BFAA";
const char* mdp = "topnetbnh";

LiquidCrystal_I2C lcd(0x27, 20, 4);
Adafruit_Fingerprint empreinte = Adafruit_Fingerprint(&Serial1);
int BouttonBas = 13;
int BouttonHaut = 26;
int BouttonSelect = 33;
int menu = 1;
int EtatdePorte;
void setup() 
 {
  initialisation(); 
  configurationBroche();
 }
void loop() 
 {
  Empreinte();
  Bouttons();
  alarme();
 }


void initialisation(){
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.print("Placer votre empreinte");
  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
  empreinte.begin(57600);
  delay(5);
  if (empreinte.verifyPassword()) {
    Serial.println("capteur d'empreinte detecté");
  } else {
    Serial.println("aucune capteur d'empreinte detecté");
    while (1) { delay(1); }
  }

  Serial.println(F("Reading sensor parameters"));
  empreinte.getParameters();
  Serial.print(F("Status: 0x")); Serial.println(empreinte.status_reg, HEX);
  Serial.print(F("Sys ID: 0x")); Serial.println(empreinte.system_id, HEX);
  Serial.print(F("Capacity: ")); Serial.println(empreinte.capacity);
  Serial.print(F("Security level: ")); Serial.println(empreinte.security_level);
  Serial.print(F("Device address: ")); Serial.println(empreinte.device_addr, HEX);
  Serial.print(F("Packet len: ")); Serial.println(empreinte.packet_len);
  Serial.print(F("Baud rate: ")); Serial.println(empreinte.baud_rate);

  empreinte.getTemplateCount();

  if (empreinte.templateCount == 0) {
    Serial.print("aucun empreinte enregistré dans la capteur, essayez de faire l'exemple (enroll)");
  }
  else {
    Serial.println("attendre pour une empreinte validé");
      Serial.print("capteur contien "); Serial.print(empreinte.templateCount); Serial.println(" templates");
  }
   Serial.print("Connection a: ");
  Serial.print(utilisateur);
  WiFi.begin(utilisateur, mdp);

  int timeout = 10 * 4; // 10 seconds
  while (WiFi.status() != WL_CONNECTED  && (timeout-- > 0)) {
    delay(250);
    Serial.print(".");
  }
  Serial.println("");

  if (WiFi.status() != WL_CONNECTED) {
    Serial.println("erreur de connexion");
  }

  Serial.print("WiFi connecte a: ");
  Serial.print(millis());
  Serial.print(",IP address : ");
  Serial.println(WiFi.localIP()); 

}
 


void configurationBroche() {
  pinMode(BouttonHaut, INPUT_PULLUP);
  pinMode(BouttonBas, INPUT_PULLUP);
  pinMode(BouttonSelect, INPUT_PULLUP);
  pinMode(sensor, INPUT_PULLUP);
}

void Empreinte(){  
{   
  getFingerprintID();
  if (empreinte.fingerID == 1) {

    Serial.print("!!--");
    Serial.println(empreinte.fingerID);
    NOM = "ahmed benhamad";
}
    if (empreinte.confidence >= 60) {
      Serial.print("Attendace Marked for "); Serial.println(NOM);
      // digital write - open the door
    }
delay(50);
  }

  if (empreinte.fingerID == 88 ) {
    Serial.print("!!--");
    Serial.println(empreinte.fingerID);
    digitalWrite(2, LOW);
    NOM = "mondher ayeb";
    if (empreinte.confidence >= 60) {
      Serial.print("Empreinte marqué pour "); Serial.println(NOM);
      
      // digital write - open the door
    }      //don't ned to run this at full speed.

  }
  empreinte.fingerID = 0;
}
void Bouttons() {
  if (!digitalRead(BouttonBas)){
    menu++;
    MAJMenu();
    delay(100);
    while (!digitalRead(BouttonBas));
  }
  if (!digitalRead(BouttonHaut)){
    menu--;
    MAJMenu();
    delay(100);
    while(!digitalRead(BouttonHaut));
  }
  if (!digitalRead(BouttonSelect)){
    executionAction();
    MAJMenu();
    delay(100);
    while (!digitalRead(BouttonSelect));
  }
}
void alarme(){
 EtatdePorte=digitalRead(sensor);
  
  if (EtatdePorte == HIGH){

    digitalWrite(buzzer, HIGH);
  }
  else{
    noTone(buzzer);
  }
  delay(200);
  }
void MAJMenu() {
  switch (menu) {
    case 0:
      menu = 1;
      break;
    case 1:
      lcd.clear();
      lcd.print(">Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 2:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(">Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 3:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(">Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(" Annuler");
      break;
    case 4:
      lcd.clear();
      lcd.print(" Salle 1");
      lcd.setCursor(0, 1);
      lcd.print(" Salle 2");
      lcd.setCursor(0, 2);
      lcd.print(" Salle 3");
      lcd.setCursor(0, 3);
      lcd.print(">Annuler");
      break;
    case 5:
      menu = 4;
      break;
  }
}


uint8_t getFingerprintID() {
  uint8_t p = empreinte.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image prise");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("aucune empreinte détecté");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("erreur de lire de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }
  

  // OK success!

  p = empreinte.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converti");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("l'image est malpropre");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("erreur de communication");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("impossible de trouver les caractéristique de l'empreinte");
      return p;
    default:
      Serial.println("erreur inconnu");
      return p;
  }

  // OK converted!
  p = empreinte.fingerSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("correspondance trouvé");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("erreur de communication");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    lcd.clear();
    lcd.println("aucune correspondance");
    delay(3000);
    lcd.clear();
    lcd.println("Ressayer une autre fois");
    return p;
  } else {
    Serial.println("erreur de communication");
    return p;
  }

  // found a match!
  lcd.clear();
  lcd.print("Empreinte validee");
  delay(2000);
  lcd.clear();
  MAJMenu();
  return empreinte.fingerID;
 
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = empreinte.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = empreinte.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
  return empreinte.fingerID;
}
void executionAction() {
  switch (menu) {
    case 1:
      action1();
      break;
    case 2:
      action2();
      break;
    case 3:
      action3();
      break;
    case 4:
      action4();
      break;
  }
}
void action1() {
  lcd.clear();
  lcd.print("Salle 1 est ouvert");
  //digitalWrite(
  delay(1500);
  SALLE="salle 1";
  IFTTTRequete();
  ESP.restart();
}
void action2() {
  lcd.clear();
  lcd.print("Salle 2 est ouvert");
  delay(1500);
  SALLE="salle 2";
   IFTTTRequete();
  ESP.restart();
}
void action3() {
  lcd.clear();
  lcd.print("Salle 3 est ouvert");
  delay(1500);
  SALLE="salle 3";
 IFTTTRequete();
 ESP.restart();
}
void action4() {
  lcd.clear();
  lcd.print("Annulation...");
  delay(1500);
  ESP.restart();
}
void  IFTTTRequete() {
  Serial.print("Connection Ă  ");
  Serial.print(server);

  WiFiClient client;
  int retries = 5;
  while (!!!client.connect(server, 80) && (retries-- > 0)) {
    Serial.print(".");
  }
  Serial.println();
  if (!!!client.connected()) {
    Serial.println("erreur de connexion...");
  }

  Serial.print("Request resource: ");
  Serial.println(resource);

  String jsonObject = String("{\"value1\":\"") + NOM + "\",\"value2\":\"" + SALLE
                       +"\"}";

  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() && (timeout-- > 0)) {
    delay(100);
  }
  if (!!!client.available()) {
    Serial.println("No response...");
  }
  while (client.available()) {
    Serial.write(client.read());
  }

  Serial.println("\nclosing connection");
  client.stop();
}

Well thanks for posting the project image. I am confused that the devices used in the code like the fingerprint sensor or lcd is not connected. You do know the setup() does not properly WORK if those devices are NOT connected?

Sorry I cannot help you. Good luck with your project.

1 Like

I would start there and see what happens, its possible that one of the librarys used here is conflicting with the Tone function.
if you see the serial output or the LED illuminate then you at least know that the code is meeting the requirements for the tone to be generated. then you can troubleshoot why it doesnt generate.

the pin 13 in digitalWrite is for what ?

that will turn the built in LED on that is on pin 13

1 Like

Hi,
Where in your code is the pinMode statement for the buzzer output pin?

Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.