Barcode Scanner Shield acts as Arduino Shield via 1Sheeld

Buy 1Sheeld

 

Turn your smartphone into a Barcode Scanner shield for Arduino. Barcode Scanner library allows your phone to scan various type of barcodes (1D/2D)and
return the data back to do certain actions.
 
(*This shield supported by IOS application only)
 

This shield is one of the special shields. Special shields allows your Arduino board to use some capabilities your smartphone can do, like playing music, taking a picture, getting notifications, accessing the clock data and using the touch screen for various functions. Learn more from the special shields tutorial.

Barcode Scanner library allows your phone to read 1D/2D codes and take certain actions according the readings.

Adding #define CUSTOM_SETTINGS along with #define INCLUDE_BARCODE_SCANNER_SHIELD is a key that will let you unlock BarcodeScanner shield only amongst all shields and prevent 1Sheeld library from eating your memory especially for UNO board.

Notes

-Barcode Scanner support only these formats (UPC_A,UPC_E,EAN8,EAN13,CODE39,CODE93,CODE128,PDF417,QRCODE,AZTEC,ITF,ITF14,DATA_MATRIX)

-There’s an implicit delay in the app between each scan of max (2sec).

-When code first scanned Barcode scanner shield sends the first 128 character or less, while if code holds more than 128 character, then you will have to query the next characters using the query function queryNextDataBytes (explained), if less than 128 character it will all be sent once and you won’t have to query any more bytes.

For more information about Barcode check the Wiki link

2D barcodes coded to several categories for example the QR code supports (URL’s,business cards..etc) check the link here for more information, also check this link which generates most types of barcodes (1D & 2D).

 

 bool isNewBarcodeScanned(void)

Check if a new barcode scanned.

SYNTAX

BarcodeScanner.isNewBarcodeScanned();

RETURNS

A Yes ‘1’ or No ‘0’.

PARAMETERS

None.

USAGE

BarcodeScanner.isNewBarcodeScanned();

 
 

bool isFullySent(void)

Check if the data of code is fully sent. (used specially if code has more than 128 character)

SYNTAX

BarcodeScanner.isFullySent();

RETURNS

A Yes ‘1’ or No ‘0’.

PARAMETERS

None.

USAGE

BarcodeScanner.isFullySent();

 
 

bool isNextDataBytesReceived(void)

Check if the incoming data is the next characters of the scanned code. (used specially when query for next characters  function invoked)

SYNTAX

BarcodeScanner.isNextDataBytesReceived();

RETURNS

A Yes ‘1’ or No ‘0’.

PARAMETERS

None.

USAGE

BarcodeScanner.isNextDataBytesReceived();

 

byte getFormat(void)

Returns scanned code format type.

LITERALS:

UPC_A=0x01 ,UPC_E=0x02 ,EAN8=0x03 ,EAN13=0x04 ,CODE39=0x05 ,CODE93=0x06, CODE128=0x07 ,PDF417=0x08 ,QRCODE=0x09 ,AZTEC= 0x0A ,ITF= 0x0B, ITF14= 0x0C, DATA_MATRIX= 0x0D

SYNTAX

BarcodeScanner.getFormat();

RETURNS

A byte illustrates the format of scanned code.

PARAMETERS

None.

USAGE

byte formatType = BarcodeScanner.getFormat();

 

byte getCategory(void) (for 2D codes)

Returns 2D scanned code category type.

LITERALS:

NO_CATEGORY= 0x00,CODE_URL= 0x01,CODE_TXT= 0x02, CODE_EMAIL= 0x03,

CODE_VCARD= 0x04,CODE_SMS= 0x05,CODE_CALL= 0x06,CODE_GEO= 0x07,

CODE_WIFI= 0x08,CODE_EVENT= 0x09

SYNTAX

BarcodeScanner.getCategory();

RETURNS

A byte illustrates the catergory of 2D scanned code.

PARAMETERS

None.

USAGE

byte categoryType= BarcodeScanner.getCategory();

 

byte getDataLength(void)

Returns number of characters read. (Max 128 characters)

Note: if code has more than 128 character use queryNextbytes function. also check official example for more demonstration.

SYNTAX

BarcodeScanner.getDataLength();

RETURNS

Number of data characters.

PARAMETERS

None.

USAGE

byte dataLength= BarcodeScanner.getDataLength();

 

int getMaxDataLength(void)

Returns max number of characters barcode holds.

SYNTAX

BarcodeScanner.getMaxDataLength();

RETURNS

Number of data characters code holds.

PARAMETERS

None.

USAGE

int maxDataLength= BarcodeScanner.getMaxDataLength();

 

char * getData(void)

Returns read characters from code.(128 max per scan if code holds more than 128,use queryNextDataBytes to get the rest characters)

SYNTAX

BarcodeScanner.getData();

