NRF24L01 example not working?

Posted on
  • Hi,

    I'm trying to get the NRF24L01 example working with two STM32F4DISCOVERY boards. The setup is fairly simple: Two STM32F4DISCOVERY each with one NRF24L01 module connected to SPI1 (A5-A7, C4, C5). One as slave, one as master.

    As I don't think that I'm the first one who tries to get it running on the STM32F4DISCOVERY I think there is a problem on my side but I double checked the setup and I don't know where my mistake is.

    First question: What about case sensitivity? But I think that doesn't affect my problem as there is no difference.
    On line 8 of the driver:
    this.SPI.setup({sck:SCK, miso:MISO, mosi:MOSI});
    Shouldn't it be:
    this.SPI.setup({sck:sck, miso:miso, mosi:mosi});

    Question two:
    Is there a wiring diagram? Or to be more precise which is correct:
    MOSI->MOSI; MISO->MISO (straight)
    MOSI->MISO; MISO->MOSI (crossed)

    I'm still trying to get it working but any hints would be nice...

  • Hi,

    Thanks for letting us know - case sensitivity is actually an issue, so that code is wrong and I'll correct it. My guess is that when I wrote the code, the NRF24 was on the 'default' pins, so as MOSI/MISO/SCK would have been undefined, Espruino chose the correct (default) pins for SPI1 automatically.

    SPI is connected 'straight' - it's actually got a really nice naming convention. MOSI = Master Out Slave In, and obviously MISO is the opposite. Espruino is the Master and the NRF module is the slave.

    One way to help test is to make sure that you can communicate with the module over SPI. You could try asking it for its status, so you could do:

    var nrf = new NRF( D13, D12, D11, D1, D0, 4 ); 
    nrf.init([0,0,0,0,1], [0,0,0,0,2]); 
    nrf.getAddr(nrf.C.RX_ADDR_P1);
    

    and it should return an array representing the address - which should be [0,0,0,0,1] - the address that was given to the module in the init() function.

    Hope that helps!

  • Thanks for the answer. Actually it works now without changing anything on the hardware side. Probably there got something mixed up with some old code in the Espruino or while updating the two boards in parallel.

    Maybe there should be an option in the Web IDE to clean any Javascript code in the Espruino before uploading the new Javascript.

    I'm not really sure what's the easiest way to get a definitely clean Espruino? I did reset(); save(); to have a clean Espruino. And then every time before uploading something important I disconnect the power to be sure to start from zero.

    Small side question: Is there a rough estimation when module support works without having an sdcard? I've written a small lib for controlling DMX devices and I dislike to have two versions, one for copy&paste and one as module. Additionally I can't test the latter because I don't have a board with sdcard until I get the Espruinos from the campaign.

  • Glad it's working...

    Yes, reset();save(); is the best way to clear out any stored software... it's a good point about the Web IDE and resetting - to be honest it makes sense that it does a full reset every time you upload by default.

    I'm not sure about when the module support will arrive - I've been putting it off as it's in the Web IDE so isn't as hard to update later on as the firmware. It is something I'll be looking at soon though as I'd like to encourage more modules to be developed.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

NRF24L01 example not working?

Posted by Avatar for Daniel @Daniel

Actions