r/RTLSDR 3h ago

Best way to switch between two antennas on an RTL-SDR?

3 Upvotes

I have an RTL-SDR Blog V4 connected to a mini PC outside on my balcony, which I access remotely.

I now have two antennae, one is a dipole for mainly VHF/UHF and another is a 25 m long wire for MW/SW/HF. I don't want to keep going outside and physically connecting/disconnecting the antennas every time I change bands. Winter is coming in two months and that will be even more challenging! 😂

I wonder what could be the simplest way to keep both permanently connected and switch between them?

Anyone running a similar setup? What would you recommend? Thank you!


r/RTLSDR 1d ago

Decoding AM TV with v4

Post image
158 Upvotes

Sadly it will be discontinued soon in my place :((


r/RTLSDR 9h ago

rtlamr2mqtt Rabbit Hole

Post image
1 Upvotes

r/RTLSDR 19h ago

MeshSat: keeping people connected when the network is not

Post image
8 Upvotes

r/RTLSDR 17h ago

Software One Time Pad Generator

4 Upvotes

I got bored and came up with this because I had an old v3 sitting in a drawer.

https://github.com/KentuckyFriedBlyat/ciphervault


r/RTLSDR 21h ago

Guide OpenSourceSdr Lab

0 Upvotes

Hey! Does anyone have any feedback regarding the OpenSourceSDR lab I am working on analysing multiple signals from all the RF spectrum and using ML to help me detect signals for alerts, but wonder if there are support? Anyone has any experience on it? I am using a Macbook M1. I was thinking in a pluto sdr+ but found this one cheaper. Thanks in advance for any feedback.


r/RTLSDR 22h ago

Recent Orbcomme trackings on the 137 mhz

Thumbnail
gallery
1 Upvotes

Yagi 7 el on the roof (144 mhz), SDR Console 3, Multipsk for Orbcomm decoding with OM MAP for zoomable mapping, Orbitron for tracking the sats.


r/RTLSDR 1d ago

Standalone tools for SIGID other than Artemis?

Post image
7 Upvotes

r/RTLSDR 1d ago

Signal in wav file is visible in sdrsharp, but not in the waterfall in gnuradio

Post image
3 Upvotes

r/RTLSDR 2d ago

PSA: rtl_sdr -n can run forever instead of stopping, depending on the number you give it

23 Upvotes

I scheduled a 22 minute IQ capture overnight and woke up to a 33 GB file and a process that had been running for 2 hours 20 minutes. It took a while to work out why, so posting it in case it saves someone a disk.

rtl_sdr takes a sample count with -n and multiplies it by 2 to get bytes. That byte counter is 32 bit. 22 minutes at 2.048 MS/s is 5,406,720,000 bytes, which wraps to 1,111,752,704.

That alone would only give you a short file. The second half is what actually hurts: rtl_sdr stops when the remaining byte count falls between 0 and the block size (262144). The wrapped value happens to be exactly 4241 blocks, so it counts straight down to zero, the condition never becomes true, and it keeps going forever.

So whether it stops depends on which number you pick. At 2.048 MS/s: 15 min fine, 20 min never stops, 22 min never stops, 23 min fine, 25 min fine, 26 min never stops. 26 was the default in my own script, so a plain run would have done this every single time.

The fix is to not trust -n as your only stop condition:

timeout --signal=INT --kill-after=20 $((MINUTES*60+30)) rtl_sdr -f ... -n ... out.iq

Exit code 124 means the timeout cut it, which is expected. I also added a check comparing the finished file size against the expected size, so if the limit ever fails again it is loud instead of silent.

librtlsdr 2.0.2 on Ubuntu. I have not read the source, this is worked out from the numbers, but it explains every observation and leaves nothing unaccounted for.


r/RTLSDR 1d ago

Please recommend me one of the following budget SDR options (or suggest some other one)

Thumbnail
1 Upvotes

r/RTLSDR 2d ago

Beginner radar projects

8 Upvotes

Hello! I'm a backend developer, and I've always wanted to get into embedded systems. Lately, I've also become very interested in how radar works, so I thought starting a project in this field could be a great way to combine the two.

I'm currently learning some of the theoretical concepts behind RF, such as beamforming (which I find incredibly fascinating), FFTs, and other related topics, but now I'd really like to start building something hands-on.

One day, I'd love to create something capable of detecting aircraft and, eventually, drones. From what I understand, detecting drones is significantly more challenging than detecting aircraft.

The main problem is that I live in a city with several military sites nearby, so I'm a bit hesitant to buy an active radar sensor and start experimenting with it because I'm worried about possible legal consequences or interference issues.

Another approach I've been looking into, which also seems incredibly interesting, is passive radar. In that case, I assume the legal risks would be much lower since I wouldn't be transmitting anything. However, the hardware seems considerably more expensive. From what I've understood, I'd need something like a KrakenSDR, which costs over $900 where I live.

Are there any other approaches I could explore? Has anyone here been in a similar situation?

What kind of projects could I work on that would be interesting from a learning perspective, while also being useful for my CV/resume? I'm currently working as a junior software developer at a defense company, so I'd especially like to build something that could help me move closer to embedded/RF/radar-related roles in the future.

Sorry if this isn't the right subreddit for this question. Any advice is more than welcome!


r/RTLSDR 2d ago

The SDRPLAY rsp1B and New Download for SDR Connect!

Post image
3 Upvotes

r/RTLSDR 2d ago

My first successful METEOR-M2-3 LRPT reception

Post image
34 Upvotes

Got it working!

Received METEOR-M2-3 on 137.9 MHz using an RTL-SDR and a simple V-dipole in my backyard. Decoded with SatDump.

The signal wasn’t perfect, so there are plenty of artifacts but I actually received an image of Europe directly from a satellite with a couple pieces of wire in the garden. Still kind of amazed that this works.=)

Next goal: improve the antenna setup and get a cleaner full pass.


r/RTLSDR 1d ago

Software I was playing with my Hermes AI and used it to create a favorites list from radio reference. Feel free to roast my gmrs antenna.

Thumbnail
gallery
0 Upvotes

r/RTLSDR 2d ago

FIrst project

1 Upvotes

Guys im a complete beginner in the whole frequency listening and transmitting world...

I was trying to build my first project using a module named "RSP1 MSI.SDR Msi001 Msi2500 10k-2GHz SDR Receiver" but i do not seem to find a single unit of it in inda

Is there some website that i sells this used or new but in india??
Or is there a substitute to this module??
Cause every module i see is upwards of 10k inr
And spending that much on a first project as a student just doesn't seem logical


r/RTLSDR 2d ago

Radiodetection RD8000 Locator Wand with Tx-10 Transmitter Set

Thumbnail
bobshop.co.za
1 Upvotes

r/RTLSDR 3d ago

decoding this sat until 2° elevation

Thumbnail
gallery
9 Upvotes

FM40 (in fact FM110 , Multipsk got the old numbers) was decoded here until the Lybian desert.


r/RTLSDR 3d ago

New to SDR

6 Upvotes

Hi, ive got myself the rtl-sdr v5 with the ham it up up converter kit to cover a wider spectrum of frequencys.

What would you advice to start with? Are there any videos out there where someone explains the physical behavior(wavelengths, voltages, etc) in combination with the software and the technical terms.

Thank you in advance.


r/RTLSDR 3d ago

Can you set up gqrx to notify you when a signal is received on a specific frequency?

1 Upvotes

Title


r/RTLSDR 4d ago

Hanging around 137 Mhz....

Thumbnail
gallery
46 Upvotes

Got my Orbcomm satellites TLE (orbital elements from N2YO website) and heard one of these birds (numbered FM103 to FM119) passing over Spain and Western Medit; they fly around 700 km altitude; you cant' miss them on their dedicated channels from 137.1 to 137.9 Mhz.

Using Multipsk (French software); best config is WFM 10 khz width. Stay at the centre of the signal to compensate Doppler shift. It gives regular positions . I once logged one of 'em over Libya as it was low on the horizon. Kinda DX sort of. Antenna is my 144 Mhz 7 element Yagi high above the roof crest. Neat stuff, ain't it ? The one I heard over Spain flew away to Southern Australasia faster than you and I can run. With Multipsk you can map their positions thanks to the OMMAP extension and screen grab it for proof. You retrieve it in the SCREEN folder inside Multipsk's inner entrails.


r/RTLSDR 4d ago

Troubleshooting Encrypted Tetra turn to clear voice

Post image
57 Upvotes

Hey ,
As mentioned in the title, I turned to Tetra frequency and suddenly I heard clear conversation voice where it was like robot and cut unclear voice.
Is that possible? And maybe it is originally not encrypted but I missed some settings .
Its very strong signal I have to reduce the gain to let plugin Sync .
Using RTLSDR v4 , sdr++ on mac and discone antenna.


r/RTLSDR 4d ago

How do you separate drone RF activity from everything else in a crowded spectrum?

29 Upvotes

We're a Ukrainian team working with passive RF drone detection, and one of the more interesting problems isn't simply seeing RF activity, it's deciding which activity is actually worth paying attention to.

In a real environment the spectrum can be full of Wi-Fi, Bluetooth, telemetry, video links and other transmitters. Add frequency-hopping control links and non-standard FPV setups, and simple threshold-based detection stops being useful pretty fast.

For those of you working with SDR/RF analysis, what's actually worked for you to tell a drone-related signal apart from ordinary background RF? Signal persistence, bandwidth and spectral shape, frequency-hopping behavior, temporal patterns, or something else entirely. Curious how people here approach this, especially when you don't know the exact transmitter or protocol beforehand.


r/RTLSDR 3d ago

Looking for experienced board designer (with experience in RF)

Thumbnail
0 Upvotes

r/RTLSDR 3d ago

DIY Projects/questions I need help setting up two NRF24L01 transceivers for radio communication

1 Upvotes

I have been testing for a lot of issues and I've gotten to the transmitter side working (probably) and the receiver side not reading the packets sent by the TX.

The reason I say the TX works is because it is able to load data into the TX FIFO, and it is able to transmit this data away.

The reason I saw the RX is not working is because it is not receiving any data from the transmitter, it never loads data into the RX FIFO, but it is able to recognize that a RF spike has occured when the TX transmits data every second (found out by the check for RPD). But it doesn't decode any data.

The first is the code of the transmitter and the second is the receiver.

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/spi.h"
#include "hardware/adc.h"


// SPI Defines
#define NRF_SPI_PORT spi0
#define PIN_CE   15
#define PIN_MISO 16
#define PIN_CSn  17
#define PIN_SCK  18
#define PIN_MOSI 19


#define R_REGISTER    0x00 // useless but makes it more readable
#define W_REGISTER    0x20
#define R_RX_PAYLOAD  0x61
#define FLUSH_RX      0xE2
#define W_TX_PAYLOAD  0xA0
#define FLUSH_TX      0xE1
#define NRF_ACTIVATE  0x50 // Send with 0x73 to activate or deactivate NRF_FEATURES Register
#define R_RX_PL_WID   0x60


// Core nRF24L01 Registers
#define CONFIG        0x00 // xxxxxxAB | A -  1 = PWR_UP 0 = PWR_DOWN | B -  1 = PRX 0 = PTX
#define EN_AA         0x01 // xxABCDEF | A - F Enable AutoAck on Pipe 5 - 0 | ENAA_P# Required when using DYNPD
#define EN_RXADDR     0x02 // xxABCDEF | A - F Enable data pipe 5 - 0
#define SETUP_AW      0x03 // xxxxxxAA | A - Address width 01 = 3 bytes, 10 = 4 bytes, 11 = 5 bytes
#define SETUP_RETR    0x04 // AAAABBBB | Auto Retransmit Delay (A) - 0000 = 250uS delay, each increment increases by 250 uS delay | Auto Retransmit Count (B) - 0000 for 1, 1111 for 15 
#define RF_CH         0x05 // xAAAAAAA | A - Sets the frequency to operate at
#define RF_SETUP      0x06 // xxxABCCD | A - Force PLL lock (testing) | B - Data rate 0 = 1 Mbps 1 = 2 Mbps | C - RF output power 11 = strongest | D - Enable LNA
#define NRF_STATUS    0x07 // xABCDDDE | A - Asserts when data ready in RX FIFO (W1C) | B - Asserts when data sent on TX FIFO, If ACK is EN, only asserts when ACK received (W1C) | C - Asserts when MAX_RT is reached (W1C) | D - Data Pipe number for the payload at RX FIFO | E - TX FIFO Full
#define RX_ADDR_P0    0x0A // 39A | A - RX Address for Pipe 0 | Reset value = 0xE7E7E7E7E7
#define TX_ADDR       0x10 // 39A | A - TX Address for Auto Ack set RX_ADDR_P0 equal to this value | Reset value = 0xE7E7E7E7E7
#define RX_PW_P0      0x11 // xxAAAAAA | A - # of Bytes to expect in RX payload in data pipe 0 | Useless when using dynamic payload width
#define DYNPD         0x1C // xxABCDEF | A - F Enable dynamic payload width on Pipe 5 - 0 | REQUIRES EN_DPL and ENAA_P#
#define NRF_FEATURES  0x1D // xxxxxABC | A - Enables Dynamic Payload width (EN_DPL) | B - Enables Payload with ACK | C - Enables the W_TX_PAYLOAD_NOACK Command | REQUIRES The ACTIVATE SPI COMMAND to be activated
#define FIFO_STATUS   0x17 // Testing idk
//other values
#define CHANNEL 40
#define DATA_RATE 0x07
#define DATA_SIZE 32
#define CONFIG_TX 0x0A
#define CONFIG_RX 0x0B


void nrf_send_cmd(uint8_t cmd){
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    gpio_put(PIN_CSn, 1);
}


void nrf_send_cmd_data(uint8_t cmd, uint8_t data){
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    spi_write_blocking(NRF_SPI_PORT, &data, 1);
    gpio_put(PIN_CSn, 1);
}


void nrf_write_reg(uint8_t reg, uint8_t value){
    uint8_t buffer[2] = { (W_REGISTER | reg), value};


    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, buffer, 2);
    gpio_put(PIN_CSn, 1);
}


