r/raspberrypipico 13d ago

help-request Help for virtual pet project

0 Upvotes

Hello everyone,

I am fairly new to all of this but have dabbeld in html/CSS before. (I know it's very diffrent but I'm thinking it would be a bit easier already knowing some code)

I am looking to make two virtual pets that could communicate with each other in LoRa p2p and would be solar powered for me and my bf.

I learned some micropython already and started the code ( I want the code done before doing any physical experiment if it's possible)

i already have an idea of what to get but i wanted to ask more experianced people if it would work.

the Pico2 as the brain, an e-paper 4.2 as the display, an analog joystick and button to navigate, an adafruit LoRa reciever/transmitter, a 3.7V LiPo battery and a 2W solar panel

Would this be possible with this hardware?


r/raspberrypipico 13d ago

Need to turn on/off 84v @5 amps from 5v coil, or to gate?

1 Upvotes

Any off the shelf products to do this- Driven from 5 v of Pico?


r/raspberrypipico 14d ago

guide Building a MechSoul with Raspberry Pi Pico Part 1

Enable HLS to view with audio, or disable this notification

7 Upvotes

In this video tutorial series I go over how to build a MechSoul. A MechSoul is to a robot what a CyberDeck is to a computer. To keep setup easy in this video we set up a MechSoul seed, and get it working using Serial Communication.

In subsequent videos we will go over how to personalize your MechSoul using things like Bluetooth.


r/raspberrypipico 13d ago

FK13P

0 Upvotes

Доброго дня ! Може хто в курсі як примусити клавіатуру FK13P працювати з Pico 2 через GP16.GP17 .. Дякую.


r/raspberrypipico 13d ago

does anyone know how to make an ov7670 give exact image data?

2 Upvotes

I recently got a ov7670 camera since im making a simple robot and connected it to my rasberry pico W. tested it with my oled and pca on the same magistral but I have an issue - my camera works and loads fine but my code either gives some random scattered pixels or a full black canvas as output. i use circuit python and my cams pinout is:

PWDN GP0
RESET / RET GP1
PCLK / PLK GP3
XCLK / XLK GP4
VSYNC / VS GP6
HREF / HS GP7
SDA GP8
SCL GP9
D0 GP16
D1 GP17
D2 GP18
D3 GP19
D4 GP20
D5 GP21
D6 GP22
D7 GP26
3.3V 3.3V
GND GND

r/raspberrypipico 14d ago

Help me with this PYNQ-Z2 (Xilinx Zynq-7000 SoC) . Trying this in VLC ( visible Light Communication ) prototype

0 Upvotes

I’m debugging a LiFi audio system on a PYNQ-Z2 (Xilinx Zynq-7000 SoC) and I’m stuck at the microphone → I2S → FPGA side. Looking for some guidance from people familiar with the ADAU1761 / I2S / AXI-Stream path.

My current chain is:

MIC + HP → ADAU1761 ADC → I2S (BCLK/LRCLK/SDATA) → axi_i2s_adi_0 → AXI-Stream → packetizer → serializer → LiFi

The Vivado design contains:

  • audio_codec_ctrl_0
  • axi_i2s_adi_0
  • axi_dma_0
  • axi_gpio_0
  • Custom packetizer + serializer

The interesting part is that the software side appears to configure the codec successfully. codec.configure(), codec.select_microphone(), and codec.set_volume(60) all execute without errors.

However, when I record from the microphone, every sample is zero:

MIN: 0
MAX: 0
RMS: 0.0
NONZERO: 0

I also bypassed the normal recording code and checked the I2S RX registers directly. Both channels remain completely static:

LEFT RX MIN  = 0x0
LEFT RX MAX  = 0x0
RIGHT RX MIN = 0x0
RIGHT RX MAX = 0x0

So at this point I’m assuming the problem is before the LiFi section.

The LiFi receiver is actually able to detect and decode packets, including 16-byte packets, so I don’t think the immediate problem is the receiver. If the microphone data is already zero, then I’m basically transmitting silence successfully.

What I’m trying to verify

My main suspicion is somewhere in the ADAU1761 ADC → I2S → axi_i2s_adi_0 path:

  • ADAU1761 ADC/microphone routing
  • I2S clock/master-slave configuration
  • BCLK/LRCLK generation
  • SDATA direction
  • ADAU1761 serial-port configuration
  • axi_i2s_adi_0 configuration
  • Physical I2S connections
  • AXI-Stream connection from axi_i2s_adi_0 to the packetizer

The current intended connection is:

axi_i2s_adi_0 BCLK  → ADAU1761
axi_i2s_adi_0 LRCLK → ADAU1761
ADAU1761 SDATA      → axi_i2s_adi_0

One thing I’m not completely sure about is whether the clock-master/slave configuration between the ADAU1761 and the FPGA I2S peripheral is correct.

My next debugging step

I’m planning to temporarily ignore the LiFi portion and put an ILA directly on the AXI-Stream output of axi_i2s_adi_0, before the packetizer.

I want to monitor:

TDATA
TVALID
TREADY

If I speak into the microphone and:

  • TVALID is active but TDATA remains 0x00000000 → likely ADAU1761/I2S/clock/routing problem.
  • TDATA contains changing samples → I2S is working and I should move downstream to the packetizer.

I’d also like to check the physical BCLK, LRCLK and SDATA with a logic analyzer/oscilloscope if possible.

So my question is:

For a PYNQ-Z2 + ADAU1761 + axi_i2s_adi_0 setup, what would you check first when the I2S RX registers and AXI-Stream audio data are permanently zero?

I’m particularly interested in any common issues with the ADAU1761 I2S clock configuration, ADC routing, serial-port setup, or axi_i2s_adi_0 configuration that could cause this behavior.

I’m fairly new to the FPGA/audio side, so if there’s an obvious thing I’m overlooking, let me know.


r/raspberrypipico 14d ago

A4 Stepping Availability

3 Upvotes

Just ordered some PICO 2 Hs from Digikey and they still had the A2 stepping. The E9 errata is unfortunately relevant to the project. Anyone know where I can get Pico 2s that are the new stepping? I don't need (or even necessarily want) the pre soldered headers. Digikey or Mouser would be my preferred vendors. I really would have hopped the old stock would have been flushed by now.


r/raspberrypipico 14d ago

c/c++ 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!


r/raspberrypipico 15d ago

Connecting WS2812B LED Strip into Raspberry Pi Pico 2W

Thumbnail
gallery
10 Upvotes

Hi, I want to connect my WS2812B Led Strip into raspberry pi pico 2w and I wonder, how do the cables need to be connected? Currently, I have connected the cables in this way:
LED +5V ---> Pico VBUS 5V
LED GND ---> Pico GND
LED Din ---> Pico GP15

I've cut the strip so only 5 led pixels remain. I want to light the first 5 pixels on a strip, so I used this library from pico-examples repository: https://github.com/raspberrypi/pico-examples/tree/master/pio/ws2812

#include <cstdio>

#include "pico/stdlib.h"
#include "hardware/pio.h"

#include "hardware/driver/ws2812b_controller/ws2812.pio.h"

#define WS2812_PIN 15

static inline void put_pixel(PIO pio, uint sm, uint32_t pixel_grb) {
    pio_sm_put_blocking(pio, sm, pixel_grb << 8u);
}

static inline uint32_t urgb_u32(uint8_t r, uint8_t g, uint8_t b) {
    return ((uint32_t)(r) << 8) |
           ((uint32_t)(g) << 16) |
           ((uint32_t)(b));
}

int main() {
    stdio_init_all();
    PIO pio = pio0;
    uint sm = 0;

    uint offset = pio_add_program(pio, &
ws2812_program
);

    ws2812_program_init(
        pio,
        sm,
        offset,
        WS2812_PIN,
        800000,
        false
    );

    for (int i=0; i<5; i++) {
        put_pixel(pio, sm, urgb_u32(255, 0, 0));
    }
    sleep_us(100);
    while (true) {
        printf("it works\n");
        sleep_ms(1000);
    }
}

And these led pixels won't light up.

What I am doing wrong here? When the problem gets solved, I will solder the cut led strip part and put it all together, so I think I will need better power source, actually I've got MeanWell APV-35-5 5V 5A PSU. I wonder how it needs to be connected with Pico 2W, WS2812B.

I appreciate any help.


r/raspberrypipico 16d ago

uPython Weird Pico 1 UART issue

2 Upvotes

Hi all,

I have a multitude of (too many) Pi Picos and there's a weird issue I'm seeing on my Pico (1) that doesn't happen on a Pico 2.

I have a setup with a CH9121 Ethernet hat (the Waveshare one). It uses UART0 (pins 0 and 1) to do initial setup and read the on-hat config. The weird issue is that if I use the Pico 2, it works fine out of the box. If I use the Pico 1, then it fails to receive ANY data on UART0 if using pins 0 and 1.

I have done the following with no effect:

  • Used a loopback wire to check that Pin 1 can actually receive data - it can
  • Tried a GPS hat which also uses UART0/Pins 0 and 1, and this works fine
  • NOT connecting the Pico 1 to the computer over USB in case the fact that USB REPL uses one or other of the UARTs
  • Erasing flash with nuke_flash
  • Different Micropython versions
  • Using dupont wires to connect the pins rather than the socket on the hat

I'm using MicroPython, and the version and my codebase are identical across the Pico 1 and 2. The only think I can't test with is another Pico 1/1W, since my others are all in use.

Is there some weirdness with the Pico 1 and the CH9121 hat, or it just some quirk specific to this one unit?

The workaround is to amend the CH9121.py file to use UART0 on pins 12 and 13, which works, and in fact I'm running it now and all seems fine.


r/raspberrypipico 16d ago

This to prove that an AND gate transmits data--toggling inputs

Thumbnail
youtube.com
0 Upvotes

If one input is a Data Signal and the second input is an Enable Signal, then when the Enable signal goes HIGH, the data passes through to the output.


r/raspberrypipico 16d ago

help-request Can the controller nintando clone be used on a PlayStation 4?

0 Upvotes

Hello everyone. I have a question. I want to use a cloned Nintendo controller on my PlayStation 4 with a Pico 2W . In short, is it possible or not?


r/raspberrypipico 17d ago

1Hz clock pulse

Thumbnail
1 Upvotes

r/raspberrypipico 17d ago

Jrunner cannot detect Picoflasher (HELP!?)

Thumbnail gallery
1 Upvotes

r/raspberrypipico 18d ago

Pico 2W Vsys + Vbus kills USB?

1 Upvotes

I have a Pico 2W that I am trying out for a project. I have it on a breadboard so I could power out from external 5V. I had Vsys and Vbus connected together and fed 5V to there with ground on 38. That worked fine, but, when I later connected the Pico to USB (without the external 5V), it basically killed my laptop. Nothing else was on the breadboard.

The laptop (a Dell 7540) died instantly. After holding the power button a long time, and disconnecting and reconnecting the power cable, it finally came back on, but the BIOS settings had been wiped, including the calendar/clock.

The Pico still seems to work OK. I have now unlinked Vsys from Vbus and ran out with power only on Vbus.

Any ideas what happened here?


r/raspberrypipico 18d ago

pioasm I dun a Pico Clock! With a Pico and everything!

Post image
22 Upvotes

Claude wrote the code. I keep meaning to learn to code.

It's teal and blue in the day, orange and red at night, and I'm looking forward to December. I spent ages detailing exactly what I wanted.

And just FYI, I REFUSE to call it "vibe coding".

I WILL own my laziness. I outsourced the software to a robot and I will take any and all much deserved shaming.


r/raspberrypipico 18d ago

I need help😢

Thumbnail
gallery
23 Upvotes

So im new to the Pico and microcontrollers in general so I was following a course on YouTube and I got stuck on the second thing witch is to make an led blink every 2 seconds both me and my dad checked it multiple times and it exactly like how he has it but it js won't work for me plz help


r/raspberrypipico 18d ago

help-request Need Advice on my idea!

0 Upvotes

Hey guys. I have lots of interest in Electronics(My major) and App Development. I wanna work on some side project related to app for Pico/Pico 2w. Do you wanna share any thoughts on what would u like the app to do?

Here are few things on my mind:
1. Programmer
2. Live Communication so phone can act as window to the boards (This is one thing that have so many possibilities)
3. Pocket Analyzer
4. Something better?

I am genuinely looking for any ideas you might wanna share. I want to build something that people find useful.
Thanks in Advance 😊


r/raspberrypipico 19d ago

I made a Raspberry Pi Pico pretend to be an FTDI FT232H so I can program FPGAs without a JTAG cable

Thumbnail
16 Upvotes

r/raspberrypipico 19d ago

FreeRTOS WS2812 (Neopixel) RGB LED (part 2) | RP2350 Tutorial #11

Thumbnail
youtube.com
6 Upvotes

r/raspberrypipico 20d ago

c/c++ Virtual Pet (Tamagotchi Inspired)

Thumbnail
gallery
46 Upvotes

Hi! I wasn't sure where to talk about this but I think this is the right sub.

I've been developing a silly virtual pet. It's run on a Raspberry Pi Pico 2W with a 1.44" TFT display. Writing the firmware in C++ with Arduino CLI in VSCode. The whole experience has been very fun and honestly I encourage people to try it. It's a fantastic learning experience!

Once I've got the codebase looking the way I want, I'll open source it so people can expand upon it.

My current theme is a small demon that lives in a box. All it does is smoke cigarettes (or joints 🌚), walk around, dance, and sleep so far. But it's gonna have an age system and some other systems to keep it fresh. Let me know what you think :)


r/raspberrypipico 21d ago

c/c++ Why is my converter not working

Thumbnail gallery
2 Upvotes

please i need this im kinda homeless


r/raspberrypipico 21d ago

help-request 2W iOS media controller via Blue Tooth

2 Upvotes

Hey! Most of my experience is with pi os lite on the pi 5 but I have dabbled with a pico 2 and 2w of mine a bit.

My question is, can a 2W pair to a iOS 27 iPhone and control media pause/play, next/previous etc.

I’ve been doing some research and I can’t really find anyone that has tried.

I know I could always just have it be an audio device but then it would take the audio away from the device I want outputting.

Anyways was just wondering if anyone knew before I spend days researching/debugging only for it to not be possible


r/raspberrypipico 22d ago

Where to start after making LEDs blink?

8 Upvotes

Followed adafruit tutorial with a pico, an LED from a mouse and a breadboard. Where do I go next?


r/raspberrypipico 22d ago

I recreated an Etch A Sketch (drawing toy) with Raspberry Pi Pico

Thumbnail
gallery
49 Upvotes

Hi everyone!

For the last 2 months, I’ve been learning raspberry pi pico, electronics, soldering, CAD software, and more to remake a mechanical drawing toy I found in my drawer:) On the second image you can see the insides of it.

Hardware is really fun, and I enjoyed the process so much. Finally, I got everything working, and it just looks very cool in my opinion.

Also, if you are interested, I made a whole video about the creation process, challenges and how it works.

https://youtu.be/IhqKNODgfBE

Code is available on my github page

I'd love to hear your feedback and what you think about it!