This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF24L01+ | Registers get set to 0x00 after sending write command + data

Hello,

I'm having this problem with this nRF24L01+ connected to an ESP8266 (ESP12-E on BOB), and I'm using NodeMCU 2.2.1.  The nRF24L01+ module I'm using is a small board with 8 castellations that I broke out using half of a SOIC-16 to 2.54 mm adapter.  I'm also using the NodeMCU SPI library, though I'm confident it's not the problem.

I can communicate with the chip just fine, I can read registers, and they are all at their default values, however, when I try to set a register by sending 0x2X, I get 0x00 back, and reading the register after also returns 0x00.  Other registers will be at their default values, though sometimes the chip crashes, and I have to power-cycle to reset to be able to read registers again.

Obviously the chip can receive data, and output data; and the software can write data to the MOSI buffer, and read data from the MISO buffer...  I also tried to set RX_ADDR_P2 to see if maybe my bits were out of order or something, it should've accepted pretty much any value from 0x0 to 0xFFFFFFFFFF, but it just gets set to 0x00.

Once I was playing with the clock polarity and phase settings (I know from the datasheet that they're both supposed to be low, but I was turning knobs to see), and I managed to get 0x08 set at some point, but it had nothing to do with the data, so it was probably just noise from the bad polarity, but it shew that it was possible to set something in the register at all.

I suppose this is pretty simple I'm just not aware of, or not paying attention to, and so preemptively, I would like to add that while I'm a pretty bright kid, I'm just starting out as a hobbyist, it's my first time with the nRF24L01+, and my first time with SPI, but know that your help is invaluable to me, and that I am eager to learn anything you may be willing to show me.

The nRF24L01+ is wired straight to the ESP8266's HSPI GPIO ports (TX/RX and IRQ are floating), I don't have any pF caps at hand, so the transmission lines aren't pulled-up, nor decoupled, but since I can communicate, I don't think it's the problem...  I think it's either my code, or my understanding, but I did read the datasheet cover to cover.  Below is my code, and let me know if you would like a picture of the physical setup.

Thanks in advance for your time, and any help, or insight you may be able to provide.  : ]

spi.setup ( 1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 80, spi.FULLDUPLEX )
--spi.setup(id, mode, cpol, cpha, databits, clock_div[, duplex_mode])

local buffer
local address = 0x000000
local addrlen = 0
local misolen = 256
local command = 0x2B  --tonumber ( 00101011, 2 )  -- MSBit first
local datalen = 5*8
local data = 0x1a1a1a1a1a  -- tonumber( 00001100, 2 )  -- LSByte first, MSBit first

spi.set_mosi ( 1, 0, datalen, data )
--spi.set_mosi(id, offset, bitlen, data1[, data2[, ..., datan]])

spi.transaction ( 1, 8, command, addrlen*8, address, datalen, 0, misolen )
--spi.transaction(id, cmd_bitlen, cmd_data, addr_bitlen, addr_data, mosi_bitlen, dummy_bitlen, miso_bitlen)

for i = 0, misolen-1, 1 do

	if ( i == 0 ) then
		buffer = spi.get_miso ( 1, i, 1, 1 )
		--spi.get_miso(id, offset, bitlen, num)
	else
		buffer = buffer .. spi.get_miso ( 1, i, 1, 1 )
	end

	if ( (i+1)%8 == 0 ) then
		buffer = buffer .. ' '
	end

end

print ( buffer )

Parents
  • Hi 

    Do you have a scope available so you can check what is happening on the bus?
    That is a big help in debugging serial communication issues like these. 

    Also, which supply voltage are you running your boards at?
    You have made sure to run both the ESP8266 and the nRF24L01+ from the same supply?

    If you have a link to the module you are using that could be helpful, and a picture of your setup if you have one. 

    Finally, if you have an Arduino Uno or similar laying around you can use that as a reference. There is an nrf24 library for the Arduino which makes it relatively simple to get the module running, and when you have something working it might be easier to see what is wrong with the ESP implementation.

    Best regards
    Torbjørn

  • Hi Torbjørn,

    thanks for replying.

    Unfortunately I don't have a scope, or a LA... they're both high in priority on my list of things to buy, but being an apprentice, I have a lot of parts to buy, ICs, passives, modules, etc. to be able to do most things as they come, and the need to purchase a lot of smaller things, combined with being new, and the price point of a scope makes it so I'm waiting to both learn more, and be sure of my investment of time, before investing my money...  I am definitely going to order a cheap USB logic analyzer board, and clips, though...  I'm not sure what $10 will get me, but I think it's worth the risk at this point.  I really wish I had one available to me, though, because this problem was a pain to try and understand....

    The MCU and nRF24L01+ are both powered by USB, and a voltage regulator feeds 3.31 V both to the MCU and to the rail, and both are referenced to the same ground.

    Link to module: Castellated board, 4th picture from right.

    Picture of setup: Picture of setup.

    I do have an Arduino Uno in my box, but while it may seem strange I'm not super familiar with it...  Arduino makes the information I look for difficult to find because of floods of tutorials, and people having the same stupid problems, or unrealistic expectations (sorry), and I'm still hoping there's something obviously wrong in my setup, or that someone who've had this issue might come up, and know right away what the problem is, but I will try to dust off the board over the weekend, and try to see if I can configure the nRF24L01+ with it...

    Thanks for your help  Blush

Reply
  • Hi Torbjørn,

    thanks for replying.

    Unfortunately I don't have a scope, or a LA... they're both high in priority on my list of things to buy, but being an apprentice, I have a lot of parts to buy, ICs, passives, modules, etc. to be able to do most things as they come, and the need to purchase a lot of smaller things, combined with being new, and the price point of a scope makes it so I'm waiting to both learn more, and be sure of my investment of time, before investing my money...  I am definitely going to order a cheap USB logic analyzer board, and clips, though...  I'm not sure what $10 will get me, but I think it's worth the risk at this point.  I really wish I had one available to me, though, because this problem was a pain to try and understand....

    The MCU and nRF24L01+ are both powered by USB, and a voltage regulator feeds 3.31 V both to the MCU and to the rail, and both are referenced to the same ground.

    Link to module: Castellated board, 4th picture from right.

    Picture of setup: Picture of setup.

    I do have an Arduino Uno in my box, but while it may seem strange I'm not super familiar with it...  Arduino makes the information I look for difficult to find because of floods of tutorials, and people having the same stupid problems, or unrealistic expectations (sorry), and I'm still hoping there's something obviously wrong in my setup, or that someone who've had this issue might come up, and know right away what the problem is, but I will try to dust off the board over the weekend, and try to see if I can configure the nRF24L01+ with it...

    Thanks for your help  Blush

Children
  • Hi 

    The module looks fine and is getting good reviews on AliExpress, so that is probably not the issue ;)

    It seems you are debugging the communication the right way, which is a good start. If reading the registers work there must be something working over the bus, but it is odd that you can read registers correctly at different addresses without being able to write to any of them. 

    The SPI API used by your module (NodeJS?) looks very different from other SPI API's I've seen, and it is hard to say what exactly will happen on the bus by looking at your code. 

    Does the module come with some SPI examples that show how to use the API's?

    Regarding USB logic analyzers we use the Saleae models a lot in the office. They are cheap compared to proper scopes, but unfortunately not $10 cheap ;)
    The Logic 8 retails for $399.

    If you can't afford to buy a scope I would suggest trying to find a local school or hacker community where you can borrow one when needed Slight smile

    Best regards
    Torbjørn

Related