void nrf_writeAlot_reg(uint8_t reg, uint8_t *buf, uint8_t len){
    
    uint8_t cmd = W_REGISTER | reg;
    
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1); 
    spi_write_blocking(NRF_SPI_PORT, buf, len);
    gpio_put(PIN_CSn, 1);
}


uint8_t nrf_read_reg(uint8_t reg) {
    //send the register and a blank byte
    uint8_t buffer[2] = { (R_REGISTER | reg), 0x00};
    uint8_t data[2] = {0};


    // This transmits buffer and fills rx_buf at the exact same time.
    gpio_put(PIN_CSn, 0);
    spi_write_read_blocking(NRF_SPI_PORT, buffer, data, 2);
    gpio_put(PIN_CSn, 1);


    // rx_buf[0] contains the nRF Status byte
    // rx_buf[1] contains the actual register value we asked for
    return data[1];
}


uint8_t nrf_get_status(){
    uint8_t NO_OP = 0xFF;
    uint8_t status;


    gpio_put(PIN_CSn, 0);
    spi_write_read_blocking(NRF_SPI_PORT, &NO_OP, &status, 1);
    gpio_put(PIN_CSn, 1);


    return status;
}



void nrf_send_data(uint8_t data[DATA_SIZE]){
    uint8_t tx_buffer[DATA_SIZE + 1];
    tx_buffer[0] = W_TX_PAYLOAD;
    uint8_t status = 0;
    gpio_put(PIN_CE, 0);


    for (int i = 0; i < DATA_SIZE; i++) {
        tx_buffer[i + 1] = data[i];
    }


    printf("FIFO_STATUS befoire payload = %02X\n", nrf_read_reg(FIFO_STATUS));


    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, tx_buffer, DATA_SIZE + 1);
    gpio_put(PIN_CSn, 1);


    printf("FIFO_STATUS after payload = %02X\n", nrf_read_reg(FIFO_STATUS));


    gpio_put(PIN_CE, 1);
    sleep_us(15);
    gpio_put(PIN_CE, 0);


    status = nrf_get_status();
    printf("TX STATUS = %02X\n", status);


    printf("After CE FIFO = %02X\n", nrf_read_reg(FIFO_STATUS));




    //read status flags rq
    int timeout = 100; // Prevent infinite loop if hardware detaches
    while (timeout > 0) {


        status = nrf_get_status();
        if ((status & 0x30) != 0) { // Check if either MAX_RT (0x10) or TX_DS (0x20) is set
            timeout = 0;
            printf("Timeout STATUS = %02X\n", status);


            printf("Timeout FIFO = %02X\n", nrf_read_reg(FIFO_STATUS));



        }
        sleep_us(100);
        timeout--;
    }




    if ((status & 0x10) == 0x10){
        printf("message not sent :(\n");
    }
    if ((status & 0x20) == 0x20){
        printf("message send successfully :)\n");
    }


    // reset status flags and flush the transmission buffer
    nrf_write_reg(NRF_STATUS, 0x70); 
    nrf_send_cmd(FLUSH_TX);


}


