Stránka 2 z 3

Re: Nrf24l01- chyba při odesílání

Napsal: 04 srp 2020, 20:29
od Hanz
dobrý den,
A to jsi sebral kde ?
tady jsem čerpal :
z https://navody.arduino-shop.cz/navody-k ... 24l01.html
citace ...

Re: Nrf24l01- chyba při odesílání

Napsal: 04 srp 2020, 21:58
od Orsen95
Hanz píše:
04 srp 2020, 08:59
dobrý den,
z https://navody.arduino-shop.cz/navody-k ... 24l01.html
citace ...
... Co se týká napájení, bezdrátový modul nRF24L01 vyžaduje napětí 3,3 V, ale datové piny jsou schopné pracovat s 5 V logikou Arduino desky a není tedy nutné používat žádné převody napájecích úrovní. Vysílací výkon nRF24L01 lze nastavit ve čtyřech úrovních od MIN do MAX (viz ukázkový kód), ale pro úrovně HIGH a MAX je doporučeno použít externí zdroj napětí 3,3 V, protože pro tyto vysílací výkony už není dostačující maximální proud, který dokáže dát stabilizátor na Arduino deskách. Co se týká proudového odběru, v Power down režimu má nRF24L01 udávanou spotřebu jen 1 mikroAmpér. Při odesílání a příjmu dat ale může tento bezdrátový modul odebírat krátkodobě až stovky miliAmpér a proto je vhodné kromě externího zdroje napětí 3,3 V připojit i kondenzátor 10 mikroFarad mezi napájecí napětí 3,3 V a zem GND. Jak bylo zmíněno, jako externí zdroj lze použít například stabilizátor napětí AMS1117-3,3V. ...

to potvrzují příspěvky viz.výše
snad to pomůže ;)
Dobrý večer, tak jsem to zkusil s menším kondenzátorem 4,7uF, bohužel mi přijímač nechytil ani jednu zprávu. Má smysl koupit kondenzátory s 10uF? Také jsem zkusil jinou knihovnu (Nrflite), ale výsledek byl stejný.

Re: Nrf24l01- chyba při odesílání

Napsal: 04 srp 2020, 23:01
od KamilV
A vyměnit kus za kus celé nrf24? Někdy prostě může být KO modul a člověk hledá chybu všude jinde...

Re: Nrf24l01- chyba při odesílání

Napsal: 04 srp 2020, 23:09
od Orsen95
Bohužel mám moduly 3 s všechny jsem zkoušel promíchat.

Re: Nrf24l01- chyba při odesílání

Napsal: 05 srp 2020, 00:34
od ArduXPP
Rychlost na obou nrf musí být stejná, jinak asi nedojde k příjmu.

Re: Nrf24l01- chyba při odesílání

Napsal: 05 srp 2020, 08:03
od Hanz
dobrý den,
adresa mezi NrF moduly musí být stejná ;)
vlož sem kody pomocí </> , ať je diagnoza přesnější

Re: Nrf24l01- chyba při odesílání

Napsal: 05 srp 2020, 10:29
od Orsen95
Hanz píše:
05 srp 2020, 08:03
dobrý den,
adresa mezi NrF moduly musí být stejná ;)
vlož sem kody pomocí </> , ať je diagnoza přesnější
Tady jsou oba dva:

Kód: Vybrat vše

ARDUINO UNO	

/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/

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

/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 0;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 0;

void setup() {
  Serial.begin(115200);
  Serial.println(F("RF24/examples/GettingStarted"));
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
  
  radio.begin();

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
  
  
/****************** Ping Out Role ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.
    
    
    Serial.println(F("Now sending"));

    unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
     if (!radio.write( &start_time, sizeof(unsigned long) )){
       Serial.println(F("failed"));
     }
        
    radio.startListening();                                    // Now, continue listening
    
    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
    
    while ( ! radio.available() ){                             // While nothing is received
      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
          timeout = true;
          break;
      }      
    }
        
    if ( timeout ){                                             // Describe the results
        Serial.println(F("Failed, response timed out."));
    }else{
        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
        radio.read( &got_time, sizeof(unsigned long) );
        unsigned long end_time = micros();
        
        // Spew it
        Serial.print(F("Sent "));
        Serial.print(start_time);
        Serial.print(F(", Got response "));
        Serial.print(got_time);
        Serial.print(F(", Round-trip delay "));
        Serial.print(end_time-start_time);
        Serial.println(F(" microseconds"));
    }

    // Try again 1s later
    delay(1000);
  }



/****************** Pong Back Role ***************************/

  if ( role == 0 )
  {
    unsigned long got_time;
    
    if( radio.available()){
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
      }
     
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      Serial.print(F("Sent response "));
      Serial.println(got_time);  
   }
 }




