Silicon ChipEl Cheapo modules Part 19 – Arduino NFC Shield - September 2018 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Streaming will make broadcast television obsolete
  4. Feature: Augmented GNSS promises accuracy down to mm! by Dr David Maddison
  5. Project: Dipole guitar/PA speaker without a box! by Allan-Linton Smith
  6. Project: Digital white noise generator by John Clarke
  7. Project: Steam loco or diesel engine sound effects module by John Clarke
  8. Subscriptions
  9. ElectroneX Feature by Ross Tester
  10. Product Showcase
  11. Serviceman's Log: The aircon that nearly made me lose my cool by Dave Thompson
  12. Project: Add wireless remote to your motorised garage door by Design by Branko Justic; words by Ross Tester
  13. Project: Super sound effects module – Part 2 by Tim Blythman & Nicholas Vinen
  14. Feature: El Cheapo modules Part 19 – Arduino NFC Shield by Jim Rowe
  15. Review: PICkit 4 in-circuit programmer by Tim Blythman
  16. Vintage Radio: The Ekco Gondola RM 204 Mantel Radio by Associate Professor Graham Parslow
  17. PartShop
  18. Market Centre
  19. Notes & Errata: Wide-range Digital LC Meter, June 2018; Notebook: Low-cost Automotive Ammeter, June 2018; El Cheapo Modules 16 – ADF4351 4.4GHz DCO, May 2018; 6GHz+ Touchscreen Frequency Counter, October-December 2017
  20. Advertising Index
  21. Outer Back Cover: Hare & Forbes MachineryHouse

This is only a preview of the September 2018 issue of Silicon Chip.

You can view 53 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "Dipole guitar/PA speaker without a box!":
  • Panel artwork for the Dipole Guitar Speaker (Free)
Items relevant to "Digital white noise generator":
  • PIC12F617-I/P programmed for the White Noise Generator [0910618A.HEX] (Programmed Microcontroller, AUD $10.00)
  • Firmware (ASM and HEX) files for the White Noise Source and Steam Train Whistle/Diesel Horn [0910618A/M.HEX] (Software, Free)