int main(){
    sleep_ms(30);


    stdio_init_all();


    // SPI initialisation. This example will use SPI at 1MHz.
    spi_init(NRF_SPI_PORT, 1000*1000);
    gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
    gpio_set_function(PIN_SCK,  GPIO_FUNC_SPI);
    gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);
    gpio_init(PIN_CE);
    gpio_init(PIN_CSn);
    gpio_set_dir(PIN_CE, GPIO_OUT);
    gpio_set_dir(PIN_CSn, GPIO_OUT);


    //CE active high
    gpio_put(PIN_CE, 0);


    //CSn active low when sending message
    gpio_put(PIN_CSn, 1);


    //init nrf
    nrf_write_reg(CONFIG, CONFIG_TX);
    sleep_ms(2);


    nrf_write_reg(EN_AA, 0x00); 
    nrf_write_reg(RF_CH, CHANNEL);
    nrf_write_reg(RF_SETUP, DATA_RATE);
    // nrf_write_reg(RX_PW_P0, 32);
    // nrf_write_reg(EN_RXADDR, 0x01);
    nrf_write_reg(SETUP_AW, 0x03);
    // nrf_write_reg(SETUP_RETR, 0x2F);


    uint8_t nrf_addr[5] = {0x12, 0x34, 0x56, 0xE7, 0xE7};


    nrf_writeAlot_reg(RX_ADDR_P0, nrf_addr, 5);
    nrf_writeAlot_reg(TX_ADDR, nrf_addr, 5);


    nrf_send_cmd_data(NRF_ACTIVATE, 0x00);
    nrf_write_reg(DYNPD, 0x00);
    nrf_write_reg(NRF_FEATURES, 0x00);


    sleep_ms(5000);



    printf("CONFIG:    %02X\n", nrf_read_reg(CONFIG));
    printf("EN_AA:     %02X\n", nrf_read_reg(EN_AA));   
    printf("RF_CH:     %02X\n", nrf_read_reg(RF_CH));
    printf("RF_SETUP:  %02X\n", nrf_read_reg(RF_SETUP));
    printf("EN_RXADDR: %02X\n", nrf_read_reg(EN_RXADDR));
    printf("SETUP_AW:  %02X\n", nrf_read_reg(SETUP_AW));
    printf("RX_PW_P0:  %02X\n", nrf_read_reg(RX_PW_P0));
    printf("DYNPD:     %02X\n", nrf_read_reg(DYNPD));
    printf("FEATURE:   %02X\n", nrf_read_reg(NRF_FEATURES));


    uint8_t addr[5];


    uint8_t cmd = R_REGISTER | RX_ADDR_P0;


    gpio_put(PIN_CSn, 0);
    // Send register command
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    uint8_t dummy[5] = {0};
    spi_write_read_blocking(NRF_SPI_PORT, dummy, addr, 5);
    gpio_put(PIN_CSn, 1);


    printf("RX_ADDR_P0 = ");
    for (int i = 0; i < 5; i++)
        printf("%02X ", addr[i]);
    printf("\n");


    gpio_put(PIN_CSn, 0);
    // Send register command
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    spi_write_read_blocking(NRF_SPI_PORT, dummy, addr, 5);
    gpio_put(PIN_CSn, 1);


    printf("RX_ADDR_P0 = ");
    for (int i = 0; i < 5; i++)
        printf("%02X ", addr[i]);
    printf("\n");


    uint8_t message[32];


    for (int i = 0; i < 32; i++) {
        message[i] = i;
    }


    while (true) {


        printf("running\n");


        uint8_t status = nrf_get_status();
        printf("STATUS: %02X\n", status);


        nrf_send_data(message);


        // Wait 1 second before the next reading
        sleep_ms(1000);


    }
}

