Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4640

General • Pico & ESP32 & NRF24L01 Communications problem

$
0
0
Hello,

I want to communicate with pico and esp32 via nrf24l01.
I used the following library to communicate between two picos:
https://github.com/AndyRids/pico-nrf24/tree/main
But I could not establish communication between pico and esp32 via nrf24l01.

I am using esp32 c3 devkit m1.

Thank you in advance for your help.

Esp32 main.cpp

Code:

#include "nRF24L01.h"#include <RF24.h>RF24 radio(8, 7, 5000000);// CE CSNuint8_t weight = 5;const byte address[5] = {0x37, 0x37, 0x37, 0x37, 0x37};void setup() {Serial.begin(115200);delay(2000);if (!radio.begin()) {Serial.println(F("Radio hardware not responding!"));}radio.setChannel(50);radio.setDataRate(RF24_1MBPS);radio.setPALevel(RF24_PA_MAX);radio.enableDynamicPayloads();radio.setPayloadSize(1);radio.enableAckPayload();radio.enableDynamicAck();radio.setRetries(3, 10);radio.setAddressWidth(5);radio.openReadingPipe(0, address);radio.startListening();}uint32_t sendTimer = 0;void loop() {if (radio.available()) {radio.read(&weight, 1);Serial.println(weight);}}
Pico main.c

Code:

int main() {stdio_init_all();pin_manager_t my_pins = {.sck = 2, .copi = 3, .cipo = 4, .csn = 5, .ce = 6};nrf_manager_t my_config = {.channel = 50,   .address_width = AW_5_BYTES,   .dyn_payloads = DYNPD_ENABLE,   .data_rate = RF_DR_1MBPS,   .power = RF_PWR_NEG_12DBM,   .retr_count = ARC_10RT,   .retr_delay = ARD_500US};uint32_t my_baudrate = 5000000;nrf_client_t my_nrf;nrf_driver_create_client(&my_nrf);my_nrf.configure(&my_pins, my_baudrate);my_nrf.initialise(&my_config);my_nrf.payload_size(ALL_DATA_PIPES, 1);my_nrf.standby_mode();uint8_t payload_zero = 123;fn_status_t success = 0;uint64_t time_sent = 0;  // time packet was sentuint64_t time_reply = 0;  // response time after packet sentwhile (1) {my_nrf.tx_destination((uint8_t[]){0x37, 0x37, 0x37, 0x37, 0x37});time_sent = to_us_since_boot(get_absolute_time());// time sentsuccess = my_nrf.send_packet(&payload_zero, sizeof(payload_zero));time_reply = to_us_since_boot(get_absolute_time()); // response timeif (success) {printf("\nPacket sent:- Response: %lluμS | Payload: %d\n",   time_reply - time_sent, payload_zero);} else {printf("\nPacket not sent:- Receiver not available.\n");}sleep_ms(3000);}}

Statistics: Posted by juniorTR — Fri Sep 20, 2024 5:19 pm — Replies 0 — Views 49



Viewing all articles
Browse latest Browse all 4640

Trending Articles