Hey guys I’m new to the forum so I’m not sure if this is the correct place to post the question, but I have a bunch of XIAO boards and have been wanting to incorporate them into small projects as the size is optimal. So here’s my question,
Connecting the Nrf24L01 to xiao?
Project- I use arduino pro minis with NRF modules all over my shop and have a single controller that I use to trigger the relays on my devices. So I wanted to use the XIAO to make the controller smaller and use that as my transmitter-as it’s 3.3v and so is the NRF, I thought it would be a match made in heaven. So replacing all of my relay boards with XIAOs as well to make the enclosures as small as possible.
So what I did was load almost the identical code to my arduino units (transmitter and receivers) and they complied fine upload, yay. But are not triggering and I believe the nrf is not connected properly and also there may be special code to enable the SPI communication (SERCOM0 I believe) but there is no information online in regards to this board and the nrf24l01.
Any help would be awesome, I’ll post the code when I get to my computer. Also this project is as basic as it gets, transmitter with 2 switches and an NRF that switch on and off relays of other receivers around the shop.
Thanks in advance,
-Bobby
Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define buttonPin1 A0
#define buttonPin2 A1
int buttonState1 = 0;
int buttonState2 = 0;
RF24 radio(6, 7); // CE, CSN
const byte address[6] = "00002";
void setup() {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState1 == 1)
{
buttonState1 = 1;
}
else if (buttonState1 == 0)
{
buttonState1 = 0;
}
if (buttonState2 == 1)
{
buttonState2 = 3;
}
else if (buttonState2 == 0)
{
buttonState2 = 2;
}
Serial.print(buttonState1);
Serial.print("\t");
Serial.println(buttonState2);
radio.write(&buttonState1, sizeof(buttonState1));
radio.write(&buttonState2, sizeof(buttonState2));
}