Problem associated with include<memory>

#include <WiFiLink.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <Adafruit_Fingerprint.h>
#include <ArduinoJson.h>
#include <FS.h>
extern "C" {
#include <wl_definitions.h>
}

const char* ssid = "hii";
const char* password = "hii@10";
const char* host = "sheets.googleapis.com";
const char* spreadsheetId = "abcdefg"; // Replace with your spreadsheet ID
const char* sheetName = "Attendance"; // Replace with your sheet name


bool loadServiceAccountKey() {
  // Open the JSON file
  File file = SPIFFS.open("/abcdefg.json", "r");
  if (!file) {
    Serial.println("Failed to open service account key file");
    return false;
  }

  // Parse the JSON data
  StaticJsonDocument<1024> doc;
  DeserializationError error = deserializeJson(doc, file);
  if (error) {
    Serial.println("Failed to parse service account key file");
    file.close();
    return false;
  }

  // Extract the necessary information (private key, client email, etc.)
  const char* privateKey = doc["private_key"];
  const char* clientEmail = doc["client_email"];

  // Use the extracted information to authenticate requests to Google Sheets API
  // (Add your authentication logic here)

  // Close the file
  file.close();

  return true;
}

// LCD configuration
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the I2C address if needed

// GSM800L configuration
SoftwareSerial gsmSerial(8, 7); // RX, TX

// Fingerprint sensor configuration
SoftwareSerial fingerprintSerial(10, 11); // RX, TX
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerprintSerial);

const int buzzerPin = 9;

// Parent phone numbers
String parentPhoneNumbers[] = {
  // Enter parent phone numbers here, one for each student
  "+91111111111",
  "+919975783632",
  "+919699784068",
  "+919689781708",
  "+918668794502"// Add more phone numbers as needed
};

const int numStudents = 100; // Number of students
unsigned long cooldownDuration = 60000; // 30 seconds cooldown period per student
unsigned long lastFingerprintTime[numStudents] = {0}; // Initialize cooldown times for each student to 0

bool fingerDetected = false;

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  gsmSerial.begin(9600);
  fingerprintSerial.begin(57600);
  pinMode(buzzerPin, OUTPUT);
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }
  lcd.print("Initializing...");
  // Initialize GSM module
  gsmSerial.println("AT");
  delay(1000);
  gsmSerial.println("AT+CMGF=1"); // Set SMS mode to text
  delay(1000);

  lcd.clear();
  lcd.print("System initialized");
  delay(2000);
  lcd.clear();
  SPIFFS.begin();
  
  // Load and parse the service account key
  if (!loadServiceAccountKey()) {
    // Handle error
  }
}

void loop() {
  // Example: Read fingerprint
  if (!fingerDetected) {
    lcd.clear();
    lcd.print("Place finger");
    fingerDetected = true;
  }
  
  int fingerprintID = getFingerprintID();
  if (fingerprintID != -1) {
    // Check if cooldown period has elapsed for this student
    if (millis() - lastFingerprintTime[fingerprintID] >= cooldownDuration) {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Fingerprint ID: ");
      lcd.setCursor(0,1);
      lcd.print(fingerprintID);
      activateBuzzer();

      Serial.print("Fingerprint ID: ");
      Serial.println(fingerprintID);
      Serial.print("Sending SMS to: ");
      Serial.println(parentPhoneNumbers[fingerprintID]);
      Serial.print("Sending attendance to Google Sheets...");
    
      // Example: Send attendance to Google Sheets
      sendToGoogleSheets(fingerprintID);
      // Example: Send SMS
      sendSMS(parentPhoneNumbers[fingerprintID], "Your Child Is At College");

      // Update last fingerprint time for this student
      lastFingerprintTime[fingerprintID] = millis();
    } 
    else 
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Attendance");
      lcd.setCursor(0, 1);
      lcd.print("Cooldown");
      delay(2000);
      lcd.clear();
    }
    fingerDetected = false;
  }
}

int getFingerprintID() {
  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;
  return finger.fingerID;
}

void sendToGoogleSheets(int fingerprintID) 
{
  // Construct HTTP request payload
  String payload = "{\"values\": [[" + String(fingerprintID) + "]]}";

  // Construct HTTP request
  String request = "POST /v4/spreadsheets/" + String(spreadsheetId) + "/values/" + String(sheetName) + ":append?valueInputOption=RAW HTTP/1.1\r\n" +
                   "Host: " + String(host) + "\r\n" +
                   "Content-Type: application/json\r\n" +
                   "Authorization: Bearer " + String(serviceAccountKey) + "\r\n" +
                   "Content-Length: " + String(payload.length()) + "\r\n\r\n" +
                   payload;

  // Establish a secure connection
  WiFiClientSecure client;
  if (!client.connect(host, 443)) {
    Serial.println("Connection failed");
    return;
  }

  // Send HTTP request to Google Sheets API
  client.print(request);

  // Wait for the server's response
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      break;
    }
  }
  String response = client.readStringUntil('\n');
  Serial.println("Server response: " + response);

  // Close the connection
  client.stop();
}

void sendSMS(String phoneNumber, String message)
 {
  gsmSerial.print("AT+CMGS=\"");
  gsmSerial.print(phoneNumber);
  gsmSerial.println("\"");
  delay(1000);
  gsmSerial.print(message);
  delay(1000);
  gsmSerial.write(26); // Send Ctrl+Z to indicate end of message
  delay(1000);
}

void activateBuzzer() 
{
  // Activate the buzzer for 1 second
  digitalWrite(buzzerPin, HIGH);
  delay(100);
  digitalWrite(buzzerPin, LOW);
}
````Use code tags to format code for the forum`
for above code my Arduino IDE showing error as follow  
In file included from C:\Users\ACER\Documents\Arduino\developingcppfor_final1\developingcppfor_final1.ino:8:0:
C:\Users\ACER\Documents\Arduino\libraries\FS\src/FS.h:24:10: fatal error: memory: No such file or directory
 #include <memory>
          ^~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1                                              why?

You started a topic in the Uncategorised category of the forum

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Which board have you got selected in the IDE ?

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