/***** DONT Listen to Adafruit.com. This runs fine on an arduino uno R3. 40% mem use.**/ /***************************************************************************** * How to use this sketch * * This sketch uses the I2C interface to communicate with the NFC device. * It writes an NFC tag type URI (Uniform Resource Identifier). * Choose the uri by changing the content of uri_write. * * When the NFC module is started and ready, the message "Sytstem init done!" is * displayed on the monitor window. Next, the tag is written with the content * printed on the monitor window. * * You can use your smartphone to read the tag. * On Android, check if NFC is activated on your smartphone. * Put your smartphone near the tag to natively read it. * The preferred Internet Browser is automatically opened with the provided URI. ****************************************************************************** */ #include "ST25DVSensor.h" #define SerialPort Serial #define GPO_PIN 7 //GPO pin on chip can detect scans #if defined(ARDUINO_B_L4S5I_IOT01A) // Pin definitions for board B-L4S5I_IOT01A #define GPO_PIN PE4 #define LPD_PIN PE2 #define SDA_PIN PB11 #define SCL_PIN PB10 #define WireNFC MyWire TwoWire MyWire(SDA_PIN, SCL_PIN); ST25DV st25dv(12, -1, &MyWire); #else #define DEV_I2C Wire ST25DV st25dv(12, -1, &DEV_I2C); #endif void setup() { const char uri_write_message[] = "nyle.com"; // Uri message to write in the tag const char uri_write_protocol[] = URI_ID_0x01_STRING; // writes https://wwww into the msg String uri_write = String(uri_write_protocol) + String(uri_write_message); //String uri_write = String(uri_write_message); // Initialize serial for output. pinMode(GPO_PIN, INPUT); SerialPort.begin(115200); // The wire instance used can be omitted in case you use default Wire instance if(st25dv.begin() == 0) { SerialPort.println("System Init done!"); SerialPort.println(uri_write); } else { SerialPort.println("System Init failed!"); while(1); } if(st25dv.writeURI(uri_write, uri_write_message, "")) { SerialPort.println("Write failed!"); while(1); } digitalWrite(GPO_PIN, LOW); //makes sure IO is low delay(1000); } int count = 0; void loop() { // when it reads, it hits multiple times. one scan might itterate the counter by 10 or more times. if (digitalRead(GPO_PIN) == HIGH) { count +=1; Serial.print("NFC tag accessed "); Serial.print(count); Serial.println(" times"); digitalWrite(GPO_PIN, LOW); delay(1000); } else { ; } } /***** DONT Listen to Adafruit.com. This runs fine on an arduino uno R3. 40% mem use. ****************************************************************************** * @file ST25DV_SimpleWrite.ino * @author STMicroelectronics * @version V1.0.0 * @date 22 November 2017 * @brief Arduino test application for the STMicrolectronics * ST25DV NFC device. * This application makes use of C++ classes obtained from the C * components' drivers. ****************************************************************************** * @attention * *