Shop OBEX P1 Docs P2 Docs Learn Events
nRF24L01+ : Having difficult time getting a simple test to work, could use some help/advice. - Page 2 — Parallax Forums

nRF24L01+ : Having difficult time getting a simple test to work, could use some help/advice.

2»

Comments

  • I manually added this into my ReadPayload function as a test:
      payload[0] := $a1
      payload[1] := $b2
      payload[2] := $c3
      payload[2] := $d4
    

    And sure enough when I am displaying the array, I am getting "a1000000", so this confirms that its not the nRF24L01+ chip, its how I am using the array which is causing the problem.

    Does anyone know why my array is not working? I previously posted my code snippets above.
  • PUB Main|payload[4], idx

    You are declaring a long array in a local instance so that you have a total space for 16 bytes. Instead, declare payload as a byte var, payload[32]. Not sure if this the problem but you need to be thinking in terms of bytes, not longs for data.
  • T Chap wrote: »
    PUB Main|payload[4], idx

    You are declaring a long array in a local instance so that you have a total space for 16 bytes. Instead, declare payload as a byte var, payload[32]. Not sure if this the problem but you need to be thinking in terms of bytes, not longs for data.

    I created a byte _readPayload[32] under the VAR section in the library that the function PUB ReadPayload now uses, and it returns the _readPayload at the end.
    I also created a byte _readPayload[32] under the VAR section of the main program that does "_readPayload := nrf.ReadPayload" then I iterate through that now instead.

    I get the exact same result.
  • When you tell the Nordic there are 32 bytes coming, I think it may wait for only so long then it sends zeros. I don't remember, Duane may remember. You are using a method I am not using to send data. I think you need to point to the payload, then send all in one string, not as separate sends like you are doing, so the nordic may not be waiting as there is a delay in Spin between sends. See if your method allows a way to send a string that is 32 bytes long. I suspect this is your issue.

  • FIGURED IT OUT! Haha took me forever...
    I had to pass a pointer into the ReadPayload function as a parameter. This pointer pointed to the address location of my array in the main program. I then assign the nRF24L01+ data to the pointer. Now when I iterate through the array in the main program all of the data is there. Like I thought before, it didn't have anything to do with the nRF24L01+ module, it was SPIN programming error.

    I had to research it a bit, and apparently you cannot return anything other than a long from a function. This was a problem because I was trying to return an entire array.

    So the original nRF24L01+ library that is in the parallax OBEX would have never worked, I don't even know why its there in the first place.

    Thanks again T Chap for helping me out.
  • This project was a lot of fun but now I wonder what could it do if I scaled it up to do some useful work?

Sign In or Register to comment.