RETURNS

last scanned code data.

PARAMETERS

None.

USAGE

char * myData= BarcodeScanner.getData();

 

void queryNextDataBytes(byte=128)

Queries next data characters from old scanned code.(used only if code holds more than 128 characters)

SYNTAX

BarcodeScanner.queryNextDataBytes(byte=128);

RETURNS

None.

PARAMETERS

Number of bytes needed with the max of 128 characters(Default 128).

USAGE

BarcodeScanner.queryNextDataBytes();

 

void queryParameterValue(const char *) (2D code)

Queries specific parameter data from a 2D scanned code. 

Note: check official examples for more demonstration.

each 2D category has it’s own parameters:

1-CODE_URL: “url”

2-CODE_TXT: “txt”

3-CODE_EMAIL: “mailto”,”subject”,”body”

4-CODE_VCARD: “N”,”FN”,”ORG”,”TITLE”,”TEL;WORK;VOICE”,”TEL;HOME;VOICE”,”ADR;WORK;PREF”,“LABEL;WORK;PREF”,”ADR;HOME”,”LABEL;HOME”,”EMAIL”,”REV”,”GENDER”,”NICKNAME”,”GEO”,“BDAY”

5-CODE_SMS: “body”,”number”

6-CODE_CALL: “tel”

7-CODE_GEO: “latitude”,”longitude”

8-CODE_WIFI: “T” (authentication type),”S”(SSID name),”P” (password),”H”(Hidden)

9-CODE_EVENT: “SUMMARY”,”DESCRIPTION”,”LOCATION”,”DTSTART”,”DTEND”

For an example check the official advanced example in 1Sheeld library.

SYNTAX

BarcodeScanner.queryParameterValue(“FN”);

RETURNS

None.

PARAMETERS

char array of parameter needed.

USAGE

BarcodeScanner.queryNextBytes("tel");

 

void setOnNewBarcodeScanned(void (*userFunction)(byte , byte , int ,char*))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once a new code is is scanned.

SYNTAX

BarcodeScanner.setOnNewBarcodeScanned(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

BarcodeScanned.setOnNewBarcodeScanned(&newScannedFunction);
/* On new barcode scanned function. */
void newScannedFunction(byte format,byte category,int maxLength,char * data)
{
 /* Check if the code scanned is a QR code or a Data matrix code. */
 if(format == QRCODE || format == DATA_MATRIX)
 {
 /* Check if the code scanned with email category type. */
 if(category == CODE_EMAIL)
 {
 /* Terminal line for debugging. */
 Terminal.println("Entered");
 /* Query parameters from barcode scanner. */
 BarcodeScanner.queryParameterValue("mailto");
 BarcodeScanner.queryParameterValue("subject");
 BarcodeScanner.queryParameterValue("body");
 }
 }
}

 

void setOnNextDataResponse(void (*userFunction)(byte, char *))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once the queried next bytes received.

SYNTAX

BarcodeScanner.setOnNextDataResponse(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

BarcodeScanned.setOnNextDataResponse(&nextData);
/* On new barcode scanned function. */
void nextData(byte dataLength,char * data)
{
   Terminal.println(data);
}

 

void setOnParameterValueResponse(void (*userFunction)(char * , char *))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once the queried parameter received.

SYNTAX

BarcodeScanner.setOnParameterValueResponse(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

BarcodeScanned.setOnParameterValueResponse(&getParameter);
/* On new barcode scanned function. */
void getParameter(char * parameter,char * value)
{
   Terminal.println(value);
}

 

void setOnError(void (*userFunction)(byte))

Sets a certain individual function coded by the user in the sketch to be called and runs its functionality once an error occurs when code is scanned.  

Literals:

BARCODE_NOT_SUPPORTED
BARCODE_SCANNING_ERROR
WRONG_PARAMETER
NOT_ENOUGH_BYTES
CATEGORY_NOT_SUPPORTED

SYNTAX

Barcode.setOnError(&userFunctionName);

RETURNS

None.

PARAMETERS

&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

USAGE

/* Subscribe to setOnError. */
BarcodeScanner.setOnError(&errorFunction);
/* errorFunction exists under the loop function. */
/* This function will be invoked if an error occurrs.*/
void errorFunction(byte errorData)
{
 /* Switch on error and print it on the terminal. */
 switch(errorData)
 {
 case BARCODE_NOT_SUPPORTED: Terminal.println("Barcode not supported");break;
 case BARCODE_SCANNING_ERROR: Terminal.println("Barcode scanning Error");break;
 case WRONG_PARAMETER: Terminal.println("Wrong parameter");break;
 case NOT_ENOUGH_BYTES: Terminal.println("No enough bytes");break;
 case CATEGORY_NOT_SUPPORTED: Terminal.println("Category not supported");break;
 }
}