Hello, i have an inquiry. Do the google script coding need to reflect with Arduino coding if i modified the Arduino coding to my current needed but still using the same google script that i get from the github, is it the reason why the google spreadsheet cannot capture the data that i want from the Arduino?
hi @Railroader sorry for my mistake. below is the google script that i used.
function doGet(e) {
Logger.log( JSON.stringify(e) );
var result = 'Ok';
if (e.parameter == undefined) {
result = 'No Parameters';
}
else {
var id = ''; // 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 'machine_location': //Parameter
rfidData[1] = value; //Value in column B
break;
case 'Machine_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, "");
}
@J-M-L ouh... noted. i removed all the spreadsheet ID already.
Yes, it able to compile. just unable to transfer the data to the google sheet.
Where are you calling `Sending_To_spreadsheet()
do you mean i'm not declaring the function? or how is it suppose to work?
as per my understanding, we need to use pushing box as a medium to transfer the data from arduino to google spreadsheet as google script isnt compatible with it.
correct me if i'm wrong in answering your question or if my understand concept is wrong too.
the code you posted does indeed compile but you have a prototype function definition actually injected in the loop() and as it's useless then you have it's body that is executed as part of the loop
what do you expect from int j=incomingByte;as a global variable? it will be 0
what do you expect from if(j==incomingByte) {...?
what's the URL you are trying to build ?
what is connected to mySerial ?
mySerial is to read our ID for RFID tag. it connected with UHF Rfid Scanner and RS232.
As for the Sending_To_spreadsheet, those coding I'm copy from the github I found during example of the almost similar project of it. the video that i seen, able to capture the data, but they are using MFRC522. but i able to change the coding that run with RS232.
the code as it stands is really weird. the incoming bytes on mySerial are just dumped on the Serial monitor and you exit the the while loop with the variable holding the last byte received...
I'm using Arduino Uno Rev3 + Ethernet Shield, connect with RS232 that connected with the UHF Rfid Reader.
The purpose of my project is to track the asset movement. At the machine there, i will stick the Rfid sticker (passive Rfid; with its own ID printed) and once the machine move and the UHF Rfid Reader read the Rfid sticker, it will capture the asset ID (refer to Rfid sticker).
Hence, the data capture will be transfer to the googlesheet using Pushing box.
OK - the code is not very well architected to this end.
try to split the work in various functions. The loop ultimately could look like this:
void loop() {
if (newAssetAcquired(anAssetID)) {
// I received a new asset tag from Rfid sticker
if (initiateConnexionOK()) {
writeToGoogleSheet(anAssetID);
} else {
// deal with connexion error
}
}
}