/****************** Change Roles via Serial Commands ***************************/

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == 0 ){      
      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
      role = 1;                  // Become the primary transmitter (ping out)
    
   }else
    if ( c == 'R' && role == 1 ){
      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
       role = 0;                // Become the primary receiver (pong back)
       radio.startListening();
       
    }
  }


} // Loop



ESP32

/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/

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

/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 1;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(4,5);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 0;

void setup() {
  Serial.begin(115200);
  Serial.println(F("RF24/examples/GettingStarted"));
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
  
  radio.begin();

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
  
  
/****************** Ping Out Role ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.
    
    
    Serial.println(F("Now sending"));

    unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
     if (!radio.write( &start_time, sizeof(unsigned long) )){
       Serial.println(F("failed"));
     }
        
    radio.startListening();                                    // Now, continue listening
    
    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
    
    while ( ! radio.available() ){                             // While nothing is received
      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
          timeout = true;
          break;
      }      
    }
        
    if ( timeout ){                                             // Describe the results
        Serial.println(F("Failed, response timed out."));
    }else{
        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
        radio.read( &got_time, sizeof(unsigned long) );
        unsigned long end_time = micros();
        
        // Spew it
        Serial.print(F("Sent "));
        Serial.print(start_time);
        Serial.print(F(", Got response "));
        Serial.print(got_time);
        Serial.print(F(", Round-trip delay "));
        Serial.print(end_time-start_time);
        Serial.println(F(" microseconds"));
    }

    // Try again 1s later
    delay(1000);
  }



/****************** Pong Back Role ***************************/

  if ( role == 0 )
  {
    unsigned long got_time;
    
    if( radio.available()){
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
      }
     
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      Serial.print(F("Sent response "));
      Serial.println(got_time);  
   }
 }




/****************** Change Roles via Serial Commands ***************************/

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == 0 ){      
      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
      role = 1;                  // Become the primary transmitter (ping out)
    
   }else
    if ( c == 'R' && role == 1 ){
      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
       role = 0;                // Become the primary receiver (pong back)
       radio.startListening();
       
    }
  }


} // Loop

Re: Nrf24l01- chyba při odesílání

Napsal: 05 srp 2020, 12:46
od KamilV
Psal jsi, že piny CE a CS máš 2 a 3, ale komunikaci natvrdo startuješ RF24 radio(7,8);

Re: Nrf24l01- chyba při odesílání

Napsal: 05 srp 2020, 22:32
od Orsen95
KamilV píše:
05 srp 2020, 12:46
Psal jsi, že piny CE a CS máš 2 a 3, ale komunikaci natvrdo startuješ RF24 radio(7,8);
Ano to vím, zkoušel jsem je změnit jestli to nebude nimi. Zapojení mám dobře, to je první co si kontroluji.

Re: Nrf24l01- chyba při odesílání

Napsal: 06 srp 2020, 08:13
od KamilV
No přiznám se, že se chyba nehledá snadno, když nakonec nevíme, jaké přesně máš zapojení a jaký přesně kód máš nahraný.
V úvodním postu píšeš o zapojení, které pak ale měníš. Popisuješ tam vrácenou chybu, která ale nepochází z kódu, který jsi teď zveřejnil.
Ona to nemusí být jen jedna chyba, mohou to být různé chyby a tím, jak se vše mění, mohou se různě objevovat a zanikat.

Nejlépe by bylo zveřejnit aktuální zapojení, aktuální kód a aktuální chyby.