I've been trying to get a Pro Micro and Pi Pico to communicate over radio using the NF24L01 (nrf) modules. Trouble is that the Pico reciever refuses to acknowledge anything has been sent. I was getting OS error with Micropython one, although that was just simply incorrect pins, fixing that cleared up any issues. Other than that the Pro Micro seemed to return good values for radio.printDetails().
Likely issue was pipes but I think I got my head around it, AAAAA = \x41\x41\x41\x41\x41(?)
Any ideas? Much appreciated.
MicroPython (Pico), RX:
Code: Select all
pipe = (b"\x41\x41\x41\x41\x41") # 'AAAAA' on the ardinuo
cfg = {"spi": 0, "miso": 4, "mosi": 7, "sck": 6, "csn": 0, "ce": 1}
csn = Pin(cfg["csn"], mode=Pin.OUT, value=1)
ce = Pin(cfg["ce"], mode=Pin.OUT, value=0)
def rx():
nrf = NRF24L01(SPI(cfg["spi"]), csn, ce, channel = 100, payload_size=32)
nrf.open_rx_pipe(0, pipe)
nrf.start_listening()
print('readSensorLoop, waiting for packets... (ctrl-C to stop)')
while True:
utime.sleep(0.05)
if nrf.any():
print('received something!!')
rx()
Code: Select all
//create an RF24 object
RF24 radio(8, 7); //CE, CSN pins
const byte address[5] = {'A','A','A','A','A'}; //5 byte address (40 bit hex values) (0-9..A-F) e.g. A == 0x41 or \x41
void setup()
{
Serial.begin(19200); //This pipes to the serial monitor
Serial.setTimeout(0.2); //Timeout if readUntil doesn't find escape character.
radio.begin();
radio.setChannel(100);
radio.setPayloadSize(32);
radio.setRetries(15,15);
radio.openWritingPipe(address); //set the writing (pipe) address
radio.stopListening(); //Set module as transmitter
}
void loop()
{
//TRANSMIT
serialIN = "THIS BETTER WORK";
serialIN.toCharArray(txOUT,16);
RXLED1;
radio.write(txOUT, sizeof(txOUT)); //Sends PPP,RRR,YYY,TTT text
RXLED0;
delay(1000);
}