Hello,
Hopefully, this is my last post about this, my project is an RFID attendance system using the Arduino Uno, ethernet shield and the RFID-Rc522 reader. I have finally troubleshooted to get the card to scan in, but now it won't copy on to my google spreadsheet. it says this
connecting...
your card no :121 211 95
Valid Person
connected
in the arduino source so I know it scans as a valid person and connects to the api which is pushingbox, because pushingbox shows that there are some requests, which makes me think that its a problem with the code on the google scripts thing I have.
function doGet(e) {
Logger.log( JSON.stringify(e) );
var result = 'Ok';
if (e.parameter == undefined) {
result = 'No Parameters';
}
else {
var id = '(i have my spreadsheet id here i just dont want people having access to this)'; // Spreadsheet ID
var sheet = SpreadsheetApp.openById(id).getActiveSheet();
var newRow = sheet.getLastRow() + 1;
var rfidData = [];
rfidData[0] = new Date();
for (var param in e.parameter) {
Logger.log('In for loop, param='+param);
var value = stripQuotes(e.parameter[param]);
switch (param) {
case 'allowed_members': //Parameter
rfidData[1] = value; //Value in column B
break;
case 'Member_ID':
rfidData[2] = value;
break;
default:
result = "Wrong parameter";
}
}
Logger.log(JSON.stringify(rfidData));
// Write new row below
var newRange = sheet.getRange(newRow, 1, 1, rfidData.length);
newRange.setValues([rfidData]);
}
// Return result of operation
return ContentService.createTextOutput(result);
}
/**
* Remove leading and trailing single or double quotes
*/
function stripQuotes( value ) {
return value.replace(/^["']|['"]$/g, "");
}
in case it helps, here is the spreadsheet code in the arduino software
void Sending_To_spreadsheet() //CONNECTING WITH MYSQL
{
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.print("GET /pushingbox?devid=v4C30CA17D5F64E2&allowed_members="); //YOUR URL
if(j!=No_Of_Card)
{
client.print('1');
// Serial.print('1');
}
else
{
client.print('0');
}
client.print("&Member_ID=");
for(int s=0;s<3;s++)
{
client.print(rfid.uid.uidByte[s]);
}
client.print(" "); //SPACE BEFORE HTTP/1.1
client.print("HTTP/1.1");
client.println();
client.println("Host: api.pushingbox.com");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}
Much help is appreciated! thanks.