Activity › Forums › Questions & Troubleshooting › controllino maxi SPI problem
-
controllino maxi SPI problem
-
Hello
I connected the NRF24L01 with the controllino maxi power to receive the radio signal from another microcontroller
The problem is that the code does not work, although I did not encounter this problem when using the Arduino mega
I have connected the pin of NRF24L01 to controllino like this :
MOSI ——– MOSI
MISO ——— MISO
CONTROLLINO_D5 ———— CE
CONTROLLINO_D6————CSN
GND —- GND
3.3V —–VCC
Here is the code :
#include <SPI.h>
#include <Controllino.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7,8); // nRF24L01 (CE, CSN)
const byte address[6] = “00001”;
unsigned long lastReceiveTime = 0;
unsigned long currentTime = 0;
const int led = 2;
const int led2 = 4; //CONTROLLINO_D4;
struct Data_Package {
byte button1;
byte tSwitch1;
};
Data_Package data; //Create a variable with the above structure
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
radio.openReadingPipe(0, address);
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_LOW);
radio.startListening(); // Set the module as receiver
resetData();
}
void loop() {
// Check whether there is data to be received
if (radio.available()) {
radio.read(&data, sizeof(Data_Package)); // Read the whole data and store it into the ‘data’ structure
lastReceiveTime = millis(); // At this moment we have received the data
}
// Check whether we keep receving data, or we have a connection between the two modules
currentTime = millis();
if ( currentTime – lastReceiveTime > 1000 ) { // If current time is more then 1 second since we have recived the last data, that means we have lost connection
resetData(); // If connection is lost, reset the data. It prevents unwanted behavior, for example if a drone has a throttle up and we lose connection, it can keep flying unless we reset the values
}
if (data.button1 == HIGH) {
digitalWrite(led, HIGH);
digitalWrite(led2, HIGH);
}
else {
digitalWrite(led, LOW);
digitalWrite(led2, LOW);
}
delay(50);
}
void resetData() {
// Reset the values when there is no radio connection – Set initial default values
data.button1 = 1;
}
-
Hello Mou-Kros and Lukas,
I do have the same issue as Mou-Kros had. The nRF24L01 works with an Arduino Uno, but as soon as it’s connected to the SPI of the Controllino maxi I don’t get any response. Did you get it to work after some changes? And if so, where in the program did you add the Controllino_RTC_init();?
I tried several positions, but till now I could not get the right values in my serial monitor.
Kind regards,
Roy
Log in to reply.