Medsimo 1 Posted April 25, 2017 Share Posted April 25, 2017 hello !! Everything in order, it works. now what I need to know is, can I send float type data? If so, how? Quote Link to post Share on other sites
Medsimo 1 Posted April 25, 2017 Share Posted April 25, 2017 my code is : #include "NDEF.h" #include "NDEF_TXT.h" #include <RF430CL.h> #include <Wire.h> #define RF430CL330H_BOOSTERPACK_RESET_PIN 8 #define RF430CL330H_BOOSTERPACK_IRQ_PIN 12 RF430 nfc(RF430CL330H_BOOSTERPACK_RESET_PIN, RF430CL330H_BOOSTERPACK_IRQ_PIN); double randomDouble(double min, double max, int numCasas){ long _min = min * pow(10, numCasas) + 0.1; long _max = max * pow(10, numCasas) + 0.1; return (double) random(_min, _max) / pow(10, numCasas) ; } double Freq = randomDouble(10.71, 10.79, 2)+1839755.00; double voltage_1 = randomDouble(0.82, 0.88, 2); double temperature = randomDouble(18.30, 20.00, 2); double vol = randomDouble(3.10, 3.29, 2); void setup() { Serial.begin(115200); delay(1000); Serial.println("Initializing I2C and RF430CL330H-"); Wire.begin(); // Initialize I2C subsystem nfc.begin(); // Format RF430CL330H, prepare for data attachInterrupt(RF430CL330H_BOOSTERPACK_IRQ_PIN, wake_up, FALLING); // Register interrupt to wake MCU when RF430CL330H INTO (IRQ) line triggers Serial.println("Creating NFC NDEF_TXT object-"); String Value = "El valor actual de F_Tiva es de "; Value = Value + (Freq/1000000) + " MHz. El V_Tiva detectado es de " + voltage_1; Value = Value + ", la temperatura_Nodo1 es" + temperature + ", el voltaje_Nodo1 es" + vol; Value = Value + ", la temperatura_Nodo2 es" + temperature + ", el voltaje_Nodo2 es" + vol + ". El informe de estado del equipo ha terminado. Hasta pronto."; Serial.println("Posting to RF430CL330H-"); size_t ndef_size; ndef_size = Value.sendTo(nfc); // Write NDEF data to NFC device memory nfc.setDataLength(ndef_size); // Inform NFC device memory how much data is there Serial.println("Activating RF430CL330H RF link-"); nfc.enable(); // Now we're live! } void loop() { if (nfc.loop()) { if (nfc.wasRead()) { Serial.println("Something has read the NFC device!"); } if (nfc.available()) { Serial.println("Something has re-written the NFC device!"); nfc.flush(); } nfc.enable(); // If nfc.loop() returns true, it will have disabled the RF link as a side-effect. } Serial.println("<low power sleep>"); Serial.flush(); // wait for unsent UART data to flush out before going into low-power sleep suspend(); // Enter indefinite sleep (LPM4 on MSP430, DEEPSLEEP on ARM) Serial.println("<wake up>"); } void wake_up() { wakeup(); // Signal Energia to wake the MCU upon IRQ exit } I've errors .... nfc_1.cpp: In function 'void setup()': nfc_1.cpp:40:21: error: 'class String' has no member named 'sendTo' Value = Value + (Freq/1000000) + " MHz. El V_Tiva detectado es de " + voltage_1; ^ Quote Link to post Share on other sites
spirilis 1,265 Posted May 2, 2017 Author Share Posted May 2, 2017 On 4/25/2017 at 9:57 AM, Medsimo said: my code is : #include "NDEF.h" #include "NDEF_TXT.h" #include <RF430CL.h> #include <Wire.h> #define RF430CL330H_BOOSTERPACK_RESET_PIN 8 #define RF430CL330H_BOOSTERPACK_IRQ_PIN 12 RF430 nfc(RF430CL330H_BOOSTERPACK_RESET_PIN, RF430CL330H_BOOSTERPACK_IRQ_PIN); double randomDouble(double min, double max, int numCasas){ long _min = min * pow(10, numCasas) + 0.1; long _max = max * pow(10, numCasas) + 0.1; return (double) random(_min, _max) / pow(10, numCasas) ; } double Freq = randomDouble(10.71, 10.79, 2)+1839755.00; double voltage_1 = randomDouble(0.82, 0.88, 2); double temperature = randomDouble(18.30, 20.00, 2); double vol = randomDouble(3.10, 3.29, 2); void setup() { Serial.begin(115200); delay(1000); Serial.println("Initializing I2C and RF430CL330H-"); Wire.begin(); // Initialize I2C subsystem nfc.begin(); // Format RF430CL330H, prepare for data attachInterrupt(RF430CL330H_BOOSTERPACK_IRQ_PIN, wake_up, FALLING); // Register interrupt to wake MCU when RF430CL330H INTO (IRQ) line triggers Serial.println("Creating NFC NDEF_TXT object-"); String Value = "El valor actual de F_Tiva es de "; Value = Value + (Freq/1000000) + " MHz. El V_Tiva detectado es de " + voltage_1; Value = Value + ", la temperatura_Nodo1 es" + temperature + ", el voltaje_Nodo1 es" + vol; Value = Value + ", la temperatura_Nodo2 es" + temperature + ", el voltaje_Nodo2 es" + vol + ". El informe de estado del equipo ha terminado. Hasta pronto."; Serial.println("Posting to RF430CL330H-"); size_t ndef_size; ndef_size = Value.sendTo(nfc); // Write NDEF data to NFC device memory nfc.setDataLength(ndef_size); // Inform NFC device memory how much data is there Serial.println("Activating RF430CL330H RF link-"); nfc.enable(); // Now we're live! } void loop() { if (nfc.loop()) { if (nfc.wasRead()) { Serial.println("Something has read the NFC device!"); } if (nfc.available()) { Serial.println("Something has re-written the NFC device!"); nfc.flush(); } nfc.enable(); // If nfc.loop() returns true, it will have disabled the RF link as a side-effect. } Serial.println("<low power sleep>"); Serial.flush(); // wait for unsent UART data to flush out before going into low-power sleep suspend(); // Enter indefinite sleep (LPM4 on MSP430, DEEPSLEEP on ARM) Serial.println("<wake up>"); } void wake_up() { wakeup(); // Signal Energia to wake the MCU upon IRQ exit } I've errors .... nfc_1.cpp: In function 'void setup()': nfc_1.cpp:40:21: error: 'class String' has no member named 'sendTo' Value = Value + (Freq/1000000) + " MHz. El V_Tiva detectado es de " + voltage_1; ^ Allocate an NDEF_TXT object first instead of just composing your "Value" variable and trying to send it directly over the NFC: NDEF_TXT t("es", Value.c_str()); int ndef_size = t.sendTo(nfc); nfc.setDataLength(ndef_size) Note the first string in the NDEF_TXT constructor is the language code describing the language used for the text. Medsimo 1 Quote Link to post Share on other sites
Medsimo 1 Posted June 8, 2017 Share Posted June 8, 2017 Hello everyone. I've been working with the NFC module, and it worked. It sent data of an application of measures. I have connected with the TIVA 123GXL. Today I wanted to read data, And it no longer works. Is there any way to tell if the module does not transfer data? I connected an oscilloscope between the pins 14,15 (bridged with 9.10 respectively) of the I2C. and it show 3.2 V in the following figure. some help ? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.