Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RF24::begin(void) always returns false #213

Closed
wmarkow opened this issue Feb 11, 2016 · 4 comments
Closed

RF24::begin(void) always returns false #213

wmarkow opened this issue Feb 11, 2016 · 4 comments

Comments

@wmarkow
Copy link
Contributor

wmarkow commented Feb 11, 2016

I have noticed that the RF24::begin(void) always returns false which may confuse a developer who is using this library for the first time. I think commit with SHA b1b8cad comments out a little to much in the RF24::begin(void) function.

I can provide a very simple fix for that.

wmarkow added a commit to wmarkow/RF24 that referenced this issue Feb 15, 2016
wmarkow added a commit to wmarkow/RF24 that referenced this issue Feb 15, 2016
@wmarkow wmarkow mentioned this issue Feb 15, 2016
@Avamander
Copy link
Member

It should be tested before merging by people with different hardware.

Avamander added a commit that referenced this issue Feb 20, 2016
#213 fix. Seems to be okay when I tested. Hopefully no weird errors rise afterwards.
@TMRh20
Copy link
Member

TMRh20 commented Feb 20, 2016

The mess of code in begin() is due to some suggested changes to detect if setup was successful, but it never worked quite right, so I think removing that code is fine.

@wmarkow
Copy link
Contributor Author

wmarkow commented Feb 21, 2016

Thanks for merging my pull request. So for now we have the following piece of code:

uint8_t setup=0;
...
if( setDataRate( RF24_250KBPS ) )
{
  p_variant = true ;
}
setup = read_register(RF_SETUP);
...
// if setup is 0 or ff then there was no response from module
return ( setup != 0 && setup != 0xff );

My source code static analysis and datasheets for both RF24L01 and RF24L01+ shows that after hardware power up (when the power supply is attached) begin() method will return true (for both RF24L01 and RF24L01+ chips) if modules are wired correctly and are not damaged.
It should be ok even if someone will call begin() method multiple times (and sets by the way the power level RF_PWR to '00'). For both chips the setup value should be different than 0x00 or 0xff. Some issues me come up when we start touching the LNA_HCURR bit in RF24L01 (but for now we do not do that).

Another question pops up, related to this code:

// if setup is 0 or ff then there was no response from module
return ( setup != 0 && setup != 0xff );

So there is an assumption: when read a 0x00 or 0xff value over SPI it may be a clue that there was no response from the module. I have noticed on Arduino: when the module is not wired at all the SPI reads 0xff (like the MISO line was pulled up). However my NodeMCU sometimes reads 0x00 (like MISO was pulled-down) or sometimes returns 0xff (like MISO was pulled-up). What do you think?

@wmarkow
Copy link
Contributor Author

wmarkow commented May 4, 2017

I think I can close this issue now. Now there is a new API method available that is able to check if the nRF24 module is connected, correctly powered up in responsive.

@wmarkow wmarkow closed this as completed May 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants