Giter Club home page Giter Club logo

Comments (4)

TMRh20 avatar TMRh20 commented on July 22, 2024

This is a coding issue, not an issue with the library.

The library will handle a maximum of 32 bytes per payload. Either use multiple payloads, make your payloads smaller, or use RF24Network which supports large payload sizes via fragmentation/reassembly.

from rf24.

2bndy5 avatar 2bndy5 commented on July 22, 2024

This is not a RF24 lib problem, rather it is a combination of misusing c-str data and misunderstanding the hardware limitations of the nRF24L01 radio.

Lets talk c-str data

  char humidityStr[6];

Here, you allocate 6 bytes for string to represent a percentage (usually ranging [0, 100]) with 2 decimal places. So, max is 100.00% (6 characters) and min is 0.00%. At this point, it is important to note that the hunidityStr does not have enough capacity for the c-str's required null terminating character ('\0') when the float value is at max (100.00).

Lets talk RF24 payload size

Using RF24, payloads can only be 32 bytes maximum.

# this is 32 characters (32 bytes of UTF-8 encoded data)
2024/05/07 15:02:07 T:25.90°C H:

# this is 38 characters (38 bytes of UTF-8 encoded data)
2024/05/07 15:02:07 T:25.90°C H:48.90%

Increasing the buffer beyond 32 bytes is pointless because the nRF24L01 will only handle payloads with a maximum of 32-bytes. BTW, increasing the size of a buffer of uninitialized bytes does not guarantee that the c-str data will end in a '\0' because not all compilers use implicit initialization values (that's up the Arduino core you are using for the Uno R4).

Some other hints

  • use if (!radio.begin()) to detect bad radios or incorrect wiring.
  • using sprintf() instead of dtostrf() can tell you how many bytes were stored to the c-str. The byte count in turn can be used as the payload length...

from rf24.

saeidbina avatar saeidbina commented on July 22, 2024

thank you much for your reply. Could you please help me? the final project will have 12 sensors in a MEGA board that will be sent to UNO using nrf24. I am begginer.

from rf24.

2bndy5 avatar 2bndy5 commented on July 22, 2024

Sorry, but no. We try to focus on actual library problems here. You could try your luck with Arduino forums.

project will have 12 sensors in a MEGA board that will be sent to UNO using nrf24

Sounds like a good scenario for using RF24Network. It allows for payloads greater than 32 bytes and the network can have hundreds of nodes instead of just 7 nodes. The only obstacle for beginners is understanding the network topology

from rf24.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.