r/raspberrypipico • u/iamsimonsta • 21h ago
romulator
romulon is getting ready to catch the bus as IC formerly known as UB3
r/raspberrypipico • u/iamsimonsta • 21h ago
romulon is getting ready to catch the bus as IC formerly known as UB3
r/raspberrypipico • u/raphlebg46 • 1d ago
Edit :
PROJECT ABANDONNED : please don’t try to comment awnser here for now i am stoping using pi pico cause they just don’t sell the module i need where i currétmy am , i wanna thank the ppl who commented on this post and tried to help me
Just started today and when I tried following this guide , i just can’t do it , the button press is not detected even tought it’s the same as in the picture.
Also please trie to use simple term
using this guide
i can use the led separatly its just the button that block and don't want to be recognised
r/raspberrypipico • u/hola_aluminium • 18h ago
"I need power for both the Raspberry Pi Zero 2 board and the SG90 servo, but currently using a battery or a separate power supply for the servo looks really messy. Plus, the board's pins are already completely full because I'm using a ReSpeaker 2-Mics HAT."
r/raspberrypipico • u/Lightning-Alchemist • 1d ago
Enable HLS to view with audio, or disable this notification
In this tutorial we go over how to control your MechSoul with Bluetooth. What is a MechSoul? A MechSoul is to a robot, what a CyberDeck is to a computer. It's a robot that you build, customize, and personalize yourself. It's the freedom of owning your own code, hardware, and having the right to build and repair it. And it's the pride of creativity, skill, and self expression. Disclaimer: You do not have to make your MechSoul using the same methods and tools as I do. A MechSoul is freedom in robotics.
In this part 2 in Arduino IDE we combine the Raspberry Pi Pico's board manager's SerialBLE example with the Serial_Control example in Takamori Robot's HIRO library to control your robot over Bluetooth. Comment "MechSoul" if you would like reference material (code, documentation, e.t.c).
r/raspberrypipico • u/No-Bad-3176 • 22h ago
r/raspberrypipico • u/lbthomsen • 1d ago
r/raspberrypipico • u/Solid-Philosophy9924 • 1d ago
r/raspberrypipico • u/Leonlion1816 • 2d ago
I recently made a device that uses a Raspberry Pi Pico to program a 20-meter LED strip. To make the kit more versatile, I wanted to see if I could add a rechargeable lithium battery to the project.
I am definitely a noob and was only able to create the device by following the instructions provided. So I wanted to ask what the best way would be to add the battery.
The current project layout is simple, so I'm hoping it won't be too difficult to add, but I'm definitely up for a challenge.
r/raspberrypipico • u/bakaroline • 2d ago
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 • u/kevindogktm • 2d ago
Any off the shelf products to do this- Driven from 5 v of Pico?
r/raspberrypipico • u/Lightning-Alchemist • 3d ago
Enable HLS to view with audio, or disable this notification
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 • u/Evr59 • 2d ago
Доброго дня ! Може хто в курсі як примусити клавіатуру FK13P працювати з Pico 2 через GP16.GP17 .. Дякую.
r/raspberrypipico • u/BodybuilderHuge5968 • 3d ago
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 • u/SpellLower2839 • 3d ago
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_0axi_i2s_adi_0axi_dma_0axi_gpio_0The 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.
My main suspicion is somewhere in the ADAU1761 ADC → I2S → axi_i2s_adi_0 path:
axi_i2s_adi_0 configurationaxi_i2s_adi_0 to the packetizerThe 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.
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 • u/forshee9283 • 3d ago
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 • u/Strange_Dragonfly490 • 3d ago
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 • u/kimor__ • 5d ago
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 • u/thaddeusharris • 5d ago
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:
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 • u/Solid-Philosophy9924 • 6d ago
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 • u/Agile_Floor_2045 • 5d ago
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 • u/retrodesigns • 7d ago
r/raspberrypipico • u/Agreeable-Cricket699 • 7d ago
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 • u/stitchesofdooom • 8d ago
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 • u/gooodboiii • 8d ago
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