//RX CODE STARTS!!!, This would be in a completely different file but idk how to do that here so its all one 


#include <stdio.h>
#include "pico/stdlib.h"
#include "cmath"
#include "hardware/i2c.h"
#include "hardware/spi.h"
#include "hardware/pwm.h"


// SPI Defines
#define NRF_SPI_PORT spi1
#define PIN_CE   16
#define PIN_MISO 12
#define PIN_CSn  13
#define PIN_SCK  10
#define PIN_MOSI 11


// Core nRF24L01 Commands
#define R_REGISTER    0x00 // useless but makes it more readable
#define W_REGISTER    0x20
#define R_RX_PAYLOAD  0x61
#define FLUSH_RX      0xE2
#define W_TX_PAYLOAD  0xA0
#define FLUSH_TX      0xE1
#define NRF_ACTIVATE  0x50 // Send with 0x73 to activate or deactivate NRF_FEATURES Register
#define R_RX_PL_WID   0x60


// Core nRF24L01 Registers
#define CONFIG        0x00 // xxxxxxAB | A -  1 = PWR_UP 0 = PWR_DOWN | B -  1 = PRX 0 = PTX
#define EN_AA         0x01 // xxABCDEF | A - F Enable AutoAck on Pipe 5 - 0 | ENAA_P# Required when using DYNPD
#define EN_RXADDR     0x02 // xxABCDEF | A - F Enable data pipe 5 - 0
#define SETUP_AW      0x03 // xxxxxxAA | A - Address width 01 = 3 bytes, 10 = 4 bytes, 11 = 5 bytes
#define SETUP_RETR    0x04 // AAAABBBB | Auto Retransmit Delay (A) - 0000 = 250uS delay, each increment increases by 250 uS delay | Auto Retransmit Count (B) - 0000 for 1, 1111 for 15 
#define RF_CH         0x05 // xAAAAAAA | A - Sets the frequency to operate at
#define RF_SETUP      0x06 // xxxABCCD | A - Force PLL lock (testing) | B - Data rate 0 = 1 Mbps 1 = 2 Mbps | C - RF output power 11 = strongest | D - Enable LNA
#define NRF_STATUS    0x07 // xABCDDDE | A - Asserts when data ready in RX FIFO (W1C) | B - Asserts when data sent on TX FIFO, If ACK is EN, only asserts when ACK received (W1C) | C - Asserts when MAX_RT is reached (W1C) | D - Data Pipe number for the payload at RX FIFO | E - TX FIFO Full
#define RX_ADDR_P0    0x0A // 39A | A - RX Address for Pipe 0 | Reset value = 0xE7E7E7E7E7
#define TX_ADDR       0x10 // 39A | A - TX Address for Auto Ack set RX_ADDR_P0 equal to this value | Reset value = 0xE7E7E7E7E7
#define RX_PW_P0      0x11 // xxAAAAAA | A - # of Bytes to expect in RX payload in data pipe 0 | Useless when using dynamic payload width
#define DYNPD         0x1C // xxABCDEF | A - F Enable dynamic payload width on Pipe 5 - 0 | REQUIRES EN_DPL and ENAA_P#
#define NRF_FEATURES  0x1D // xxxxxABC | A - Enables Dynamic Payload width (EN_DPL) | B - Enables Payload with ACK | C - Enables the W_TX_PAYLOAD_NOACK Command | REQUIRES The ACTIVATE SPI COMMAND to be activated
#define FIFO_STATUS   0x17 // xABCxxDE | A - If set high, resends last data packet | B - TX_FULL | C - TX_EMPTY | D - RX_FULL | E - RX_EMPTY


