My Cart

New Products

  • Fritzing Libraries: Cooking Hacks Modules Package for ArduinoJune 18, 2012

    Fritzing is an open-source initiative to support designers, artists, researchers and hobbyists to work creatively with interactive electronics. The Cooking Hacks Team is developing libraries of all our arduino modules. Fell free to download and use them with Fritzing when developing your own recipes for the Cooking Hacks community!

    Now you will find a complete Cooking Hacks' package with all our modules and accessories to make your projects with this application.

    Download Complete Fritzing Modules Pack




    You can download them separately in our Fritzing Section.

  • Fritzing libraries for 3G/GPRS Shield for Arduino (3G+GPS) availableMay 31, 2012

    fritzing-3g

    Fritzing is an open-source initiative to support designers, artists, researchers and hobbyists to work creatively with interactive electronics. The Cooking Hacks Team is developing libraries of all our arduino modules and you can download our library for our 3G/GPRS Shield for Arduino (3G+GPRS) now.

    Download Fritzing here.
    Download our library for 3G/GPRS Shield here.

    3G/GPRS Shield Tutorial
    Fritzing Libraries

  • Bluetooth modules and shields for Arduino - ComparativeMay 28, 2012

    Cooking Hacks has recently released two new Bluetooth devices. Both comes with the Bluegiga WT12 chip (Bluetooth v2.1 + EDR. Class 2) that allows to discover up to 250 devices in a wide range and to perform long range connections with them (from 50 to 200m).

    Bluetooth Module PRO for Arduino is used with a XBee shield to connect your Arduino in a Wireless Network through Bluetooth protocol. It comes with a 2dBi 2.4GHz Antenna. This configuration allows to create links up to 50m. Now you can use this technology in your projects for interact between several Arduinos and your smartphone to manage your hacks from a long distance. Make a domotic project in a wide area with the aid of this module.

    Tutorial: Bluetooth Module PRO for Arduino.
    Bluetooth Extreme USB dongle is used with your PC (Windows, Linux, Mac) to discover Bluetooth Devices. It comes with a 5dBi Antenna so now you will be able to monitor a Bluetooth Network (smartphones, Arduino, PCs...) through this protocol in a wide area and get a long range connection with them. You can also use it for proximity marketing. You will be able to send ads with this Extreme dongle to active bluetooth devices to promote your store.

    Tutorial: Bluetooth Extreme USB Dongle.

    Combine both Bluetooth devices to extend an Arduino Network and make Digital Art performances with them while interacts with other devices: smartphones, joysticks, gamepads...

    If you are looking for a cheaper solution to connect your Arduino to a Bluetooth device in a small range, you can be interested in our Bluetooth Module for Arduino.

    Tutorial: Bluetooth Module for Arduino.
  • Tutorial: Bluetooth Extreme USB DongleMay 23, 2012

    Introduction

    Bluetooth Extreme has been designed to make high performance and massive Bluetooth connections as it allows to discover up to 250 devices in a certain area, and to perform long range connections with them (up to 30 m with line of sight). It works in Linux, Windows and MacOS.

    Technical characteristics:

    • Chip: Bluegiga WT12
    • Bluetooth v2.1 + EDR. Class 2
    • TX Power: 7 Power levels [-27dBm, +3dBm]
    • RX sensitivity: -90 dBm
    • Antenna: SMA connector
    • Range: depending of the antenna
    • Received Strength Signal Indicator (RSSI)
    • Class of Device (CoD) for each scanned device

    There is a female SMA connector soldered onto the Bluetooth Extreme which allows the user to connect to an external 2.4 GHz antenna of their choice.

    1. LINUX

    Installation
    For using all the features described in this tutorial, you have to install the following programs in your Linux machine.

    • btscanner
    • bluez-hcidump

    $ sudo aptitude install btscanner bluez-hcidump

    Configure Bluetooth Extreme
    First of all, connect the USB dongle to PC and open a terminal window.

    Type “hciconfig” to see if your PC has correctly detected your bluetooth device.

    $ hciconfig

    If you have several bluetooth devices, the PC identifies them with the prefix “hci” (hci0, hci1...).

    Some of the following instructions may need to be root.

    - Configure bluetooth friendly name.
    To configure the friendly name of Bluetooth Extreme, type “hciconfig -a hciX name DesiredName”. hciX is the bluetooth device and DesiredName the friendly name.

    $ hciconfig -a hci0 name BtCookingHacks

    You can type “hciconfig -a hciX name” to check the bluetooth name configuration.

    - Configure bluetooth visibility.
    To make Bluetooth Extreme visible for inquiries, type “hciconfig -a hciX piscan”.

    $ hciconfig -a hci0 piscan

    Now you can scan and connect to Bluetooth Extreme from your Smartphone or any device with bluetooth radio.

    On the other hand, if you don't want to be visible for inquiries, type “hciconfig -a hciX noscan”.

    $ hciconfig -a hci0 noscan

    - Scan Bluetooth devices
    To scan remote bluetooth devices type “hcitool -i hciX scan”. All discovered devices will be listed with MAC address and friendly name.

    $ hcitool -i hci0 scan

    - Getting RSSI
    The command “hcidump” gives us a lot of information about bluetooth connections. For example to get the RSSI signal strength of each Bluetooth device.

    First, run hcidump program. In this case “hcidump -V > tmp/bluetoothpackets” launches hcidump with verbose decoding and stores the results in “tmp/bluetoothpackets”.

    $ hcidump -V > tmp/bluetoothpackets

    Second, launch a scan in parallel. hcidump program will read raw HCI data coming from and going to the Bluetooth device and stores it in the selected file.

    Next image shows an example of a hcidump file where you can identify the signal strength:

    In this example, RSSI is -40. Therefore, 'joki' Bluetooth device is quite near.

    - Getting CoD
    The stored hcidump file also allows us to identify the Class of Device:

    Focusing on the bits 8, 9 and 10 of the class we can identify the type of the bluetooth device.

    001 → Computer
    010 → Smartphone
    011 → LAN/Network AP
    100 → Handsfree
    ...

    In this example, 0x5A020C is 010110100000001000001100. Therefore, 'joki' Bluetooth device is a Smartphone.

    Create connection and send files.

    After a bluetooth scan is performed, you can make connections to those devices typing “hcitool -i hciX -cc MAC_ADDR”. MAC_ADDR is the MAC address of a discovered device.

    $ hcitool -i hci0 scan


    Once the bluetooth device is configured, a bluetooth icon appears in the top right corner of the screen (next to the clock). Click the bluetooth icon and select “Send files to device...”.

    Then select the file to send and press open.

    If you haven't created the connection before, the program will ask you for the destination bluetooth device.

    Finally, you will receive the file “logo.png” in your smartphone.

    2. WINDOWS

    Windows recognizes automatically Bluetooth Extreme. Therefore, you only have to connect the USB dongle to PC.

    There are many program in Windows to handle bluetooth features. Bluetooth assistant for Windows is good enough and easy to use.

    First, select Send a file or Receive a file and press Next.

    Then, select a discovered bluetooth device and press Accept.

    Then, select if you want to use a security key or not and press Next.

    Select the file to send and press Open.

    Finally, if everything went fine, you will see next image:

    3. MacOS

    As for Windows, MacOS detects automatically Bluetooth Extreme. Therefore, you only have to connect the USB dongle to PC.

    In this case, MacOS has an application to scan, send and receive data using the bluetooth device.

    For scanning and setting up bluetooth devices, go to System Preferences → Bluetooth

    Then select Set up New Device...

    And a list with the devices in the range will appear.

    Click Continue and you can set up the bluetooth device with the MAC to synchronize files or another features.

    For sending files, press the bluetooth icon that appears in the top right corner of the screen.

    Then select a file.

    And select a bluetooth device.

    Press Send and the file will be sent to the bluetooth device.

  • DIY Alarm with 3G/GPRS Shield for Arduino, Camera, Ultrasound Sensor, Keypad & RGB LedMay 16, 2012

    Arduteka launches its new tutorial!

    It reveals the new 3G/GPRS Shield for Arduino (3G+GPS) from Cooking Hacks. We are going to build a fun alarm that will send us a photo of our intruder directly to our mail, and let us know by a SMS to our mobile phone without a constant connection to the internet.

    Let's build a homemade alarm. We will scan continuously the space in front of you through the ultrasonic sensor, with a radius of approximately 30 °. When an object or person is in the field of action at a distance less than the established, it will sound an alarm, take a photograph, turn the RGB Led from green to blue (it will give you 10 seconds to deactivate the alarm through our matrix keyboard). If it is deactivated, it will turn again to scan the field. If not, it will play a loud sound and it will send a SMS to our mobile phone and a photography to our email.

    Read the full article here. (Spanish)

    Via: Arduino Blog, Source: Arduteka

  • Tutorial: Bluetooth module PRO for Arduino.May 15, 2012

    Introduction

    This tutorial describes some features of Bluetooth module PRO for Arduino which has been mainly designed to discover high amount of bluetooth devices in a variable area. Besides that, connection processes between two bluetooth modules are shown.
    It has to be mentioned that inquiry processes of bluetooth module are anonymous due to only MAC address is obtained from the bluetooth remote device. No account or phone numbers are obtained. These facts allows saving privacy of bluetooth users.

    Ingredients:

    Difficulty: Medium -medium
    Preparation Time: 20 minutes

    Steps Index

    Step 1: Bluetooth module PRO:

    Bluetooth module can be connected in a Xbee shield for Arduino.

    Technical characteristics:

    • Chip: Bluegiga WT12
    • Bluetooth v2.1 + EDR. Class 2
    • TX Power: 7 Power levels [-27dBm, +3dBm]
    • RX sensitivity: -90 dBm
    • Antenna: 2dBi
    • Range: from 10 to 50 meters depending tx power and environment conditions.
    • Received Strength Signal Indicator (RSSI) for each scanned device
    • Class of Device (CoD) for each scanned device

    Special features:
    Bluetooth module integrates a firmware called Iwrap, developed by manufacturer which offers many possibilities. Refer to link & documentation section for more information.
    Moreover, Libelium has developed a specific API to allow using this module with Waspmote. There are many useful functions which can be used as a guideline for other designs. Refer to Libelium web site for more information.

    Power consumption
    Bluetooth module has different power consumption according its operating state. Next table shows information about it.

    Estate Power consumption
    OFF 0
    Sleep < 0.5 mA
    ON (IDLE state) 2 mA
    Inquiry at minimum power 33.5 mA
    Inquiry at maximum power 36.5 mA

     

    Step 2 : Device discovery:

    For a device discovery example connect bluetooth module PRO in Gateway mode. An Arduino and a Xbee shield will be needed. Microcontroller (Atmega328) must be removed from Arduino to use it in gateway mode and also jumpers must be set to USB position.

    Using gateway mode, commands can be sent from our PC to bluetooth module. The module has and integrated firmware called IWRAP which allows several possibilities. See links & documentation section to see where you can find a description of all supported commands of bluetooth module and IWRAP firmware. Commands are not case sensitive.
    Once gateway is ready let's open a serial monitor (Cutecom in this case) and open serial port with parameters 38400 bps, 8 data bits,parity none and 1 stop bit. To test communication you can simply type “AT” command and “OK” will be returned.
    The command used to carry out a device discovery is “INQUIRY {timeout}”. Timeout can be a number between 1 and 48 and it will determine time spent searching for devices. The module will answer with a list of discovered devices as in shown in picture below.

    In this case, module has discovered three devices, showing each one in a different line with next data fields:

    • MAC address, which is a unique identification number of a bluetooth device. It has 12 hexadecimal digits separated by “:”. One example could be “12:34:56:aa:bb”.
    • CoD (Class of Device): Bluetooth devices are classified according to the device which they are integrated. Therefore a vehicle hands free device will belong to a different class than a pedestrian mobile phone. This parameter has 6 hexadecimal digit and it allows distinguish if detected bluetooth device is a vehicle, a pedestrian, and so on.
    • RSSI (Received Signal Strength Indicator): This parameters shows quality of the radio link. It can be used to know distance between bluetooth module and inquired device. It is shown as a negative value rounding -40 dBm (close devices) and -90 dBm (far devices)

    By default, bluetooth module PRO is in visible mode, so you are able to discover it with other bluetooth modules. If you want to change to NOT visible mode use command “SET BT PAGEMODE 0” and if you want to make it visible again just use “SET BT PAGEMODE 4”.
    If the user wants to know also “friendly name” of remote devices, the inquiry command must include “NAME” flag following timeout parameter, for instance “INQUIRY 5 NAME”, and name will be shown at the end of module response. Next image shows an example of it.

    It could be that a bluetooth device has friendly name property disabled, in this case bluetooth module will answer with an event like “NAME ERROR 0x104 {MAC} HCI_ERROR_PAGE_TIMEOUT”.
    If the user wants to stop inquiry processes in a certain moment, IC should be used (Inquiry Cancel). It can be useful for example to limit number of discovered devices. However, this command has to be used before summary is given by module, and name resolution processes can not be canceled.
    Furthermore, “SLEEP” command can be used to reduce power consumption of bluetooth module. It has to be taken into account that awaking module by UART will produce the lost of first byte sent, which is used to wake up the module. Other useful commands are “INFO” and “SET” which show information about module.
    There is another command which uses the internal temperature sensor of bluetooth module. It has no relevance in bluetooth actions but it can be used as a reference of the approximated temperature surrounded module. Just type “TEMP” command and temperature will be answered in Celsius degrees. Take into account that refresh rate of temperature sensor is not very high.

    Note: Pay attention when using configuration commands and always be sure of what you are doing. Otherwise bluetooth module can become unresponsive and blocked.

    Step 3 : Connecting Arduino to another Arduino without security.

    If the user wants to make a basic transparent link between two bluetooth modules, CALL command should be used. Destination address must be also included. Just connect the two bluetooth modules in gateway mode and open both serial monitors. Type on module 1 next command, with address of module 2:

    CALL 00:07:80:4b:2b:c4 1101 RFCOMM

    After sending this command you will see “CALL” event followed to link_ID of the call and “CONNECT” event on module 1 side and “RING” event on module 2 side. Next picture shows all this process carried out, whit module 1 serial monitor on the right and module 2 serial monitor on the left.
    After this events all data sent through each serial monitor will be sent to the other one. If the user want to send a command to module, escape sequence of “+++” must be sent (without end of line characters) and then module will be listening for commands. At the end, the call can be ended using “CLOSE” command followed with link_ID, and events NO CARRIER 0 and ERROR 0 will be received if everything is OK.

    (example code of an Arduino connecting with a bluetooth module in gateway mode and sending “hello word”)

    Step 4 : Connecting Arduino to another Arduino with security:

    Connecting with security means that a PIN code will be necessary to open a connection. If the user wants to connect two Arduino with bluetooth module PRO, next steps should be followed.
    First of all, same PIN code must be set in each module (in this example “1234”) using the command “SET BT AUTH * 1234”. This command saves PIN code into non-volatile memory of bluetooth module and enables security for all connections. PIN code length is configurable from 0 to 16 digit. If PIN code is set OK, same command will be returned. Also PIN code can be read using “SET” command. If the user wants to delete PIN code, it can be done with “SET BT AUTH * ” (with no pin code).
    After setting same PIN code on both sides, process is equal to previous section “connecting without security” except for one detail. Devices will be paired automatically if their connection is successful. This can be checked also using ”SET” command and reading line “SET BT PAIR ...”.
    However, pairing process can be done manually using “PAIR {MAC ADDR}” and the paired device will become into a trusted device (if bluetooth devices has same PIN code, or both have no pin code set). Next image shows how to set PIN code, enabling security and also how to pair a trusted device.
    After setting PIN code and pairing devices, just use “CALL” command as in previous section to open a transparent connection.

    Step 5 : Connecting Arduino to a PC without security:

    In this case, an standard bluetooth USB dongle will be connected with bluetooth module PRO inserted in Arduino (gateway mode). The PC runs under Linux.
    First of all, connect USB dongle to PC, open a terminal window and use “hcitool” to scan for bluetooth module PRO typing “hcitool scan”. All discovered devices will be listed with MAC address and friendly name. In this point can be seen if USB dongle is able to detect Arduino with bluetooth PRO module.
    After that, use “sdptool” to discover remote device services and channel used for RFCOMM, typing “sdptool search sp”. Search lines corresponding to Bluetooth PRO module and see rfcomm channel like in next picture.


    Then, open a connection with Bluetooth module typing command “rfcomm connect 0 {MAC_ADDR} {Channel}” and answer will show rfcomm port where USB is connected (rfcomm0 in this case).
    Finally, just go to a serial monitor and open port “\dev\rfcomm0”. Now there is a transparent connection between two bluetooth modules, as is shown below.

    Other useful hcitool commands are:

    • hcitool dev: shows hci devices connected to PC.
    • hcitool name {mac_addr}: shows name of given mac address.

    Moreover, “hciconfig” is also useful to configure some features of bluetooth modules. Some useful commands are:

    • hciconfig: show each hci device with its main features.
    • hciconfig hciX name Bluetooth_PRO: Set local device “X” name as bluetooth_PRO.
    • hciconfig hciX piscan: Makes device “X” visible for inquiries.

    Instead of using Arduino in gateway mode, you can upload a code like next one and see how to make a transparent connection.

    Step 6 : Connecting Arduino to a PC with security:

    This step can be carried out in same way as step 5 processes. The only difference is that bluetooth module Pro should have set a PIN code (using SET BT AUTH * {PIN_CODE}), and this code will be prompted when “sdptool search sd” is typed into a terminal. Just enter same PIN code and both devices will be paired automatically and you can continue as in step 5 to open a transparent connection.

    Fritzing Libraries:

    modules_fritzing

    Bluetooth module PRO for Arduino

    Downloaddownload

    Bluetooth Module PRO for Arduino has been mainly designed to discover high amount of bluetooth devices in a variable area. It can be connected in a Xbee shield for Arduino to work.

    You can download our Fritzing libraries from this area.


    Links and documentation:

    NOTE: If you are searching for Wireless Sensor Networks devices (motes) you may be interested in our ready to market sensor platform: Waspmote which counts with more than 50 sensors available to use.

  • New GPRS/GSM Quadband Module SIM900 for ArduinoApril 25, 2012

    gprs-sim900-arduino
    The new GPRS/GSM Quadband Module for Arduino (SIM900) offers GPRS connection to your Arduino board. It includes the SIM900 communication module from SIMCom. You can get it for only 63€.

    It is necessary an antenna in order to establish a communication.You can send SMS, make calls or create TCP and UDP sockets in order to send the information to the Internet. HTTP and FTP protocols are also available in order to send the information to the cloud directly from your Arduino.

    Differences between SIM900 and HiLo Modules
    - GPRS_SIM900 performs the same actions that GPRS HiLo module (some functions had been enhanced) and new functions has been added such as multiconnection for TCP/IP and UDP/IP clients, audio control or operator selection.
    - Regarding power consumption it has been reduced from 56µA to 30µA in power down mode (GPRS_OFF power mode).
    - The SIM900 module improves TCP/IP and UDP/IP connections adding new features such as TCP/IP server and multiconnection mode that allows up to 8 TCP/UDP clients or up to 7 TCP/UDP clients and 1 TCP/IP server. Extra functions such as autosending timer, add IP headers, setting DNS servers,... have been added.
    - Also uploading and downloading functions have been upgraded to allow to select the origin and destiny folder into the SD card and FTP server.
    - New functions allow to manage speaker level, Calling Line Identification (CLI) , mute, call alert. Also GSM/GPRS operator connection can be managed with functions such as get current operator, set preferred operator list, get cell information.

    You can read the full tutorial to work with this GPRS/GSM Quadband Module SIM900 for Arduino.

  • Tutorial: RFID 13.56 MHz / NFC Module for ArduinoApril 9, 2012

    Introduction

    RFID (Radio Frequency Identification) is a technology that uses electromagnetic fields to identify objects in a contactless way; it is also called proximity identification. There are 2 elements in RFID communications: the RFID module (or reader/writer device)
    and an RFID card (or tag). The RFID module acts as the master and the card acts as the slave; this means the module queries the card and sends instructions to it. In a normal RFID communication, the RFID module is fixed and the user takes his card near it when he needs to start the interaction.

    Ingredients:

    Cooking Hacks offers Mifare® Classic 1k cards tags, stickers and key rings along with the RFID/NFC module for Arduino. A Mifare® Classic 1k tag has 1024 bytes of internal storage capacity, divided into 16 sectors. Each sector is composed of 4 blocks, and each block is composed of 16 bytes. That is to say, each card has 64 blocks, from number 0 to 63. Blocks number 3, 7, 11 is called the sector trailer. This block stores the 2 keys or passwords and controls the access to the rest of the blocks in the sector.


    Difficulty: Medium -medium
    Preparation Time: 20 minutes

    Steps Index

    Step 1: Connecting the RFID/NFC module to Arduino:

    Setting up the hardware is very easy, just plug the XBee shield with the RFID/NFC module to Arduino. The jumpers in the XBee shield have to be set to XBEE position. Now you can program the Arduino and communicate it with the RFID/NFC module using the serial port (Serial.read(), Serial.print()...). Remember you must unplug the XBee shield when uploading code to Arduino.

    Step 2 : Reading tags (read only cards):

    In this part we show an example of the Arduino reading Mifare tags. We use the Auto Read mode. Arduino is waiting all the time, when a tag is detected, we read its code, and print the code over USB port.
    Arduino code:

    /*
      *  RFID/NFC module from Libelium for Arduino.
      *  This sketch authenticates and reads a block in a RFID tag
      *
      *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
      *  http://www.libelium.com
      *
      *  This program is free software: you can redistribute it and/or modify
      *  it under the terms of the GNU General Public License as published by
      *  the Free Software Foundation, either version 3 of the License, or
      *  (at your option) any later version.
      *
      *  This program is distributed in the hope that it will be useful,
      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      *  GNU General Public License for more details.
      *
      *  You should have received a copy of the GNU General Public License
      *  along with this program.  If not, see .
      *
      *  Version 0.1
      *  Author: Ahmad Saad, Javier Solobera
      */
    
    uint8_t dataRX[35];//Receive buffer.
    uint8_t dataTX[35];//Transmit buffer.
    uint8_t _UID[4];// stores the UID (unique identifier) of a card.
    uint8_t keyAccess[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } ;// stores the key or password.
    uint8_t address = 0x04;//Address to read.
    uint8_t ATQ[2];//Answer to request
    uint8_t state;//state of the process
    uint8_t aux[16];//Auxiliar buffer. 
    
    void setup()
    {
    	//Start serial port 115200 bps:
    	Serial.begin(115200);
    	delay(100);
    	Serial.print("RFID/NFC @ 13.56 MHz module started");
    	delay(1000);
    	//!It is needed to launch a simple command to sycnchronize
    	getFirmware();
    	configureSAM();
    }
    
    void loop()
    {
    	Serial.print("\n");
    	Serial.println("Ready to read...");
    	/////////////////////////////////////////////////////////////
    	//Get the UID Identifier
    	init(_UID, ATQ);
    	Serial.print("\n");
    	Serial.print( "The UID : ");
    	print(_UID , 4);
    	/////////////////////////////////////////////////////////////
    	//Auntenticate a block with his keyAccess
    	state = authenticate(_UID, address, keyAccess);
    	Serial.print("\n");
    
    	if ( state == 0) {
    		Serial.println("Authentication block OK");
    	} else {
    	Serial.println("Authentication failed");
    	}
    	/////////////////////////////////////////////////////////////
    	//Read from address after authentication
    	state = readData(address, aux);
    	Serial.print("\n");
    
    	if (state == 0) {
    		Serial.println("Read block OK");
    	} else {
    		Serial.println("Read failed");
    	}
    
    	Serial.print("\n");
    	Serial.print("Data readed : ");
    	print(aux , 16);
    	Serial.print("\n");
    	delay(2000);
    }
    //**********************************************************************
    //!The goal of this command is to detect as many targets (maximum MaxTg)
    // as possible in passive mode.
    uint8_t init(uint8_t *UID , uint8_t *ATQ)   //! Request InListPassive
    {
      Serial.flush();
    
    	dataTX[0] = 0x04; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x4A; // Code
    	dataTX[4] = 0x01; //MaxTarget
    	dataTX[5] = 0x00; //BaudRate = 106Kbps
    	dataTX[6] = 0x00; // Clear checkSum position
    	checkSum(dataTX); 
    
    	sendTX(dataTX , 7 ,23);
    
    	for (int i = 17; i < (21) ; i++){
    		_UID[i-17] = dataRX[i];
    	UID[i-17] = _UID[i-17];
    	}
    
    	ATQ[0] = dataRX[13];
    	ATQ[1] = dataRX[14];
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!A block must be authenticated before read and write operations
    uint8_t authenticate(uint8_t *UID, uint8_t blockAddress, uint8_t *keyAccess)
    {
    	dataTX[0] = 0x0F;
    	lengthCheckSum(dataTX);
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40; // inDataEchange
    	dataTX[4] = 0x01; //Number of targets
    	dataTX[5] = 0x60; // Authentication code
    	dataTX[6] = blockAddress;
    	for (int i = 0; i < 6 ; i++) {
    		dataTX[i + 7] = keyAccess[i];
    	}
    	dataTX[13] = UID[0];  dataTX[14] = UID[1];
    	dataTX[15] = UID[2];  dataTX[16] = UID[3];
    	dataTX[17] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 18 ,14);
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Write 16 bytes in address .
    uint8_t writeData(uint8_t address, uint8_t *blockData)  //!Writing
    {
    	Serial.print("                ");
    	dataTX[0] = 0x15;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40;//inDataEchange CODE
    	dataTX[4] = 0x01;//Number of targets
    	dataTX[5] = 0xA0;//Write Command
    	dataTX[6] = address; //Address		
    
    	for (int i = 0; i < 16; i++) {
    		dataTX[i+7] = blockData[i];
    	}
    
    	dataTX[23] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 24 ,14);		
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Read 16 bytes from  address .
    uint8_t readData(uint8_t address, uint8_t *readData) //!Reading
    {
    	Serial.print("                ");
    
    	dataTX[0] = 0x05;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // Code
    	dataTX[3] = 0x40; // Code
    	dataTX[4] = 0x01; // Number of targets
    	dataTX[5] = 0x30; //ReadCode
    	dataTX[6] = address;  //Read address
    	dataTX[7] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 8, 30);
    	memset(readData, 0x00, 16);  
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		for (int i = 12; i < 28; i++) {
    			readData[i-12] = dataRX[i];
    		}
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!The PN532 sends back the version of the embedded firmware.
    bool getFirmware(void)  //! It is needed to launch a simple command to sycnchronize
    {
      Serial.print("                ");
    
    	memset(dataTX, 0x00, 35);
    	dataTX[0] = 0x02; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // CODE
    	dataTX[3] = 0x02; //TFI
    	checkSum(dataTX); //0x2A; //Checksum   
    
    	sendTX(dataTX , 5 , 17);
    	Serial.print("\n");
    	Serial.print("Your Firmware version is : ");
    
    	for (int i = 11; i < (15) ; i++){
    		Serial.print(dataRX[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    
    //**********************************************************************
    //!Print data stored in vectors .
    void print(uint8_t * _data, uint8_t length)
    {
    	for (int i = 0; i < length ; i++){
    		Serial.print(_data[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    //**********************************************************************
    //!This command is used to set internal parameters of the PN532,
    bool configureSAM(void)//! Configure the SAM
    {
    	Serial.print("               ");
    
    	dataTX[0] = 0x05; //Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x14;
    	dataTX[4] = 0x01; // Normal mode
    	dataTX[5] = 0x14; // TimeOUT
    	dataTX[6] = 0x00; // IRQ
    	dataTX[7] = 0x00; // Clean checkSum position
    	checkSum(dataTX);
    
    	sendTX(dataTX , 8, 13);
    }
    //**********************************************************************
    //!Send data stored in dataTX
    void sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength)
    {
    	Serial.print(0x00, BYTE);
    	Serial.print(0x00, BYTE);
    	Serial.print(0xFF, BYTE); 
    
    	for (int i = 0; i < length; i++) {
    		Serial.print(dataTX[i], BYTE);
    	}
    
    	Serial.print(0x00, BYTE);
    	getACK();
    	waitResponse();// Receive response
    	getData(outLength);
    }
    //**********************************************************************
    //!Wait for ACK response and stores it in the dataRX buffer
    void getACK(void)
    {
    	delay(5);
    	waitResponse();
    	for (int i = 0; i < 5 ; i++) {
    		dataRX[i] = Serial.read();
    	}
    }
    //**********************************************************************
    //!Wait the response of the module
    void waitResponse(void)
    {
    	int val = 0xFF;
    	int cont = 0x00;
    	while(val != 0x00) { //Wait for 0x00 response
    		val = Serial.read();
    		delay(5);
    		cont ++;
    	}
    }
    //**********************************************************************
    //!Get data from the module
    void getData(uint8_t outLength)
    {
    	for (int i=5; i < outLength; i++) {
    		dataRX[i] = Serial.read();//read data from the module.
    	}
    }
    //**********************************************************************
    //!Calculates the checksum and stores it in dataTX buffer
    void checkSum(uint8_t *dataTX)
    {
    	for (int i = 0; i < dataTX[0] ; i++) {
    		dataTX[dataTX[0] + 2] += dataTX[i + 2];
    	}
    	byte(dataTX[dataTX[0] + 2]= - dataTX[dataTX[0] + 2]);
    }
    //**********************************************************************
    //!Calculates the length checksum and sotres it in the buffer.
    uint8_t lengthCheckSum(uint8_t *dataTX)
    {
    	dataTX[1] = byte(0x100 - dataTX[0]);
    }

    Here is the USB output using the Arduino IDE serial port terminal:

    Step 3 : Reading / writing Mifare tags.

    The next example for this module is the writing/reading of tags.
    Warning!!!
    Don't write address 0, 3, 7, 11, 15, ... if you are not an advanced user!!! You could leave your tag unaccesable.

    Each tag has some special blocks:

    • Address 0 - . It contains the IC manufacturer data. Due to security and system requirements this block has read-only access after having been programmed by the IC manufacturer at production.
    • Address 3, 7, 11... - Each sector has a sector trailer containing the secret keys A and B (optional), which return logical “0”s when read. Writing in them will change the access keys and access conditions!!!

    Arduino Code:

    /*
      *  RFID/NFC module from Libelium for Arduino.
      *  Basic program, read and write.
      *
      *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
      *  http://www.libelium.com
      *
      *  This program is free software: you can redistribute it and/or modify
      *  it under the terms of the GNU General Public License as published by
      *  the Free Software Foundation, either version 3 of the License, or
      *  (at your option) any later version.
      *
      *  This program is distributed in the hope that it will be useful,
      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      *  GNU General Public License for more details.
      *
      *  You should have received a copy of the GNU General Public License
      *  along with this program.  If not, see .
      *
      *  Version 0.1
      *  Author: Ahmad Saad, Javier Solobera
      */
    
    uint8_t dataRX[35];//Receive buffer.
    uint8_t dataTX[35];//Transmit buffer.
    uint8_t _UID[4]; // stores the UID (unique identifier) of a card.
    uint8_t blockData[] =	{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
    				0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F};//Data to write (16 bytes).
    uint8_t keyAccess[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} ;// stores the key or password.
    uint8_t address = 0x04;//Address to read.
    uint8_t ATQ[2];//Answer to request
    uint8_t state;//state of the process
    uint8_t aux[16];//Auxiliar buffer. 
    
    void setup()
    {
    	//Start serial port 115200 bps:
    	Serial.begin(115200);
    	delay(100);
    	Serial.print("RFID/NFC @ 13.56 MHz module started");
    	delay(1000);
    
    //! It is needed to launch a simple command to sycnchronize
    	getFirmware();
    	configureSAM();
    }
    void loop()
    {
    	Serial.print("\n");
    	Serial.println("Ready to read...");
    	/////////////////////////////////////////////////////////////
    	//Get the Card Identifier
    	init(_UID, ATQ);
    	Serial.print("\n");
    	Serial.print( "The Card NUID : ");
    	print(_UID , 4);
    	/////////////////////////////////////////////////////////////
    	//Auntenticate a block with his keyAccess
    	state = authenticate(_UID, address, keyAccess);
    	Serial.print("\n");
    
    	if ( state == 0) {
    		Serial.println("Authentication block OK");
    	} else {
    		Serial.println("Authentication failed");
    	}
    	/////////////////////////////////////////////////////////////
    	//Write blockData in a address, after authentication.
    	if ( state == 0 ) {
    		state = writeData(address, blockData);
    		Serial.print("\n");
    			if ( state == 0) {
    				Serial.println("Write block OK");
    			} else {
    				Serial.println("Write failed");
    			}
    	/////////////////////////////////////////////////////////////
    	//Read from address after authentication
    		state = readData(address, aux);
    		Serial.print("\n");
    
    		if (state == 0) {
    			Serial.println("Read block OK");
    		} else {
    			Serial.println("Read failed");
    		}
    
    		Serial.print("Data readed : ");
    		print(aux , 16);
    		Serial.print("\n");
    	}
       delay(2000);
    }
    //**********************************************************************
    //!The goal of this command is to detect as many targets (maximum MaxTg)
    // as possible in passive mode.
    uint8_t init(uint8_t *UID , uint8_t *ATQ)   //! Request InListPassive
    {
    	Serial.flush();
    
    	dataTX[0] = 0x04; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x4A; // Code
    	dataTX[4] = 0x01; //MaxTarget
    	dataTX[5] = 0x00; //BaudRate = 106Kbps
    	dataTX[6] = 0x00; // Clear checkSum position
    	checkSum(dataTX); 
    
    	sendTX(dataTX , 7 ,23);
    
    	for (int i = 17; i < (21) ; i++){
    		_UID[i-17] = dataRX[i];
    		UID[i-17] = _UID[i-17];
    	}
    
    	ATQ[0] = dataRX[13];
    	ATQ[1] = dataRX[14];
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
     //!A block must be authenticated before read and write operations
    uint8_t authenticate(uint8_t *UID, uint8_t blockAddress, uint8_t *keyAccess)
    {
    	dataTX[0] = 0x0F;
    	lengthCheckSum(dataTX);
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40; // inDataEchange
    	dataTX[4] = 0x01; //Number of targets
    	dataTX[5] = 0x60; // Authentication code
    	dataTX[6] = blockAddress;
    
    	for (int i = 0; i < 6 ; i++) {
    		dataTX[i + 7] = keyAccess[i];
    	}
    
    	dataTX[13] = UID[0];  dataTX[14] = UID[1];
    	dataTX[15] = UID[2];  dataTX[16] = UID[3];
    	dataTX[17] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 18 ,14);
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Write 16 bytes in address .
    uint8_t writeData(uint8_t address, uint8_t *blockData)  //!Writing
    {
    	Serial.print("                ");
    	dataTX[0] = 0x15;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40;  //inDataEchange CODE
    	dataTX[4] = 0x01;  //Number of targets
    	dataTX[5] = 0xA0; //Write Command
    	dataTX[6] = address; //Address		
    
    	for (int i = 0; i < 16; i++) {
    		dataTX[i+7] = blockData[i];
    	}
    
    	dataTX[23] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 24 ,14);  		
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Read 16 bytes from  address .
    uint8_t readData(uint8_t address, uint8_t *readData) //!Reading
    {
    	Serial.print("                ");		
    
    	dataTX[0] = 0x05;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // Code
    	dataTX[3] = 0x40; // Code
    	dataTX[4] = 0x01; // Number of targets
    	dataTX[5] = 0x30; //ReadCode
    	dataTX[6] = address;  //Read address
    	dataTX[7] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 8, 30);
    	memset(readData, 0x00, 16);  
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		for (int i = 12; i < 28; i++) {
    			readData[i-12] = dataRX[i];
    		}
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!The PN532 sends back the version of the embedded firmware.
    bool getFirmware(void)  //! It is needed to launch a simple command to sycnchronize
    {
    	Serial.print("                ");
    
    	memset(dataTX, 0x00, 35);
    	dataTX[0] = 0x02; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // CODE
    	dataTX[3] = 0x02; //TFI
    	checkSum(dataTX); //0x2A; //Checksum   
    
    	sendTX(dataTX , 5 , 17);
    	Serial.print("\n");
    	Serial.print("Your Firmware version is : ");
    
    	for (int i = 11; i < (15) ; i++){
    		Serial.print(dataRX[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    
    //**********************************************************************
    //!Print data stored in vectors .
    void print(uint8_t * _data, uint8_t length)
    {
    	for (int i = 0; i < length ; i++){
    		Serial.print(_data[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    //**********************************************************************
    //!This command is used to set internal parameters of the PN532,
    bool configureSAM(void)//! Configure the SAM
    {
    	Serial.print("               ");
    
    	dataTX[0] = 0x05; //Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x14;
    	dataTX[4] = 0x01; //Normal mode
    	dataTX[5] = 0x14; // TimeOUT
    	dataTX[6] = 0x00; // IRQ
    	dataTX[7] = 0x00; // Clean checkSum position
    	checkSum(dataTX);
    
    	sendTX(dataTX , 8, 13);
    }
    //**********************************************************************
    //!Send data stored in dataTX
    void sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength)
    {
    	Serial.print(0x00, BYTE);
    	Serial.print(0x00, BYTE);
    	Serial.print(0xFF, BYTE); 
    
    	for (int i = 0; i < length; i++) {
    		Serial.print(dataTX[i], BYTE);
    	}
    
    	Serial.print(0x00, BYTE);
    	getACK();
    	waitResponse();    // 1C - receive response
    	getData(outLength);
    }
    //**********************************************************************
    //!Wait for ACK response and stores it in the dataRX buffer
    void getACK(void)
    {
    	delay(5);
    	waitResponse();
    	for (int i = 0; i < 5 ; i++) {
    		dataRX[i] = Serial.read();
    	}
    }
    //**********************************************************************
    //!Wait the response of the module
    void waitResponse(void)
    {
    	int val = 0xFF;
    	int cont = 0x00;
    	while(val != 0x00) {
    		val = Serial.read();
    		delay(5);
    		cont ++;
    	}
    }
    //**********************************************************************
    //!Get data from the module
    void getData(uint8_t outLength)
    {
    	for (int i=5; i < outLength; i++) {
    		dataRX[i] = Serial.read(); // read data from the module.
    	}
    }
    //**********************************************************************
    //!Calculates the checksum and stores it in dataTX buffer
    void checkSum(uint8_t *dataTX)
    {
    	for (int i = 0; i < dataTX[0] ; i++) {
    		dataTX[dataTX[0] + 2] += dataTX[i + 2];
    	}
    	byte(dataTX[dataTX[0] + 2]= - dataTX[dataTX[0] + 2]);
    }
    //**********************************************************************
    //!Calculates the length checksum and sotres it in the buffer.
    uint8_t lengthCheckSum(uint8_t *dataTX)
    {
    	dataTX[1] = byte(0x100 - dataTX[0]);
    }

    Here is the USB output using the Arduino IDE serial port terminal.

    Step 4 : Changing the keys:

    This example changes the keys and access conditions in a sector and checks the block can be accessed with the new conditions.
    Warning!!!

    • Address 3, 7, 11, 15, ... contains the secret keys A and B (optional), which return logical “0”s when read. Write in them will change the access keys and access conditions!!!
    • You can change the keys, but we do not advise to change the access conditions

    Arduino code:

    /*
      *  RFID/NFC module from Libelium for Arduino.
      *
      *  This sketch changes the keys and access conditions in a
      *  block and checks the block can be accessed with the new conditions.
      *
      *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
      *  http://www.libelium.com
      *
      *  This program is free software: you can redistribute it and/or modify
      *  it under the terms of the GNU General Public License as published by
      *  the Free Software Foundation, either version 3 of the License, or
      *  (at your option) any later version.
      *
      *  This program is distributed in the hope that it will be useful,
      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      *  GNU General Public License for more details.
      *
      *  You should have received a copy of the GNU General Public License
      *  along with this program.  If not, see .
      *
      *  Version 0.1
      *  Author: Ahmad Saad, Javier Solobera
      */
    
    uint8_t dataRX[35];//Receive buffer.
    uint8_t dataTX[35];//Transmit buffer.
    //stores the status of the executed command:
    short state;
    //auxiliar buffer:
    unsigned char aux[16];
    //stores the UID (unique identifier) of a card:
    unsigned char _CardID[4];
    //stores the key or password:
    unsigned char keyOld[]= {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};// Old key access.
    unsigned char keyA[]= {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1};//NEW KEY ACCESS.
    unsigned char keyB[]= {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};//Secundary KEY ACCESS
    
    //only edit config if strong knowledge about the RFID/NFC module
    unsigned char config[] = {0xFF, 0x07, 0x80, 0x69};
    int address = 3;
    
    void setup()
    {
    	// start serial port 115200 bps:
    	Serial.begin(115200);
    	delay(100);
    
    	Serial.print("RFID/NFC @ 13.56 MHz module started");
     delay(1000);
    
    //! It is needed to launch a simple command to sycnchronize
    	getFirmware();
    	configureSAM();
    }
    
    void loop()
    {
    	Serial.print("\r\n++++++++++++++++++++++++++++++++++++");
    	// **** init the RFID/NFC reader
    	state = init(_CardID, aux);
    	if (aux[0] == aux[1]) {// if so, there is no card on the EM field
    		Serial.print("\r\nRequest error - no card found");
    	} else { // a card was found
    
    		Serial.print("\r\nRequest | Answer: ");
    		print(aux, 2);  //show the ATQ
    
    		Serial.print("\r\nAnticollSelect: ");
    		Serial.print(state, HEX);//show the status of the executed init command(should be 0)
    		Serial.print(" | Answer: ");
    		print(_CardID, 4); //show the UID (Unique IDentifier) of the read card (4 bytes)
    
    	//Write new key in block then authenticate this address and get the new value
    		state = setKeys(_CardID, keyOld, keyA, keyB, config, aux, address);
    		Serial.print("\r\n**write new key, state: ");
    		Serial.print(state, HEX);
    
    		if (state == 0) {
    			Serial.print(" --> correct key change ");
    		} else {
    			Serial.print(" --> ** ERROR: keys not changed ** ");
    		}	 // ###### check block 3/7/11/15 (the keys will return 0s)
    			// **** authenticate again, now with the new key A
    
    		state = authenticate(_CardID, address , keyA);
    		Serial.print("\r\n**Authentication block: ");
    		Serial.print(state, HEX);
    
    		if (state == 0) {
    			Serial.print(" --> correct authentication ");
    		}else {
    			Serial.print(" --> ** ERROR: bad authentication ** ");
    		}
    
    	}
    	delay(5000); // wait 10 seconds in each loop
    } 
    
    //**********************************************************************
    //!The goal of this command is to detect as many targets (maximum MaxTg)
    //  as possible in passive mode.
    uint8_t init(uint8_t *CardID , uint8_t *ATQ)   //! Request InListPassive
    {
      Serial.flush();
    
    	dataTX[0] = 0x04; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x4A; // Code
    	dataTX[4] = 0x01; //MaxTarget
    	dataTX[5] = 0x00; //BaudRate = 106Kbps
    	dataTX[6] = 0x00; // Clear checkSum position
    	checkSum(dataTX); 
    
    	sendTX(dataTX , 7 ,23);	
    
    	for (int i = 17; i < (21) ; i++){
    		_CardID[i-17] = dataRX[i];
    		CardID[i-17] = _CardID[i-17];
    	}
    
    	ATQ[0] = dataRX[13];
    	ATQ[1] = dataRX[14];
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x4B) & (dataRX[11] == 0x01)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
     //!A block must be authenticated before read and write operations
    uint8_t authenticate(uint8_t *CardID, uint8_t blockAddress, uint8_t *keyAccess)
    {
    	dataTX[0] = 0x0F;
    	lengthCheckSum(dataTX);
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40; // inDataEchange
    	dataTX[4] = 0x01; //Number of targets
    	dataTX[5] = 0x60; // Authentication code
    	dataTX[6] = blockAddress;
    	for (int i = 0; i < 6 ; i++) {
    		dataTX[i + 7] = keyAccess[i];
    	}
    	dataTX[13] = CardID[0];  dataTX[14] = CardID[1];
    	dataTX[15] = CardID[2];  dataTX[16] = CardID[3];
    	dataTX[17] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 18 ,14);
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Write 16 bytes in address .
    uint8_t writeData(uint8_t address, uint8_t *blockData)  //!Writing
    {
    	Serial.print("                ");
    	dataTX[0] = 0x15;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x40;  //inDataEchange CODE
    	dataTX[4] = 0x01;  //Number of targets
    	dataTX[5] = 0xA0; //Write Command
    	dataTX[6] = address; //Address		
    
    	for (int i = 0; i < 16; i++) {
    		dataTX[i+7] = blockData[i];
    	}
    
    	dataTX[23] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 24 ,14);  		
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!Read 16 bytes from  address .
    uint8_t readData(uint8_t address, uint8_t *readData) //!Reading
    {
    	Serial.print("                ");		
    
    	dataTX[0] = 0x05;
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // Code
    	dataTX[3] = 0x40; // Code
    	dataTX[4] = 0x01; // Number of targets
    	dataTX[5] = 0x30; //ReadCode
    	dataTX[6] = address;  //Read address
    	dataTX[7] = 0x00;
    	checkSum(dataTX);
    	sendTX(dataTX , 8, 30);
    	memset(readData, 0x00, 16);  
    
    	if ((dataRX[9]== 0xD5) & (dataRX[10] == 0x41) & (dataRX[11] == 0x00)) {
    		for (int i = 12; i < 28; i++) {
    			readData[i-12] = dataRX[i];
    		}
    		return 0;
    	} else {
    		return 1;
    	}
    }
    //**********************************************************************
    //!The PN532 sends back the version of the embedded firmware.
    bool getFirmware(void)  //! It is needed to launch a simple command to sycnchronize
    {
    	Serial.print("                ");		
    
    	memset(dataTX, 0x00, 35);
    	dataTX[0] = 0x02; // Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4; // CODE
    	dataTX[3] = 0x02; //TFI
    	checkSum(dataTX); //0x2A; //Checksum   
    
    	sendTX(dataTX , 5 , 17);
    	Serial.print("\n");
    	Serial.print("Your Firmware version is : ");
    
    	for (int i = 11; i < (15) ; i++){
    		Serial.print(dataRX[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    
    //**********************************************************************
    //!Print data stored in vectors .
    void print(uint8_t * _data, uint8_t length)
    {
    	for (int i = 0; i < length ; i++){
    		Serial.print(_data[i], HEX);
    		Serial.print(" ");
    	}
    	Serial.print("\n");
    }
    //**********************************************************************
    //!This command is used to set internal parameters of the PN532,
    bool configureSAM(void)//! Configure the SAM
    {
    	Serial.print("               ");
    
    	dataTX[0] = 0x05; //Length
    	lengthCheckSum(dataTX); // Length Checksum
    	dataTX[2] = 0xD4;
    	dataTX[3] = 0x14;
    	dataTX[4] = 0x01; //Normal mode
    	dataTX[5] = 0x14; // TimeOUT
    	dataTX[6] = 0x00; // IRQ
    	dataTX[7] = 0x00; // Clean checkSum position
    	checkSum(dataTX);
    
    	sendTX(dataTX , 8, 13);
    }
    //**********************************************************************
    //!Send data stored in dataTX
    void sendTX(uint8_t *dataTX, uint8_t length, uint8_t outLength)
    {
    	Serial.print(0x00, BYTE);
    	Serial.print(0x00, BYTE);
    	Serial.print(0xFF, BYTE); 
    
    	for (int i = 0; i < length; i++) {
    		Serial.print(dataTX[i], BYTE);
    	}
    
    	Serial.print(0x00, BYTE);
    	getACK();
    	waitResponse();    // 1C - receive response
    	getData(outLength);
    }
    //**********************************************************************
    //!Wait for ACK response and stores it in the dataRX buffer
    void getACK(void)
    {
    	delay(5);
    	waitResponse();
    	for (int i = 0; i < 5 ; i++) {
    		dataRX[i] = Serial.read();
    	}
    }
    //**********************************************************************
    //!Wait the response of the module
    void waitResponse(void)
    {
    	int val = 0xFF;
    	int cont = 0x00;
    	while(val != 0x00) {
    		val = Serial.read();
    		delay(5);
    		cont ++;
    	}
    }
    //**********************************************************************
    //!Get data from the module
    void getData(uint8_t outLength)
    {
    	for (int i=5; i < outLength; i++) {
    		dataRX[i] = Serial.read(); // read data from the module.
    	}
    }
    //**********************************************************************
    //!Calculates the checksum and stores it in dataTX buffer
    void checkSum(uint8_t *dataTX)
    {
    	for (int i = 0; i < dataTX[0] ; i++) {
    		dataTX[dataTX[0] + 2] += dataTX[i + 2];
    	}
      byte(dataTX[dataTX[0] + 2]= - dataTX[dataTX[0] + 2]);
    }
    //**********************************************************************
    //!Calculates the length checksum and sotres it in the buffer.
    uint8_t lengthCheckSum(uint8_t *dataTX)
    {
    	dataTX[1] = byte(0x100 - dataTX[0]);
    }
    //**********************************************************************
    //Changes both keys and access conditions to one card's sector
    uint8_t setKeys(uint8_t *CardID,uint8_t *keyOld,uint8_t *keyA,uint8_t *keyB,uint8_t *config,uint8_t *data,uint8_t add)
    {
    	uint8_t state = 1; 
    
    	if (((add+1) % 4) == 0){
    		state = authenticate(CardID , add, keyOld);
    		if (state == 0) {
    			for (int i = 0; i < 6; i++) {
    				data[i] = keyA[i];
    				data[i+ 10] = keyB[i];
    			}
    
    			for (int i = 0; i < 4 ; i++) {
    				data[i + 6] = config[i];
    			}
    			state = writeData(add, data);
    		}
    	}
    	return state;
    }

    Here is the USB output using the Arduino IDE serial port terminal:

    Fritzing Libraries:

     

    modules_fritzing

    RFID 13.56 MHz / NFC Module for Arduino

    Downloaddownload

    RFID 13.56 MHz / NFC Module for Arduino can be connected to Arduino using a XBee shield and will communicate it using the Arduino serial port (UART).

    You can download our Fritzing libraries from this area.

    Links:

    Datasheet
    Schematic
    User Manual

    NOTE: If you are searching for Wireless Sensor Networks devices (motes) you may be interested in our ready to market sensor platform: Waspmote which counts with more than 50 sensors available to use.

  • New Product: 3G/GPRS shield for Arduino (3G + GPS)March 20, 2012

    3G - GPRS - GPS - A-GPS Shield for Arduino

    The new 3G shield for Arduino enables the connectivity to high speed WCDMA and HSPA cellular networks in order to make possible the creation of the next level of worldwide interactivity projects inside the new "Internet of Things" era.

    The module counts also with an internal GPS what enables the location of the device outdoors and indoors combining standard NMEA frames with mobile cell ID triangulation using both assisted-mobile (A-GPS) and mobile-based (S-GPS) modes.

    There is a 3G Shield for Arduino (3G+GPS) + Audio / Video Kit available to make video-calls, use it as handsfree device or play your music like your smartphone.

    Features

    • WCDMA and HSPA 3G networks compatibility
    • Internal GPS for Assisted A-GPS and Supported S-GPS modes
    • Video Camera (640x480) for video and photo recordings available
    • Audio Kit including microphone, speaker, hands free and headphones available
    • SD file system up to 32GB
    • Works as a standard 3G modem in Linux/Windows/MacOS (~7.2Mbps download, ~5.5Mbps upload)
    • Talk directly to web servers by HTTP/HTTPS (secure)
    • Upload and download files directly by FTP/FTPS (secure)
    • Send and receive mails by POP3/SMTP
    • Play compressed audio files

    Read the full article here.

  • Components Kit arrives at Cooking Hacks!February 16, 2012

    Cooking Hacks launches the best tool for beginners: Components Kit includes all you need to start in electronics: resistors, capacitors, potentiometers, transistor, diodes, leds.... If you are looking for an essential box "all in one" to work with Arduino or make your own projects, this tool is the one you need. It is a good add-on for our current Arduino Starter Kits too.

    Resistors:
    x10 100 ohm
    x10 180 ohm
    x10 220 ohm
    x10 330 ohm
    x10 470 ohm
    x10 680 ohm
    x10 1 k
    x10 2k2
    x10 4k7
    x10 10 k
    x10 15 k
    x10 27 k
    x10 33 k
    x10 56 k
    x10 100 k
    x10 330 k
    x10 470 k
          Capacitors:
    x5 22 pf
    x5 47 pf
    x5 220 nf

    Electrolytic Capacitors:
    x5 1 uf
    x5 2.2 uf
    x5 4.7 uf
    x5 22 uf
    x5 47 uf
    x5 220 uf
    x5 470 uf

    Potentiometers:
    x2 1 k
    x2 10 k
    x2 100 k
    x2 1 M

          Diodes:
    x5 1N4001

    Octocouplers:
    x3 4N25

    Transistors:
    x5 BD-139 NPN
    x5 BD-140 PNP

    Leds:
    x10 5mm Red Led
    x10 5mm Green Led

    Speakers:
    x1 8 ohm 1/4W Mini Speaker

          Push Buttons:
    x10 12x12mm push buttons

    Wires:
    x1 Hook Up Wire Red
    x1 Hook Up Wire Black
    x1 Hook Up Wire Yellow

    Tools:
    x1 Flush Cutter
    x1 Mini Screwdriver

Items 41 to 50 of 74 total