Print in oled screen radio.printDetails();

Hello everyone. How do I display radio.printDetails(); on a 0.96" oled screen?
This is the code:

#include <SPI.h>
#include <RF24.h>
#include <printf.h>

RF24 radio(7, 8);

byte addresses[][6] = {"1Node", "2Node"};


void setup() {
  radio.begin();
  radio.setPALevel(RF24_PA_LOW);
  
  radio.openWritingPipe(addresses[0]);
  radio.openReadingPipe(1, addresses[1]); 
  radio.startListening();
  
  Serial.begin(9600);
  printf_begin();

  radio.printDetails();
  
}

void loop() {
//  empty

}

How am I supposed to display the results or the data from the radio.printDetails(); on a 0.96" OLED screen? I only need these values:

EN_AA
EN_RXADDR
RF_CH
RF_SETUP
CONFIG
The values will look something like this:
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f

Connect the circuit correctly and program it correctly, then follow the instructions from where you copied it.

1 Like

That code does not appear to have that ability, find a different library that can print to the display you want. You will likey also need a library for the display.

Its because i want to check the details when the Arduino is connected via battery (2 18650 batteries)

All those register values are accessed with the library's read_register() function. See RF24.h:

    /**
     * Read single byte from a register
     *
     * @param reg Which register. Use constants from nRF24L01.h
     * @return Current value of register @p reg
     */
    uint8_t read_register(uint8_t reg);

Unfortunately, that function is private within the RF24 class. If it's really that important, you can modify RF24.h to make it public. You could even put in a Pull Request to the library's GitHub for that.

@memind - RadioHead has, in its documentation, how to ask a question about the library.

You can also find online help and discussion at https://groups.google.com/group/radiohead-arduino Please use that group for all questions and discussions on this topic. Do not contact the author directly,

https://www.airspayce.com/mikem/arduino/RadioHead/

Take a look at the class documentation:
https://nrf24.github.io/RF24/classRF24.html

There is a function called encodeRadioDetails(); which will allow you to print the config data to an OLED etc.
https://nrf24.github.io/RF24/classRF24.html#abe54fe7f4b776ca4927dcf8435ca1133

/*
  If your serial output has these values same then Your nrf24l01 module is in working condition :
  
  EN_AA          = 0x3f
  EN_RXADDR      = 0x02
  RF_CH          = 0x4c
  RF_SETUP       = 0x03
  CONFIG         = 0x0f
 
 */

#include <SPI.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128  // OLED display width, in pixels
#define SCREEN_HEIGHT 64  // OLED display height, in pixels
RF24 radio(7, 8);

byte addresses[][6] = { "1Node", "2Node" };

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {  // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for (;;)
      ;
  }
  delay(2000);
  display.clearDisplay();

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println("test");
  display.display();

  radio.begin();
  radio.setPALevel(RF24_PA_LOW);

  radio.openWritingPipe(addresses[0]);
  radio.openReadingPipe(1, addresses[1]);
  radio.startListening();

  Serial.begin(9600);
  uint8_t encoded_details[1] = { 0 };
  radio.encodeRadioDetails(encoded_details);
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  // Display static text
  display.println(encoded_details);
  display.display();
}

void loop() {
  //  empty
}

It is not working? What I'm I supposed to do to make it work?

Your Code:

Code from the link provided:

uint8_t encoded_details[43] = {0};
radio.encodeRadioDetails(encoded_details);

See the difference?

You can't print an entire array like that. You must access / print one element at a time.

I used this:

for (int i = 0; i < 43; i++) {
    display.print(encoded_details[i], HEX);  // Print in hexadecimal format
    display.print(" ");  // Add a space for readability

    // Move to the next line after every 16 bytes to fit the screen
    if ((i + 1) % 16 == 0) {
      display.println();
    }
  }
  display.display();
}

And then it worked. (I don't need it now anyways as I have a working nrf24l01 module now.)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.