[Back]
Interfacing a wireless keyboard with an NRF24L01+
The NRF24L01+ is a cheap 2.4GHz wireless transciever that can be found for less than $1 on Aliexpress.
I've been using these radio modules at home for more than a year, they work at 2.4GHz but they're neither WiFi or Bluetooth, because wireless keyboards and mice also use 2.4GHz but they're neither WiFi or Bluetooth, I tought maybe I can receive data from a wireless keyboard with one of the circuits with an NRF24L01+.
NRF24L01+ radio module

If you plan to buy these modules from Aliexpress, be aware that some sellers sell fake ones, always verify the seller's reputation and the product reviews.

After searching a bit on the internet, apparently wireless keyboards and mice often use very similar/compatible radio ICs for communication, I definetely wanted to play with that.
Here I'll be documenting my progress using a wireless Logitech K400r, it's a wireless keyboard with trackpad that runs on two AA batteries.
K400r with Unifying receiver

These modules connect to a microcontroller using the SPI interface, they work at 3.3V so they can't be used on an Arduino UNO or any other microcontroller that works at 5V. If you plan on doing that, you must use a logic-level shifter, or you risk burning the module.

For this project I'll be using a custom board that has an Atmega1284P running at 3.3V, and the RF24 library.
Link to library: https://github.com/nRF24/RF24

Connecting the module to an Atmega:
NRF24L01+ uses SPI, so we just have to connect MISO to MISO, MOSI to MOSI, SCK to SCK, and then connect CE and CSN to any free pin on you MCU.

The code, using Arduino IDE:
#include "RF24.h"           //http://tmrh20.github.io/RF24/

const int Pin_NRF_CSN =         19; //CSN pin
const int Pin_NRF_CE =          A3; //CE pin

RF24 radio(Pin_NRF_CE, Pin_NRF_CSN);

byte kbuffer[32];

void setup() {
    pinMode(Pin_NRF_CE, OUTPUT);
    pinMode(Pin_NRF_CSN, OUTPUT);
    digitalWrite(Pin_NRF_CE, LOW);
    digitalWrite(Pin_NRF_CSN, HIGH);

    Serial1.begin(250000);
    Serial1.println("Hello.");

    if (!radio.begin()) {
        Serial1.println("NRF24 error.");
    } else {
        Serial1.println("NRF24 ok.");
    }
}

void loop() {
    KB_Scan();
}

void KB_Scan() {
  Serial1.println("KB_Scan() started.");
  printf_begin();
  uint8_t base_mac_address[] = {0xBB, 0x0A, 0xDC, 0xA5, 0x75};
  uint8_t base_mac_address_reversed[] = {0x75, 0xA5, 0xDC, 0x0A, 0xBB};
  radio.powerUp();
  radio.stopListening();
  radio.setAutoAck(false);
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_2MBPS);
  radio.setPayloadSize(32);
  radio.enableDynamicPayloads();
  radio.openReadingPipe(1, base_mac_address);
  radio.openReadingPipe(0, base_mac_address_reversed);
  radio.disableCRC();
  radio.printDetails();

  const uint8_t num_channels = 126;
  uint8_t values[num_channels];

#include "RF24.h" //http://tmrh20.github.io/RF24/

const int Pin_NRF_CSN = 19; //CSN pin
const int Pin_NRF_CE = A3; //CE pin

RF24 radio(Pin_NRF_CE, Pin_NRF_CSN);

byte kbuffer[32];

void setup() {
  pinMode(Pin_NRF_CE, OUTPUT);
  pinMode(Pin_NRF_CSN, OUTPUT);
  digitalWrite(Pin_NRF_CE, LOW);
  digitalWrite(Pin_NRF_CSN, HIGH);

  Serial1.begin(250000);
  Serial1.println("Hello.");

  if (!radio.begin()) {
    Serial1.println("NRF24 error.");
  } else {
     Serial1.println("NRF24 ok.");
  }
}

void loop() {
  KB_Scan();
}

void KB_Scan() {
  Serial1.println("KB_Scan() started.");
  printf_begin();
  uint8_t base_mac_address[] = {0xBB, 0x0A, 0xDC, 0xA5, 0x75};
  uint8_t base_mac_address_reversed[] = {0x75, 0xA5, 0xDC, 0x0A, 0xBB};
  radio.powerUp();
  radio.stopListening();
  radio.setAutoAck(false);
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_2MBPS);
  radio.setPayloadSize(32);
  radio.enableDynamicPayloads();
  radio.openReadingPipe(1, base_mac_address);
  radio.openReadingPipe(0, base_mac_address_reversed);
  radio.disableCRC();
  radio.printDetails();

  const uint8_t num_channels = 126;
  uint8_t values[num_channels];