Hi guys,
I am trying to use XBEE PRO S2C on SPI with ESP32 using arduino ide. Since I could not find any useful resource except the datasheet, I have been trying to send data to and read data from SPI while sending random data from coordinator device by XCTU. Unfortunately I am not able to do that. Is there any suggestion for me to code this task. Can you help how to use SPI of XBee using arduino (or ESP) ? To get at least raw data is something for me, almost got burnt out. My current code is given below.
Thanks,
EDIT: I connected XBee to both Arduino and ESP32 individually. But I failed to receive or send any data through SPI bus. What can I try? Xbee modules are working with XCTU software. Also I configured SPI pins.
When I send packets from one module to another using XCTU then try reading SPI bus of other module only 0xFF is coming from SPI as data.
Any example code will be useful.
#include “SPI.h”
void setup() {
Serial.begin(115200);
Serial.println(“well boot is successfull”);
while(1){
if(Serial.available()){
Serial.println(“something”);
SPI.begin(18,19,23,5);
//SPI.begin();
Serial.println(“spi has begun”);
break;
}}
}
void loop() {
static uint8_t transmit_header[] = {
0x7e,
0,0,
0x10,
0,
0,0,0,0, 0,0,0,0,
0,0,
0,
0,
};
static char buffer[255];
static int count = 0;
int len = sprintf(buffer, “Count: %d”, count++);
uint8_t check = 0x10;
transmit_header[1] = ((len+14)>>8)&0xff;
transmit_header[2] = ((len+14)>>0)&0xff;
for(int i = 0; i < len; i++) {
check += buffer[i];
}
SPI.transfer(transmit_header, 17);
SPI.transfer((uint8_t*)buffer, len);
SPI.transfer(0xff - check);
Serial.println(count);
Serial.println(SPI.transfer(007) );
delay(1000);
}