I have a PN532 RFID reader that I need to connect a NodeMCU that has a ESP8266.
The situation is that the code compiles, uploads but the NodeMCu doesn't recognise the board. I used the sample code from the library got the same results from then I tried makin adjustments and still nothing
I was concerned that the PN532 wasn't working so i tested it on a arduino Mega 2560 and it worked flawlessly with the same code. I also tried reflashing the chip to make sure it works, changing the code, I changed up the wiring at least 15 times. Tried many pin combinations and it still didn't work.
The code is the sample from the library but here it is
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <Adafruit_I2CDevice.h>
// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SCK (14)
#define PN532_MOSI (13)
#define PN532_SS (5)
#define PN532_MISO (12)
// Use this line for a breakout with a software SPI connection (recommended):
// Adafruit_PN532 nfc(PN532_SS);
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
void setup(void) {
Serial.begin(115200);
Serial.println("Hello!\n");
Serial.println("Hello!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.println("Didn't find PN53x board");
delay(100); // usually there would be a wait(1) but it messed the nodemcu up...
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}
void loop(void) {
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
// Display some basic information about the card
Serial.println("Found an ISO14443A card");
Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print(" UID Value: ");
nfc.PrintHex(uid, uidLength);
Serial.println("");
if (uidLength == 4)
{
// We probably have a Mifare Classic card ...
Serial.println("Seems to be a Mifare Classic card (4 byte UID)");
// Now we need to try to authenticate it for read/write access
// Try with the factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Serial.println("Trying to authenticate block 4 with default KEYA value");
uint8_t keya[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
// Start with block 4 (the first block of sector 1) since sector 0
// contains the manufacturer data and it's probably better just
// to leave it alone unless you know what you're doing
success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, keya);
if (success)
{
Serial.println("Sector 1 (Blocks 4..7) has been authenticated");
uint8_t data[16];
// If you want to write something to block 4 to test with, uncomment
// the following line and this text should be read back in a minute
//memcpy(data, (const uint8_t[]){ 'a', 'd', 'a', 'f', 'r', 'u', 'i', 't', '.', 'c', 'o', 'm', 0, 0, 0, 0 }, sizeof data);
// success = nfc.mifareclassic_WriteDataBlock (4, data);
// Try to read the contents of block 4
success = nfc.mifareclassic_ReadDataBlock(4, data);
if (success)
{
// Data seems to have been read ... spit it out
Serial.println("Reading Block 4:");
nfc.PrintHexChar(data, 16);
Serial.println("");
// Wait a bit before reading the card again
delay(1000);
}
else
{
Serial.println("Ooops ... unable to read the requested block. Try another key?");
}
}
else
{
Serial.println("Ooops ... authentication failed: Try another key?");
}
}
if (uidLength == 7)
{
// We probably have a Mifare Ultralight card ...
Serial.println("Seems to be a Mifare Ultralight tag (7 byte UID)");
// Try to read the first general-purpose user page (#4)
Serial.println("Reading page 4");
uint8_t data[32];
success = nfc.mifareultralight_ReadPage (4, data);
if (success)
{
// Data seems to have been read ... spit it out
nfc.PrintHexChar(data, 4);
Serial.println("");
// Wait a bit before reading the card again
delay(1000);
}
else
{
Serial.println("Ooops ... unable to read the requested page!?");
}
}
}
}
Here is the pictures of the circuit:
https://ibb.co/6sk6kGf
https://ibb.co/3vZc88h
https://ibb.co/JzcJkKg
I am really desperate at the moments I will accept any help and I will post all the information if something more is needed.
Thank you
Related
I have bought a "APDS-9930" ambient light sensor, which communicates over I2C (TWI) protocol. I intend to read the the ambient light level from it, using ARDUINO Mega2560 development board. As I searched the net, I found a modified ARDUINO library, based on APDS-9960, which claims to work with APDS-9930 on ARDUINO UNO. However, when used with Mega2560, It gives me "Error initializing" error. Does anyone here know how to handle this error?
I have already used "Wire.h" library in many ways, to read "CH0 ADC data register" with address 0x14, which holds the ambient level value (according to datasheet). The code is as follows:
#define DUMP_REGS
#include <Wire.h>
#include <APDS9930.h>
// Global Variables
APDS9930 apds = APDS9930();
float ambient_light = 0; // can also be an unsigned long
uint16_t ch0 = 0;
uint16_t ch1 = 1;
void setup() {
//analogReference(EXTERNAL);
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("APDS-9930 - Ambient light sensor"));
Serial.println(F("--------------------------------"));
// Initialize APDS-9930 (configure I2C and initial values)
//if ( apds.init() ) {
// Serial.println(F("APDS-9930 initialization complete"));
//} else {
// Serial.println(F("Something went wrong during APDS-9930 init!"));
// }
// Start running the APDS-9930 light sensor (no interrupts)
//if ( apds.enableLightSensor(false) ) {
// Serial.println(F("Light sensor is now running"));
// } else {
// Serial.println(F("Something went wrong during light sensor init!"));
// }
#ifdef DUMP_REGS
/* Register dump */
uint8_t reg;
uint8_t val;
for(reg = 0x00; reg <= 0x19; reg++) {
if( (reg != 0x10) && \
(reg != 0x11) )
{
apds.wireReadDataByte(reg, val);
Serial.print(reg, HEX);
Serial.print(": 0x");
Serial.println(val, HEX);
}
}
apds.wireReadDataByte(0x1E, val);
Serial.print(0x1E, HEX);
Serial.print(": 0x");
Serial.println(val, HEX);
#endif
// Wait for initialization and calibration to finish
delay(500);
}
void loop() {
// Read the light levels (ambient, red, green, blue)
if ( !apds.readAmbientLightLux(ambient_light) ||
!apds.readCh0Light(ch0) ||
!apds.readCh1Light(ch1) ) {
Serial.println(F("Error reading light values"));
} else {
Serial.print(F("Ambient: "));
Serial.print(ambient_light);
Serial.print(F(" Ch0: "));
Serial.print(ch0);
Serial.print(F(" Ch1: "));
Serial.println(ch1);
}
// Wait 1 second before next reading
delay(1000);
}
As discussed in the comments above, the issue is hardware related.
On the Arduino Mega 2560 board there are two resistances tying lines SDA and SCK (pins 20 and 21 on the connector) to +5V.
With those pull-up resistances, it's not possible to interface with sensors working at 3.3V directly.
The solution is to add a level shifter or remove the resistances on the board and install them externally connecting them to 5V or 3.3V as necessary depending on the sensor you want to interface to.
I'm trying to get VGM CAN message out of a Reachstacker 42-45 tonnes
where I am using an arduino MEGA 2560 with a CAN-BUS shield
this my current code:
#include <SPI.h>
#include "mcp_can.h"
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
void loop()
{
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned char canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.println("get data from ID: ");
Serial.println(canId);
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf[i]);
Serial.print("\t");
}
Serial.println();
}
}
this was the result at the time of doing the test, the problem that I do not understand the result
according to the documentation should have a result like this :
this is another part of the documentation :
If someone needs more information or does not understand what I'm looking for, you can request what you need to help me
Send data:
// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(115200);
START_INIT:
if(CAN_OK == CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
// send data: id = 0x00, standrad frame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0x00, 0, 8, stmp);
delay(100); // send data per 100ms
}
You have two pieces that do not fit between your documentation and the output you are generating:
The data payload
The ID of the CAN frames
For the data payload it is simply a matter of formatting. You print each byte as integer value, whereas in the documentation it is printed as hexadecimal values. Use
Serial.print(buf[i], HEX)
to get the payload printed as hexadecimal characters.
For the ID of the CAN frames, you see from the documentation that they do not fit inside an unsigned char, as already mentioned in the comment by #Guille. Actually those are 29-bit identifiers, which you should ideally store in an appropriately sized variable. Ideally use an unsigned long:
unsigned long canId = CAN.getCanId();
In the documentation the CAN ID is also printed in hexadecimal, so also here use:
Serial.println(canId, HEX);
I'd like to set up a CAN network of multiple nodes using Arduino Pro Minis and MCP2515 cards. But I can't get the Receive to work.
#include <mcp_can.h>
#include <SPI.h>
long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
char msgString[128];
#define CAN0_INT 2 // Set INT to pin 2
MCP_CAN CAN0(10); // Set CS to pin 10
void setup() {
Serial.begin(115200);
// Initialize MCP2515 running at 8MHz with a baudrate of 125kb/s
// and the masks and filters disabled.
while (CAN_OK != CAN0.begin(MCP_ANY, CAN_125KBPS, MCP_8MHZ)) {
Serial.println("CAN BUS Module Failed to Initialize.");
}
Serial.println("MCP2515 Initialized Successfully!");
CAN0.setMode(MCP_NORMAL);
pinMode(CAN0_INT, INPUT); // Configuring pin for /INT input
}
void loop() {
if(!digitalRead(CAN0_INT)) { // If CAN0_INT is low, read receive buffer
CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s)
if((rxId & 0x80000000) == 0x80000000) // Is ID standard (11 bits) or extended (29 bits)?
sprintf(msgString, "Extended ID: 0x%.8lX DLC: %1d Data:", (rxId & 0x1FFFFFFF), len);
else
sprintf(msgString, "Standard ID: 0x%.3lX DLC: %1d Data:", rxId, len);
Serial.print(msgString);
if((rxId & 0x40000000) == 0x40000000) { // Is message a remote request frame?
sprintf(msgString, " REMOTE REQUEST FRAME");
Serial.print(msgString);
} else {
for(byte i = 0; i<len; i++) {
sprintf(msgString, " 0x%.2X", rxBuf[i]);
Serial.print(msgString);
}
}
Serial.println();
}
}
However, all I get out are the error messages, including this:
Entering Configuration Mode Failure
What am I missing here?
I got the circuit to work. The 2-node CAN Bus is communicating.
I found this site and made a couple of changes:
My Arduino ProMini MISI, MISO pins were not aligned with the SI, SO pins on the MCP2515s.
I used the CAN_BUS_Shield library.
Im trying to interface ESP12-E module with ILI9341 display 320*240 And PN532 RFID reader on the same SPI bus. I have assigned SS Pins on different GPIO.
Im unable to Communicate with both. Display works perfectly in any conditions. But once i communicate with ILI9341 , the PN532 stops working and it will not respond until i restart the device even if i reinitialize it.
Any Help would be highly Appreciated
My Code :
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <UTFT.h>
UTFT lcd(ILI9341_S5P,15,D1,D3);
// If using the breakout with SPI, define the pins for SPI communication.
#define PN532_SS (D4)
#define PN532_SCK (D5)
#define PN532_MOSI (D7)
#define PN532_MISO (D6)
// If using the breakout or shield with I2C, define just the pins connected
// to the IRQ and reset lines. Use the values below (2, 3) for the shield!
#define PN532_IRQ (2)
#define PN532_RESET (3) // Not connected by default on the NFC Shield
// Uncomment just _one_ line below depending on how your breakout or shield
// is connected to the Arduino:
// Use this line for a breakout with a SPI connection:
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
// Use this line for a breakout with a hardware SPI connection. Note that
// the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
// hardware SPI SCK, MOSI, and MISO pins. On an Arduino Uno these are
// SCK = 13, MOSI = 11, MISO = 12. The SS line can be any digital IO pin.
//Adafruit_PN532 nfc(PN532_SS);
// Or use this line for a breakout or shield with an I2C connection:
//Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);
extern uint8_t BigFont[];
void setup(void) {
Serial.begin(115200);
Serial.println("Hello!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
lcd.InitLCD();
lcd.setColor ( 0, 0, 0 );
lcd.fillRect(1,1,319,239);
lcd.setColor ( 255, 255, 255 );
lcd.fillRect(100,100,220,140);
lcd.setFont ( BigFont );
lcd.print(String("Scanning"),0,0);
// Set the max number of retry attempts to read from a card
// This prevents us from waiting forever for a card, which is
// the default behaviour of the PN532.
nfc.setPassiveActivationRetries(0xFF);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A card");
}
void loop(void) {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,25);
if (success) {
Serial.println("Found a card!");
Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print("UID Value: ");
for (uint8_t i=0; i < uidLength; i++)
{
Serial.print(" 0x");Serial.print(uid[i], HEX);
}
Serial.println("");
// Wait 1 second before continuing
delay(1000);
}
else
{
// PN532 probably timed out waiting for a card
//Serial.println("Timed out waiting for a card");
}
}
I've testing it a lot and figured out - The SPI bit-order is different, so you can not drive these two devices on the same SPI.
But you can use SW-SPI (bitbanging) for the NFC module, because it is not necessary to drive it fast. The TFT instead must be fast to have good update rates.
One Issue is still open on my setup:
the display did not show content, if you have an open serial terminal. But when it is closed, both TFT and NFC are working fine together.
Here is my code:
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <UTFT.h>
// NFC module
#define PN532_SCK D1
#define PN532_MOSI D2
#define PN532_MISO D3
#define PN532_SS D0
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
// TFT display
// HSPI defines
#define TFT_SCK D5
#define TFT_MOSI D7
//#define TFT_MISO D6 (not connected)
#define TFT_CS D8
#define TFT_DC D4
UTFT myGLCD(ILI9341_S5P, TFT_CS, -1, TFT_DC);
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
// forward declaration of helper function to get UID as HEX-String
void byteToHexString(String &dataString, byte *uidBuffer, byte bufferSize, String strSeperator);
void setup() {
Serial.begin(9600);
Serial.println("Initial nfc module");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// Set the max number of retry attempts to read from a card
// This prevents us from waiting forever for a card, which is
// the default behaviour of the PN532.
nfc.setPassiveActivationRetries(0xFF);
// configure board to read RFID tags
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A card");
Serial.println("Initial tft display");
myGLCD.InitLCD();
myGLCD.setColor(0, 0, 0);
myGLCD.fillRect(1,1,319,239);
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(BigFont);
myGLCD.print(String("Scanning"),0,0);
}
void loop(void) {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
//success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,25);
if (success) {
Serial.println("Found a card!");
Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print("UID Value: ");
String strUID;
// store UID as HEX-String to strUID and print it to display
byteToHexString(strUID, uid, uidLength, "-");
Serial.println("");
Serial.println(strUID);
myGLCD.print(strUID, CENTER, 50);
myGLCD.setColor ( 255, 0, 0 );
myGLCD.setFont ( BigFont );
myGLCD.print(String("Scanning"),0,0);
// Wait 1 second before continuing
delay(1000);
}
else
{
Serial.println("Timed out or waiting for a card");
}
}
// helper function to get UID as HEX-String
void byteToHexString(String &dataString, byte *uidBuffer, byte bufferSize, String strSeperator=":") {
dataString = "";
for (byte i = 0; i < bufferSize; i++) {
if (i>0) {
dataString += strSeperator;
if (uidBuffer[i] < 0x10)
dataString += String("0");
}
dataString += String(uidBuffer[i], HEX);
}
dataString.toUpperCase();
}
Thanks for the help.
Im not a big fan of bitbanging SPI.
I have tried several ways and tried re-initializing, etc.
Finally, i got it solved.
I dont know why, but when i re-initialize spi hardware after reading card, Both of the module works perfectly.
The code i added just after reading card:
lcd._hw_special_init();
like:
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength,0);
if (success) {
lcd._hw_special_init();
//Do the rest
}
I have created two datastream in xively from one I want to send data on xively and from one I want to get but while using put method it is changing my both value but I dont want to update one of the data stream i am using xively.put method for this
#include <SPI.h> //spi library
#include <Ethernet.h> //ethernet library
#include <HttpClient.h>//http client library
#include <Xively.h> //xively library
//using the mac id of ethernrt shield Mac_ID = 90-A2-DA-0E-99-85
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0x99, 0x85 };
//Xively api key for upload and download
char xivelyKey[] = "api_key";
// Dtastream id i.e Device create in Xively account with same name otherwise will get an error
char ledId[] = "led";
char sensorId[]="stepper";
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0;
//Initializing the xively datastream for the devices created in xively account
XivelyDatastream datastreams[] = {
XivelyDatastream(ledId, strlen(ledId), DATASTREAM_FLOAT),
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
//The transmission happen through feed initialize it
//XivelyFeed feed(FEED_ID,XIVELY_DATASTREAM,NO_OF_DATASTREAM)
XivelyFeed feed(feedid, datastreams, 2);
//Initializing the ethernet client for http support
EthernetClient myclient;
//Use the ethernet client to initialize xively client
XivelyClient xivelyclient(myclient);
/* Initial setup of arduino */
void setup(){
/* initialize the serial communication to monitor the transmission */
//starting the serial communication with the baud rate 9600
Serial.begin(9600);
Serial.println("Serial Communication started");
Serial.println();
//assigning the ip address using dhcp
while (Ethernet.begin(mac) != 1){
Serial.println("Error getting IP address via DHCP, trying again...");
delay(15000);
}
}
/* loop for doing continous upload and dowload of data*/
void loop(){
int sensor;
sensor=analogRead(sensorPin);
datastreams[1].setFloat(sensor);
/* uploading the data */
Serial.print("uploading data of stepper");
Serial.println(datastreams[1].getFloat());
Serial.println("Uploading it to Xively");
while((xivelyclient.put(feed, xivelyKey) != 200));
Serial.println();
delay(15000);
Serial.println("uploading of data completed");
/* finidh uploading data*/
/* Downloading the data*/
Serial.println("downloading data");
while((xivelyclient.get(feed, xivelyKey) != 200));
Serial.println("Datastream is...");
Serial.println(feed[0]);
Serial.println("Datastream is...");
Serial.println(feed[1]);
Serial.print("stepper motor downloaded data is: ");
Serial.println(feed[1].getFloat());
Serial.println("downloadind data completed");
Serial.println();
delay(15000);
/* Downloading data completed */
}
Make two XivelyDatastream: one with the Id that you want to send and the other with what you want to read.
Otherwise everything is updated in the datastream.
// Setup two different streams:
XivelyDatastream datastreams_get[] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
XivelyDatastream datastreams_put[] = {
XivelyDatastream(ledId, strlen(ledId), DATASTREAM_FLOAT),
};
//The transmission happen through feed initialize it
//XivelyFeed feed(FEED_ID,XIVELY_DATASTREAM,NO_OF_DATASTREAM)
XivelyFeed feedget(feedid, datastreams_get, 1);
XivelyFeed feedput(feedid, datastreams_put, 1);
// then use different stream definitions for PUT and GET:
xivelyclient.get(feedget, xivelyKey);
xivelyclient.put(feedput, xivelyKey);