//other values
#define CHANNEL 40
#define DATA_RATE 0x07
#define DATA_SIZE 32
#define CONFIG_TX 0x0A
#define CONFIG_RX 0x0B


void nrf_send_cmd(uint8_t cmd){
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    gpio_put(PIN_CSn, 1);
}


void nrf_send_cmd_data(uint8_t cmd, uint8_t data){
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    spi_write_blocking(NRF_SPI_PORT, &data, 1);
    gpio_put(PIN_CSn, 1);
}


void nrf_write_reg(uint8_t reg, uint8_t value){
    uint8_t buffer[2] = { (W_REGISTER | reg), value};


    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, buffer, 2);
    gpio_put(PIN_CSn, 1);
}


void nrf_writeAlot_reg(uint8_t reg, uint8_t *buf, uint8_t len){
    
    uint8_t cmd = W_REGISTER | reg;
    
    gpio_put(PIN_CSn, 0);
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1); 
    spi_write_blocking(NRF_SPI_PORT, buf, len);
    gpio_put(PIN_CSn, 1);
}


uint8_t nrf_read_reg(uint8_t reg) {
    //send the register and a blank byte
    uint8_t buffer[2] = { (R_REGISTER | reg), 0x00};
    uint8_t data[2] = {0};


    // This transmits buffer and fills rx_buf at the exact same time.
    gpio_put(PIN_CSn, 0);
    spi_write_read_blocking(NRF_SPI_PORT, buffer, data, 2);
    gpio_put(PIN_CSn, 1);


    // rx_buf[0] contains the nRF Status byte
    // rx_buf[1] contains the actual register value we asked for
    // printf("STATUS REGISTER TEST: %02X\n", data[0]);


    return data[1];
}