Items relevant to "Steam loco or diesel engine sound effects module":
  • Steam Train Whistle / Diesel Horn PCB [09106181] (AUD $5.00)
  • PIC12F617-I/P programmed for the White Noise Generator [0910618A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC12F617-I/P programmed for the Steam Train Whistle/Diesel Horn [0910618M.HEX] (Programmed Microcontroller, AUD $10.00)
  • Pair of PIC12F617-I/P chips for the Steam Train Whistle/Diesel Horn [0910618A/M.HEX] (Programmed Microcontroller, AUD $15.00)
  • TDA7052AT 1.1W audio amplifier IC (SOIC-8) (Component, AUD $3.00)
  • Firmware (ASM and HEX) files for the White Noise Source and Steam Train Whistle/Diesel Horn [0910618A/M.HEX] (Software, Free)
Items relevant to "Super sound effects module – Part 2":
  • Super Digital Sound Effects PCB [01107181] (AUD $2.50)
  • PIC32MM0256GPM028-I/SS programmed for the Super Digital Sound Effects Module [0110718A.hex] (Programmed Microcontroller, AUD $15.00)
  • Firmware (C and HEX) files for the Super Digital Sound Effects Module [0110718A.HEX] (Software, Free)
Articles in this series:
  • Miniature, high performance sound effects module (August 2018)
  • Miniature, high performance sound effects module (August 2018)
  • Super sound effects module – Part 2 (September 2018)
  • Super sound effects module – Part 2 (September 2018)
Items relevant to "El Cheapo modules Part 19 – Arduino NFC Shield":
  • Software for El Cheapo Modules: NFC Shield (Free)
Articles in this series:
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 1 (October 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 2 (December 2016)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules From Asia - Part 3 (January 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules from Asia - Part 4 (February 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 5: LCD module with I²C (March 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 6: Direct Digital Synthesiser (April 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules, Part 7: LED Matrix displays (June 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo Modules: Li-ion & LiPo Chargers (August 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo modules Part 9: AD9850 DDS module (September 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules Part 10: GPS receivers (October 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 11: Pressure/Temperature Sensors (December 2017)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 12: 2.4GHz Wireless Data Modules (January 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 13: sensing motion and moisture (February 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 14: Logarithmic RF Detector (March 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 16: 35-4400MHz frequency generator (May 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo Modules 17: 4GHz digital attenuator (June 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo: 500MHz frequency counter and preamp (July 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El Cheapo modules Part 19 – Arduino NFC Shield (September 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 20: two tiny compass modules (November 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El cheapo modules, part 21: stamp-sized audio player (December 2018)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 22: Stepper Motor Drivers (February 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules 23: Galvanic Skin Response (March 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Class D amplifier modules (May 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: Long Range (LoRa) Transceivers (June 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • El Cheapo Modules: AD584 Precision Voltage References (July 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • Three I-O Expanders to give you more control! (November 2019)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: “Intelligent” 8x8 RGB LED Matrix (January 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • El Cheapo modules: 8-channel USB Logic Analyser (February 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules (May 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • New w-i-d-e-b-a-n-d RTL-SDR modules, Part 2 (June 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital Volt/Amp Panel Meters (December 2020)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: Mini Digital AC Panel Meters (January 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: LCR-T4 Digital Multi-Tester (February 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD chargers (July 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: USB-PD Triggers (August 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 3.8GHz Digital Attenuator (October 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 6GHz Digital Attenuator (November 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: 35MHz-4.4GHz Signal Generator (December 2021)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • El Cheapo Modules: LTDZ Spectrum Analyser (January 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • Low-noise HF-UHF Amplifiers (February 2022)
  • A Gesture Recognition Module (March 2022)
  • A Gesture Recognition Module (March 2022)
  • Air Quality Sensors (May 2022)
  • Air Quality Sensors (May 2022)
  • MOS Air Quality Sensors (June 2022)
  • MOS Air Quality Sensors (June 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • PAS CO2 Air Quality Sensor (July 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Particulate Matter (PM) Sensors (November 2022)
  • Heart Rate Sensor Module (February 2023)
  • Heart Rate Sensor Module (February 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • UVM-30A UV Light Sensor (May 2023)
  • VL6180X Rangefinding Module (July 2023)
  • VL6180X Rangefinding Module (July 2023)
  • pH Meter Module (September 2023)
  • pH Meter Module (September 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 1.3in Monochrome OLED Display (October 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 16-bit precision 4-input ADC (November 2023)
  • 1-24V USB Power Supply (October 2024)
  • 1-24V USB Power Supply (October 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 0.91-inch OLED Screen (November 2024)
  • 14-segment, 4-digit LED Display Modules (November 2024)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • The Quason VL6180X laser rangefinder module (January 2025)
  • TCS230 Colour Sensor (January 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)
  • Using Electronic Modules: 1-24V Adjustable USB Power Supply (February 2025)

Purchase a printed copy of this issue for $10.00.

Using Cheap Asian Electronic Modules Part 19: by Jim Rowe Arduino FC Shield This low-cost NFC (Near-Field Communication) shield for Arduino uses the same technology as RFID and contactless payments (payWave/ PayPass). It allows just about any Arduino board to read data from NFC/RFID tags or cards or write data to certain devices. You can also exchange data with other NFC devices, including many smartphones. T his shield, plus an Arduino module, could be used as the basis for a number of useful devices, for example, to unlock a door using an access card, to monitor the passage of stock or other items on a conveyor belt, to transmit business card information to customers’ smartphones and so on. But before we explain how it works, we will explain how RFID and NFC work. NFC or Near-Field Communication is a set of protocols that enable two electronic devices to exchange data by bringing them within about 40mm of each other. Communication is by electromagnetic induction, ie, coupling signals between loop antennas in each device. In effect, when the two antennas are brought within 40mm of each other they form an air-cored RF transformer. NFC involves low-power RF signals with a carrier frequency of 13.56MHz, in one of the globally available and unlicensed ISM (industrial, scientific and medical) bands. One of the devices involved in NFC communication can be passive, ie, with no onboard power source. This is typically the case with RFID (radio-frequency identification) tags and smart cards. 86 Silicon Chip In this situation, the device that is powered powers the circuitry in the passive device via the energy of the 13.56MHz RF carrier. The passive device then “replies” by modulating the carrier, with the modulated signal picked up by the active device. RFID technology was developed in 1983 by Charles Walton. Sony and Philips agreed to establish a compatible specification and this was approved as an ISO/IEC standard in 2000 (ISO/IEC 14443). The passive tags and cards used for RFID typically store between 96 and 8192 bytes of data, which can be read (and in some cases, written) using the RFID protocol. Nokia, Philips and Sony established the NFC Forum in 2004. It is a nonprofit industry association which promotes the implementation and standardisation of NFC technology to ensure interoperability between devices and services. NFC provides the same functions as RFID but also allows for communications when both devices are powered. In this case, power is not transferred using the carrier and the two devices can exchange data in an ad-hoc peerto-peer fashion. The standard defining NFC is ISO/ IEC 18092. This technology is now Australia’s electronics magazine found in all manner of smartphones and other portable devices. Sony’s FeliCa RFID system includes dynamic encryption for increased security. It was considered as part of the ISO/IEC 14443 RFID standard but in the end, was not included. However, some of the principles used by FeliCa ended up being used as part of the later NFC standard. Three different data exchange rates are in current use by NFC devices: 106kb/s, 212kb/s and 424kb/s. If an active device transfers data at 106kb/s, it uses modified Miller coding with 100% modulation. Miller coding is a type of Modified Frequency Modulation known as “delay encoding”. This is similar to NRZ (non-return-to-zero) encoding but with less power radiated at lower frequencies. For the higher data rates, Manchester coding is used, with a modulation ratio of 10%. Manchester encoding is another method of turning a bitstream into a symmetrical AC signal and is also used for transmitting digital audio data (S/PDIF). Elecrow’s NFC shield The Elecrow ACS53201S NFC shield measures 69 x 53mm (including the loop antenna) and it plugs directly siliconchip.com.au Fig.1: simplified block diagram for the PN532 controller IC. The chip is based around four sections: an NXP 80C51 micro (an old design!), NFC communications block, serial block and power/clock/reset controller. into an Arduino Uno or Mega 2560, or one of the many compatible modules. It derives its power from the Arduino and even comes with a passive keyring NFC tag for testing (see lead photo). At the heart of the shield is the NXP/ Philips PN532 NFC controller IC. The internals of this IC are summarised in the simplified block diagram, Fig.1. It’s based around an NXP 80C51 microcontroller (upper right), which includes 1KB of RAM (working memory) and 40KB of ROM (for storing the firmware). The other main sections are the contactless interface unit or CIU (at lower right) which handles the actual NFC communication, and the host interface section at lower left which handles communication with the host computer or controller (in this case, the Atmel micro on the Arduino board). The host interface section can be configured to communicate via SPI (serial peripheral interface), I2C (inter-IC serial communication) or a high-speed UART (HSU; ie, serial) connection. But note that the PN532 chip used in the Elecrow NFC shield has been configured for SPI only. Fig.2 shows the full circuit of the Elecrow NFC shield, plus a block diagram of an Arduino host at upper left. siliconchip.com.au The PN532 device, IC1, connects to the NFC loop antenna at top right via the TX1, TX2 and RX pins and a network of passive components. These include inductors L1, L2 and various capacitors and a few resistors. These are used for impedance matching, to make the antenna resonant at the required frequency and to filter out unwanted signals. IC1 uses 27.12MHz crystal X1 to generate its internal master clock and divides this by a factor of two to pro- duce the NFC carrier frequency of 13.56MHz. Although IC1 can operate from supply voltages of 2.7-5.5V, in the Elecrow shield it is powered from a 3.3V regulated supply. This is derived from the Arduino’s 5V supply via REG1, an MIC5205-3.3 LDO (low dropout) regulator. This is separate from the 3.3V rail from the Arduino since IC1 can draw up to 200mA when transmitting, which could overload the regulator on the Arduino. This means that level translation is necessary on the SPI signal lines between IC1 and the Arduino. That’s provided by IC2, a 74LV4T125 quad buffer translator. Three of IC2’s buffers are used to translate the logic levels of the MOSI, SCK and MISO signal lines, with the fourth buffer unused. IC2 is also powered from the +3.3V supply from REG1. The only other components on the board are a number of bypass and filter capacitors for IC1, IC2 and REG1, a pull-up resistor on pin 38 of IC1 to enable it and a capacitor and resistor connected to the Vmid pin of IC1 (pin 9), which is used to DC bias its RX pin (pin 10) to half supply. Note that Jaycar sell a similar NFC Shield, made by “linksprite” (Cat XC4542). While not identical to the Elecrow shield, it is compatible and we have tested it successfully with the same software. Arduino software Luckily Elecrow has made the software side of things quite easy by making available an Arduino library written specifically for communicating with the PN532 via the SPI port. The library can be downloaded from the Elecrow website The NFC shield easily slots into an Arduino Mega or Uno, as shown in Fig.2. Australia’s electronics magazine September 2018  87 Fig.2: complete circuit diagram for the Elecrow ACS53201S near-field communication (NFC) shield, and wiring diagram for the shield with an Arduino, or similar, board. Screen 1: using the readMiFareMemory.ino sketch reads and then prints the data from the RFID card and keytag. 88 Silicon Chip Screen 2: the readAllMemoryBlocks.ino sketch reads the card’s memory after writing 16 bytes into it (to block 8). Australia’s electronics magazine siliconchip.com.au Fig.3: wiring diagram for a Micromite to the Elecrow NFC shield. We’ve converted the Arduino NFC library into a BASIC library so that you can use it with the Micromite. The library can be downloaded from the Silicon Chip website. S53201S NFC shield would be to modify one of the example sketches. Or if you’re doing something fairly complex (eg, which involves both reading and writing data), you may need to incorporate bits and pieces of the example sketches into your own sketch. If you want to fully understand how to use the PN532_ SPI library functions, it is simply a matter of studying the example sketches to see how they operate. Using it with a Micromite in a zip file called PN532_SPI.zip (see Links panel). This can be made available for use in the Arduino IDE by clicking on the Sketch menu and then on the Include Library → Add .ZIP Library menu option. Select the ZIP file that you have downloaded and it will be added to the IDE’s library list. The library comes with six example sketches, named: writeMifareMemory readMifareTargetID readMifareMemory readAllMemoryBlocks PtoPTarget PtoPInitiator siliconchip.com.au “Mifare” is another way of referring to passive NFC tags and cards. The “PtoP” part of the last two sketch titles is short for “peer to peer” and indicates that these sketches are used for NFC communication between two active devices. I tried opening and running the first four of these example sketches with the Elecrow NFC shield connected to both an Arduino Uno and a Mega 2560. In each case, I tested it with both the keyring tag that came with the shield and also with an NFC card that came with another NFC/RFID reader. In each case, it worked exactly as expected and I was able to read data from and write data to both passive devices with no problems. You can get an idea of how the example sketches work from the adjacent screen grabs. Both grabs are of the Arduino IDE’s Serial Monitor. Screen 1 shows the output when reading the card first and then the keyring tab, using the readMifareMemory sketch. Screen 2 shows the results when using the readAllMemoryBlocks sketch to interrogate the card after using the writeMifareMemory sketch to write 16 bytes into the card’s memory (to block 8). The easiest way to build your own application using the Elecrow ACAustralia’s electronics magazine What if you want to use the shield with another MCU, like a Micromite? Since it has a standard SPI port, it’s quite easy to make the required connections, as shown in Fig.3. The software is a bit more tricky though since there was no Micromite library available to interface with the PN532 IC. So, we have translated the Arduino library into a Micromite BASIC file and have made this available for download from our website (free for subscribers). We have also translated some of the example programs. The download package includes several BASIC files which all start with an identical set of library functions but have different sample code snippets at the bottom. Having wired up the shield as shown in Fig.3, it’s simply necessary to upload one of these programs to the Micromite and run it. You should see similar output on the Micromite serial console as shown in the screen grabs above. Extra links NFC Forum: https://nfc-forum.org/ PN532 data sheet: siliconchip.com. au/link/aakl PN532 user manual: siliconchip. com.au/link/aakm How to use the PN532: siliconchip. com.au/link/aakn Elecrow shield library: siliconchip. SC com.au/link/aako September 2018  89