NRF24L01 Issues: Unterschied zwischen den Versionen

Aus Hackerspace Ffm
Wechseln zu: Navigation, Suche
(RF24 Library)
 
Zeile 22: Zeile 22:
  
 
== RF24 Library ==
 
== RF24 Library ==
 +
 +
=== Working with dynamic payloads ===
 +
The library is very unintuitive and buggy in this behaviour. To recevie a packet with dynamic payload, do this:
 +
 +
<pre>
 +
if(radio.available()){
 +
  uint8_t payloadsize = radio.getDynamicPayloadSize();
 +
  if(payloadsize  < 1){
 +
    // Corrupt payload has been flushed
 +
    return;
 +
  } else {
 +
    radio.setPayloadSize(payloadsize); // THIS IS IMPORTANT TO DO DUE CRAPPY LIB
 +
    radio.read(&data,sizeof(data));
 +
  }
 +
}
 +
</pre>

Aktuelle Version vom 6. März 2017, 21:13 Uhr

Issues and pitfalls when using NRF24L01(+)

The radio modules based on NRF24L01+ are cheap 2.4GHz transmitters for medium bandwidth transmission. The module supports 250kbps, 1Mbps and 2Mbps data rate over 125 different channels, has internal buffers for up to 32 bytes of user data, automatic retransmission and CRC checking stuff.

Things that are nice

  • Cheap
  • 125 channels
  • Very low latency, high data rate
  • Easy to connect, control lines are 5V tolerant, however module needs 3.3V supply
  • Protocol handled in hardware - low processor interventions, usually no timing issues

Things that are not that nice

Even the module makes radio transmission easy, there are very many pitfalls a typical beginner might step in. So many that using this module ends up often very frustrating for beginners and even experts, if those will be neglected.

Electrical issues

Radio frequency is not easy to handle, care must be taken on noise-free power-supply, proper antenna configuration, antenna ground area, shielding of module at higher power levels and so on. With proper care, the module can transmit over distances over 1km, but with improper care the module somethings don't even reach more than 1m.

Understanding issues

Clones

RF24 Library

Working with dynamic payloads

The library is very unintuitive and buggy in this behaviour. To recevie a packet with dynamic payload, do this:

if(radio.available()){
  uint8_t payloadsize = radio.getDynamicPayloadSize();
  if(payloadsize  < 1){
    // Corrupt payload has been flushed
    return; 
  } else {
    radio.setPayloadSize(payloadsize); // THIS IS IMPORTANT TO DO DUE CRAPPY LIB
    radio.read(&data,sizeof(data));
  }
}