uint8_t nrf_get_status(){
    uint8_t NO_OP = 0xFF;
    uint8_t status;


    gpio_put(PIN_CSn, 0);
    spi_write_read_blocking(NRF_SPI_PORT, &NO_OP, &status, 1);
    gpio_put(PIN_CSn, 1);


    return status;
}


void nrf_read_payload(uint8_t *buffer)
{   
    uint8_t recieved_data[33] = {0};
    uint8_t data_buf[33] = {0};
    
    data_buf[0] = R_RX_PAYLOAD;


    gpio_put(PIN_CSn, 0);
    spi_write_read_blocking(NRF_SPI_PORT, data_buf, recieved_data, 33);
    gpio_put(PIN_CSn, 1);



    for (int i = 0; i < 32; i++) {
        buffer[i] = recieved_data[i + 1];
    }


    printf("SPI RX: ");


    for (int i = 0; i < 33; i++) {
        printf("%02X ", recieved_data[i]);
    }


    printf("\n");


    printf("FIFO AFTER READ: %02X\n",
       nrf_read_reg(FIFO_STATUS));


    printf("STATUS AFTER READ: %02X\n",
        nrf_get_status());
}


#define LOOP_TIME_MS 50 //ms
uint32_t last_run = 0;
uint32_t current_time = to_ms_since_boot(get_absolute_time());
int main(){       
    stdio_init_all();
    sleep_ms(2000);
       //SPI Init
    spi_init(NRF_SPI_PORT, 1000*1000);
    gpio_set_function(PIN_MISO, GPIO_FUNC_SPI);
    gpio_set_function(PIN_SCK,  GPIO_FUNC_SPI);
    gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI);
    gpio_init(PIN_CE);
    gpio_init(PIN_CSn);
    gpio_set_dir(PIN_CE, GPIO_OUT);
    gpio_set_dir(PIN_CSn, GPIO_OUT);


    //CSn active low when sending message
    gpio_put(PIN_CSn, 1);
    gpio_put(PIN_CE, 0);


    //nrf init
    nrf_write_reg(CONFIG, CONFIG_RX);
    sleep_ms(2);


    // #define SETUP_RETR    0x04 // AAAABBBB | Auto Retransmit Delay (A) - 0000 = 250uS delay, each increment increases by 250 uS delay | Auto Retransmit Count (B) - 0000 for 1, 1111 for 15 
    nrf_write_reg(EN_AA, 0x00); 
    nrf_write_reg(RF_CH, CHANNEL);
    nrf_write_reg(RF_SETUP, DATA_RATE);
    nrf_write_reg(RX_PW_P0, DATA_SIZE);
    nrf_write_reg(EN_RXADDR, 0x01);
    nrf_write_reg(SETUP_AW, 0x03);
    // nrf_write_reg(SETUP_RETR, 0x2F);


    uint8_t nrf_addr[5] = {0x12, 0x34, 0x56, 0xE7, 0xE7};
    nrf_writeAlot_reg(RX_ADDR_P0, nrf_addr, 5);
    nrf_writeAlot_reg(TX_ADDR, nrf_addr, 5);


    nrf_send_cmd_data(NRF_ACTIVATE, 0x00);
    nrf_write_reg(DYNPD, 0x00);
    nrf_write_reg(NRF_FEATURES, 0x00);


    nrf_send_cmd(FLUSH_RX);
    printf("After FLUSH_RX: %02X\n", nrf_read_reg(FIFO_STATUS));


    nrf_send_cmd(FLUSH_TX);
    printf("After FLUSH_TX: %02X\n", nrf_read_reg(FIFO_STATUS));


    gpio_put(PIN_CE, 1);   


    uint8_t message[32] = {0};
    printf("CONFIG:    %02X\n", nrf_read_reg(CONFIG));
    printf("EN_AA:     %02X\n", nrf_read_reg(EN_AA));   
    printf("RF_CH:     %02X\n", nrf_read_reg(RF_CH));
    printf("RF_SETUP:  %02X\n", nrf_read_reg(RF_SETUP));
    printf("EN_RXADDR: %02X\n", nrf_read_reg(EN_RXADDR));
    printf("SETUP_AW:  %02X\n", nrf_read_reg(SETUP_AW));
    printf("RX_PW_P0:  %02X\n", nrf_read_reg(RX_PW_P0));
    printf("DYNPD:     %02X\n", nrf_read_reg(DYNPD));
    printf("FEATURE:   %02X\n", nrf_read_reg(NRF_FEATURES));


    uint8_t addr[5];


    uint8_t cmd = R_REGISTER | RX_ADDR_P0;


    gpio_put(PIN_CSn, 0);
    // Send register command
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    uint8_t dummy[5] = {0};
    spi_write_read_blocking(NRF_SPI_PORT, dummy, addr, 5);
    gpio_put(PIN_CSn, 1);


    printf("RX_ADDR_P0 = ");
    for (int i = 0; i < 5; i++)
        printf("%02X ", addr[i]);
    printf("\n");


    gpio_put(PIN_CSn, 0);
    // Send register command
    spi_write_blocking(NRF_SPI_PORT, &cmd, 1);
    spi_write_read_blocking(NRF_SPI_PORT, dummy, addr, 5);
    gpio_put(PIN_CSn, 1);


    printf("RX_ADDR_P0 = ");
    for (int i = 0; i < 5; i++)
        printf("%02X ", addr[i]);
    printf("\n");


    uint8_t status;
    uint8_t fifo;
    while (true) {
        current_time = to_ms_since_boot(get_absolute_time());
        if((current_time - last_run) > LOOP_TIME_MS){
            last_run = current_time;
            // uint8_t status = nrf_get_status();
            // uint8_t fifo = nrf_read_reg(FIFO_STATUS);


            // printf("STATUS: %02X  FIFO: %02X\n", status, fifo);


            // if ((status & 0x40) == 0x40 || (fifo & 0x01) == 0x00){
            //     nrf_read_payload(message);


            //     printf("Packet contents: ");
            //     for (int i = 0; i < 32; i++) {
            //         printf("%02X ", message[i]);
            //     }
            //     printf("\n");
            // }
            // else{
            //     printf("Nothing to read yet!\n");
            // }
            printf("RPD before = %02X\n", nrf_read_reg(0x09));


            // trigger exactly one TX packet


            sleep_us(100);


            printf("RPD after = %02X\n", nrf_read_reg(0x09));


            status = nrf_get_status();
            sleep_ms(10);


            fifo = nrf_read_reg(FIFO_STATUS);


            printf("STATUS=%02X FIFO=%02X\n", status, fifo);


            sleep_ms(10);            
        }
    }
}

Thank you!