Conflit de bibliothèque ?

Bonjour tout monde,

Je travaille actuellement sur un petit projet et j'ai besoin d'utiliser un écran OLED avec un récepteur de type nrf24l01 qui doivent être tout deux pilotés par le même arduino. Donc je fais des petits essais avec l'écran et le récepteur séparement et je n'ai pas de problème. Mais quand je combine les 2 codes, l'écran n'affiche plus rien.

Les 2 codes ci-dessous:

Ecran:

*/

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 8, /* reset=*/ 6);



void setup(void) {	

  u8g2.begin();  
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
  //delay(1000);
}

Recepteur :

#include <SPI.h>
#include "printf.h"
#include "RF24.h"

// instantiate an object for the nRF24L01 transceiver
RF24 radio(9, 10); // using pin 7 for the CE pin, and pin 8 for the CSN pin

// Let these addresses be used for the pair
uint8_t address[][6] = {"1Node", "2Node"};
// It is very helpful to think of an address as a path instead of as
// an identifying device destination

// to use different addresses on a pair of radios, we need a variable to
// uniquely identify which address this radio will use to transmit
bool radioNumber = 1; // 0 uses address[0] to transmit, 1 uses address[1] to transmit

// Used to control whether this node is sending or receiving
bool role = false;  // true = TX role, false = RX role

// For this example, we'll be using a payload containing
// a single float number that will be incremented
// on every successful transmission
boolean valeur = 0;

void setup() {

  Serial.begin(115200);
  pinMode(2, OUTPUT);

  while (!Serial) {
    // some boards need to wait to ensure access to serial over USB
  }

  // initialize the transceiver on the SPI bus
  if (!radio.begin()) {
    Serial.println(F("radio hardware is not responding!!"));
    while (1) {} // hold in infinite loop
  }

  // print example's introductory prompt
  Serial.println(F("RF24/examples/GettingStarted"));

  Serial.print(F("radioNumber = "));
  Serial.println((int)radioNumber);

  // Set the PA Level low to try preventing power supply related problems
  // because these examples are likely run with nodes in close proximity to
  // each other.
  radio.setPALevel(RF24_PA_LOW);  // RF24_PA_MAX is default.

  // save on transmission time by setting the radio to only transmit the
  // number of bytes we need to transmit a float
  //radio.setPayloadSize(sizeof(valeur)); // float datatype occupies 4 bytes

  // set the TX address of the RX node into the TX pipe
  radio.openWritingPipe(address[radioNumber]);     // always uses pipe 0

  // set the RX address of the TX node into a RX pipe
  radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

  // additional setup specific to the node's role
  if (role) {
    radio.stopListening();  // put radio in TX mode
  } else {
    radio.startListening(); // put radio in RX mode
  }

  // For debugging info
  // printf_begin();             // needed only once for printing details
  // radio.printDetails();       // (smaller) function that prints raw register values
  // radio.printPrettyDetails(); // (larger) function that prints human readable data

} // setup

void loop() {

   if (!role) {
    // This device is a RX node

    uint8_t pipe;
    if (radio.available(&pipe)) {             // is there a payload? get the pipe number that recieved it
      //uint8_t bytes = radio.getPayloadSize(); // get the size of the payload
      radio.read(&valeur, sizeof(valeur));            // fetch payload from FIFO
      Serial.print(F("Received :"));
      Serial.println(valeur);                // print the payload's value
    }
  } // role

  digitalWrite(2, valeur);
} // loop

C'est 2 codes fonctionnent séparemment mais quand j'essaie de les combiner, l'ecran n'affiche plus rien.
J'ai fais quelques essais et quand je met en commentaires les fonctions "radio." du setup, l'ecran fonctionne et m'affiche bien "HelloWord". J'ai donc d'abord pensais que la librairie "RF24" était en conflit avec la "U8g2" mais j'ai le même problème avec la librairie "Mirf" qui pilote aussi des récepteurs.

Il faut que je règle ce problème avant de pouvoir continuer mon projet.
Il faut que je puisse afficher des choses sur mon écran tout en utilisant mon récepteur.

Quelqu'un a-t'il une idée sur l'origine du problème svp ?

Le problème vient de cette ligne :

U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 8, /* reset=*/ 6);

Il faut utiliser un constructeur avec HW SPI (et connecter ton écran sur les pins correspondantes). Elles peuvent varier selon le modèle de ta carte. Voir ici

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.