|
1 |
| -## Accelerometer_ADXL335 [](https://travis-ci.com/Seeed-Studio/Accelerometer_ADXL335) |
| 1 | +# NFC library |
2 | 2 |
|
3 |
| -<img src="https://statics3.seeedstudio.com/images/P2241478.JPG" width=auto> |
| 3 | +This is an library for PN532 to use NFC technology. |
| 4 | +It is for [NFC Shield](https://www.seeedstudio.com/NFC-Shield-V2-0.html) and [Grove - NFC](https://www.seeedstudio.com/Grove-NFC.html). |
4 | 5 |
|
5 |
| -[Grove 3-Axis Analog Accelerometer](https://www.seeedstudio.com/Grove-3Axis-Analog-Accelerometer-p-1086.html) |
| 6 | +[](https://www.seeedstudio.com/NFC-Shield-V2-0.html) |
| 7 | +[](https://www.seeedstudio.com/Grove-NFC.html) |
6 | 8 |
|
7 |
| -The ADXL335 is a small, thin, low power, complete 3-axis accelerometer with signal conditioned voltage outputs. The product measures acceleration with a minimum full-scale range of ±3 g. |
8 |
| -The module was designed as breakout board because ADXL335's signal is analog( more ports requested ). But the board outline is grove module that you can fix it conveniently like other groves. The sensor combined 3.3 and 5V power supply,can be used in standard arduino device and seeduino stalker. The following program code includes first-order filter which can make the output smoothly if the sensor was used in robot or toy car. |
| 9 | +## Features |
9 | 10 |
|
10 |
| -For more information, please refer to [Grove - 3-Axis Analog Accelerometer wiki](http://wiki.seeedstudio.com/Grove-3-Axis_Analog_Accelerometer/) |
| 11 | +- Support all interfaces of PN532 (I2C, SPI, HSU) |
| 12 | +- Read/write Mifare Classic Card |
| 13 | +- Works with [Don's NDEF Library](https://github.com/don/NDEF) |
| 14 | +- Communicate with android 4.0+([Lists of devices supported](https://github.com/Seeed-Studio/PN532/wiki/List-of-devices-supported)) |
| 15 | +- Support [mbed platform](https://os.mbed.com/teams/Seeed/code/PN532/) |
| 16 | +- Card emulation (NFC Type 4 tag) |
11 | 17 |
|
12 |
| ----- |
13 |
| -This software is written by Frankie Chu for seeed studio<br> |
14 |
| -and is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Check License.txt for more information.<br> |
| 18 | +## To Do |
15 | 19 |
|
16 |
| -Contributing to this software is warmly welcomed. You can do this basically by<br> |
17 |
| -[forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above<br> |
18 |
| -for operating guide). Adding change log and your contact into file header is encouraged.<br> |
19 |
| -Thanks for your contribution. |
| 20 | +- To support more than one INFO PDU of P2P communication |
| 21 | +- To read/write NFC Type 4 tag |
20 | 22 |
|
21 |
| -Seeed is a hardware innovation platform for makers to grow inspirations into differentiating products. By working closely with technology providers of all scale, Seeed provides accessible technologies with quality, speed and supply chain knowledge. When prototypes are ready to iterate, Seeed helps productize 1 to 1,000 pcs using in-house engineering, supply chain management and agile manufacture forces. Seeed also team up with incubators, Chinese tech ecosystem, investors and distribution channels to portal Maker startups beyond. |
| 23 | +## Getting Started |
22 | 24 |
|
| 25 | +### Using Arduino IDE |
23 | 26 |
|
| 27 | +1. Download [zip file](https://github.com/Seeed-Studio/PN532/archive/refs/heads/arduino.zip), extract it into Arduino's libraries and rename it to PN532-Arduino. |
| 28 | +2. Download [Don's NDEF library](https://github.com/don/NDEF/archive/refs/heads/master.zip), extract it into Arduino's libraries and rename it to NDEF. |
| 29 | +3. Add the `NFC_INTERFACE_<interface>` build flag to your build system or define it in your code using `#define NFC_INTERFACE_<interface>` like |
24 | 30 |
|
| 31 | + ```cpp |
| 32 | + #define NFC_INTERFACE_I2C |
| 33 | + ``` |
25 | 34 |
|
26 |
| -[](https://github.com/igrigorik/ga-beacon) |
| 35 | +4. Follow the examples of the two libraries. |
27 | 36 |
|
| 37 | +### PlatformIO library |
28 | 38 |
|
| 39 | +Add `https://github.com/Seeed-Studio/PN532.git` to your `lib_deps` variable in `platformio.ini` like so. This library will automatically include Don's NDEF library as well. |
| 40 | + |
| 41 | +``` |
| 42 | +lib_deps = |
| 43 | + https://github.com/Seeed-Studio/PN532.git |
| 44 | +``` |
| 45 | + |
| 46 | +> ⚠️ Besides using the correct `PN532_<interface>.h` include file, you have to add `-DNFC_INTERFACE_<interface>` to `build_flags` to select what interface you want to use. This is done to prevent requiring unnecessary dependencies on e.g. `SoftwareSerial` or `SPI` when you are not using those interfaces. |
| 47 | +
|
| 48 | +``` |
| 49 | +build_flags = |
| 50 | + -DNFC_INTERFACE_HSU |
| 51 | +``` |
| 52 | + |
| 53 | +### Git way for Linux/Mac (recommended) |
| 54 | + |
| 55 | +1. Get PN532 library and NDEF library |
| 56 | + |
| 57 | + cd {Arduino}\libraries |
| 58 | + git clone --recursive https://github.com/Seeed-Studio/PN532.git NFC |
| 59 | + git clone --recursive https://github.com/don/NDEF.git NDEF |
| 60 | + ln -s NFC/PN532 ./ |
| 61 | + ln -s NDEF/NDEF ./ |
| 62 | + |
| 63 | +1. Add the `NFC_INTERFACE_<interface>` build flag to your build system or define it in your code using `#define NFC_INTERFACE_<interface>` like |
| 64 | + |
| 65 | + ```cpp |
| 66 | + #define NFC_INTERFACE_I2C |
| 67 | + ``` |
| 68 | + |
| 69 | +1. Follow the examples of the two libraries |
| 70 | + |
| 71 | +## Interfaces |
| 72 | + |
| 73 | +This library offers four ways to interface with the PN532 board: |
| 74 | + |
| 75 | +- `HSU` (High Speed Uart) |
| 76 | +- `I2C` |
| 77 | +- `SPI` |
| 78 | +- `SWHSU` (Software-based High Speed Uart) |
| 79 | + |
| 80 | +Read the section for the interface you want to use. |
| 81 | + |
| 82 | +> Make sure to add the `PN532_<interface>.h` include file and the `NFC_INTERFACE_<interface>` define to your code like the example below: |
| 83 | + |
| 84 | +```cpp |
| 85 | +#define NFC_INTERFACE_HSU |
| 86 | + |
| 87 | +#include <PN532_HSU.h> |
| 88 | +#include <PN532.h> |
| 89 | +``` |
| 90 | + |
| 91 | +## HSU Interface |
| 92 | + |
| 93 | +HSU is short for High Speed Uart. HSU interface needs only 4 wires to connect PN532 with Arduino, [Sensor Shield](http://goo.gl/i0EQgd) can make it more easier. For some Arduino boards like [Leonardo][leonardo], [DUE][due], [Mega][mega] ect, there are more than one `Serial` on these boards, so we can use this additional Serial to control PN532, HSU uses 115200 baud rate. |
| 94 | + |
| 95 | +To use the `Serial1` control PN532, refer to the code below. |
| 96 | + |
| 97 | +```c++ |
| 98 | +#define NFC_INTERFACE_HSU |
| 99 | + |
| 100 | +#include <PN532_HSU.h> |
| 101 | +#include <PN532.h> |
| 102 | + |
| 103 | +PN532_HSU pn532hsu(Serial1); |
| 104 | +PN532 nfc(pn532hsu); |
| 105 | + |
| 106 | +void setup(void) |
| 107 | +{ |
| 108 | + nfc.begin(); |
| 109 | + //... |
| 110 | +} |
| 111 | +``` |
| 112 | +
|
| 113 | +If your Arduino has only one serial interface and you want to keep it for control or debugging with the Serial Monitor, you can use the [`SoftwareSerial`][softwareserial] library to control the PN532 by emulating a serial interface. Include `PN532_SWHSU.h` instead of `PN532_HSU.h`: |
| 114 | +
|
| 115 | +```c++ |
| 116 | +#define NFC_INTERFACE_SWHSU |
| 117 | +
|
| 118 | +#include <SoftwareSerial.h> |
| 119 | +#include <PN532_SWHSU.h> |
| 120 | +#include <PN532.h> |
| 121 | +
|
| 122 | +SoftwareSerial SWSerial( 10, 11 ); // RX, TX |
| 123 | +
|
| 124 | +PN532_SWHSU pn532swhsu( SWSerial ); |
| 125 | +PN532 nfc( pn532swhsu ); |
| 126 | +
|
| 127 | +void setup(void) |
| 128 | +{ |
| 129 | + nfc.begin(); |
| 130 | + //... |
| 131 | +} |
| 132 | +``` |
| 133 | + |
| 134 | +## Attribution |
| 135 | + |
| 136 | +This library is based on [Adafruit_NFCShield_I2C](https://github.com/adafruit/Adafruit_NFCShield_I2C). |
| 137 | +[Seeed Studio](hhttps://www.seeedstudio.com/) rewrite the library to make it easy to support different interfaces and platforms. |
| 138 | +[@Don](https://github.com/don) writes the [NDEF library](https://github.com/don/NDEF) to make it more easy to use. |
| 139 | +[@JiapengLi](https://github.com/JiapengLi) adds HSU interface. |
| 140 | +[@awieser](https://github.com/awieser) adds card emulation function. |
| 141 | + |
| 142 | +[mega]: http://arduino.cc/en/Main/arduinoBoardMega |
| 143 | +[due]: http://arduino.cc/en/Main/arduinoBoardDue |
| 144 | +[leonardo]: http://arduino.cc/en/Main/arduinoBoardLeonardo |
| 145 | +[softwareserial]: https://www.arduino.cc/en/Reference/softwareSerial |
0 commit comments