Activity Forums Questions & Troubleshooting controllino maxi SPI problem

  • controllino maxi SPI problem

  • Mou-Kros

    Member
    April 7, 2022 at 2:32 pm

    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;

    }

  • Lukas

    Member
    May 5, 2022 at 12:50 pm

    Please see FAQ#7

    You should call Controllino_RTC_init(); before you use SPI for external device.

    Lukas

  • RoydL

    Member
    September 12, 2023 at 11:51 pm

    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

Viewing 1 - 3 of 3 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now