0% found this document useful (0 votes)
2 views

Apps Script

The document outlines a Smart Attendance System that utilizes Google Sheets and an LCD display to log attendance data sent from an ESP32 device. It includes a function to handle GET requests, which records the current date, time, and name into a specified Google Sheet. Additionally, there is a placeholder for a POST request function intended for future use, although it is not currently implemented in the project.

Uploaded by

Junior Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Apps Script

The document outlines a Smart Attendance System that utilizes Google Sheets and an LCD display to log attendance data sent from an ESP32 device. It includes a function to handle GET requests, which records the current date, time, and name into a specified Google Sheet. Additionally, there is a placeholder for a POST request function intended for future use, although it is not currently implemented in the project.

Uploaded by

Junior Saad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Viral Science www.viralsciencecreativity.com www.youtube.

com/c/viralscience
// Smart Attendance System with Google Sheets and LCD Display
var ss = SpreadsheetApp.openById('Sheet ID Here'); //Enter your googlesheets URL Id
here
var sheet = ss.getSheetByName('Sheet1');
var timezone = "Asia/Kolkata"; //Set your timezone

function doGet(e){
Logger.log( JSON.stringify(e) );
//-------------------------------------------------------------------------------
---
//write_google_sheet() function in esp32 sketch, is send data to this code block
//-------------------------------------------------------------------------------
---
//get gps data from ESP32
if (e.parameter == 'undefined') {
return ContentService.createTextOutput("Received data is undefined");
}
//-------------------------------------------------------------------------------
---
var Curr_Date = new Date();
var Curr_Time = Utilities.formatDate(Curr_Date, timezone, 'HH:mm:ss');
var name = stripQuotes(e.parameters.name);
//Logger.log('name=' + name);
//-------------------------------------------------------------------------------
---
var nextRow = sheet.getLastRow() + 1;
sheet.getRange("A" + nextRow).setValue(Curr_Date);
sheet.getRange("B" + nextRow).setValue(Curr_Time);
sheet.getRange("C" + nextRow).setValue(name);
//-------------------------------------------------------------------------------
---

//returns response back to ESP32


return ContentService.createTextOutput("Card holder name is stored in column C");
//-------------------------------------------------------------------------------
---
}

function stripQuotes( value ) {


return value.toString().replace(/^["']|['"]$/g, "");
}

//Extra Function. Not used in this project.


//planning to use in future projects.
//this function is used to handle POST request
function doPost(e) {
var val = e.parameter.value;

if (e.parameter.value !== undefined){


var range = sheet.getRange('A2');
range.setValue(val);
}
}

You might also like