[SOLVED IT] Not a firmware problem, a test program problem!
The nrf24l01test.py
program only handles DEFAULT pins for non-ESP32 tools. For the others, it just ignores the custom pins for SCK, MOSI, and MISO. Fixing that fixed my issues and is now working!
Testing Tonight:
- I rolled back my failing pico to rp2-pico-w-20220712-unstable-v1.19.1-127-g74794d42b.uf2 and it worked w/ default pins.
- Flashing the pimoroni-picow-v1.19.6-micropython.uf2 seemed to work as well once I got it working on the July build I had w/ default pins.
- Flashed the latest pimoroni picow firmware just to be concise, and looks like it’s still working, soooo…
- Moved back to the pico explorer base, and original pinouts, and nothing worked :(
- Moved out of base and back to default pins by author of driver, and works fine, but that pinout wouldn’t work on the pico explorer base.
- Tried the pico explorer base pinout just on breadboard and no joy. Reset to default pins again.
- Started trying to move any of the pins one by one to another SPI0_x pin, and no joy.
- Moved CSN and CE pins to new spots (GPIO 1, GPIO 0 respectively) one by one and those work.
- Debugging the stock testing, since it’s clearly mis-handling the SPI pins somewhere. Noticed this:
if cfg["spi"] == -1:
spi = SPI(-1, sck=Pin(cfg["sck"]), mosi=Pin(cfg["mosi"]), miso=Pin(cfg["miso"]))
nrf = NRF24L01(spi, csn, ce, payload_size=8)
else:
nrf = NRF24L01(SPI(cfg["spi"]), csn, ce, payload_size=8)
- Since
rp2
boards use 0
or 1
for the SPI buses, it will always drop through and not use the custom pinouts.
- Added the following to the
if / else
statement to detect an abnormal bus specification -2
. This defaults to SPI bus 0, but honors the custom pins.
if cfg["spi"] == -1:
spi = SPI(-1, sck=Pin(cfg["sck"]), mosi=Pin(cfg["mosi"]), miso=Pin(cfg["miso"]))
nrf = NRF24L01(spi, csn, ce, payload_size=8)
elif cfg["spi"] == -2:
spi = SPI(0, sck=Pin(cfg["sck"]), mosi=Pin(cfg["mosi"]), miso=Pin(cfg["miso"]))
nrf = NRF24L01(spi, csn, ce, payload_size=8)
else:
nrf = NRF24L01(SPI(cfg["spi"]), csn, ce, payload_size=8)
- I then updated my
cfg
from the testing tool to enable that -2
value and the custom pinouts for the pico explorer base.
elif usys.platform == "rp2": # PI PICO
cfg = {"spi":-2, "miso": 16, "mosi": 19, "sck": 18, "csn": 7, "ce": 6}
- Tested in breadboard and everything’s A-OK. Wowzers!
- Move back to pico explorer base, and it’s all working.
Gotta say, this has been a good refresher in basic troubleshooting and eliminating variables. Also, that’s a really annoying bug. Will file a ticket with the library for this fix (or something similar).