Jump to content
Entrax

NRF24L01 help. Does not work.

Recommended Posts

Hello 

I have problems with the two NRF24L01 and two tm4c123gxl.  I can not get 

it running.

Pins 1. Tm4c123gxl (RX): PC_6 (CE),  PD_2 (MISO),  PD_3 (MOSI),  PD_1 (CS),  PD_0 (SCK),  PE_1 (IRQ)

Pins 2. Tm4c123gxl (TX): PC_7 (CE),  PD_2 (MISO),  PD_3 (MOSI),  PD_1 (CS),  PD_0 (SCK),  PE_1 (IRQ)

I will use a simply Sketch. 

I have found this in the Forum  [Energia Library] Nordic nRF24L01+ library

I have download this Enrf24_v1_8.zip from the Forum.

Enerf24_RXdemo

#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#include <SPI.h>

Enrf24 radio(PC_6, PD_1, PE_1);
const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

const char *str_on = "ON";
const char *str_off = "OFF";

void dump_radio_status_to_serialport(uint8_t);

void setup() {
  Serial.begin(9600);

  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power
  dump_radio_status_to_serialport(radio.radioState());

  radio.setRXaddress((void*)rxaddr);
  

  
  radio.enableRX();  // Start listening
}

void loop() {
  char inbuf[33];
  
  dump_radio_status_to_serialport(radio.radioState());  // Should show Receive Mode

  while (!radio.available(true))
    ;
  if (radio.read(inbuf)) {
    Serial.print("Received packet: ");
    Serial.println(inbuf);

    if (!strcmp(inbuf, str_on))
      Serial.println("HIGH");
    if (!strcmp(inbuf, str_off))
      Serial.println("LOW");
  }
}

void dump_radio_status_to_serialport(uint8_t status)
{
  Serial.print("Enrf24 radio transceiver status: ");
  switch (status) {
    case ENRF24_STATE_NOTPRESENT:
      Serial.println("NO TRANSCEIVER PRESENT");
      break;

    case ENRF24_STATE_DEEPSLEEP:
      Serial.println("DEEP SLEEP <1uA power consumption");
      break;

    case ENRF24_STATE_IDLE:
      Serial.println("IDLE module powered up w/ oscillators running");
      break;

    case ENRF24_STATE_PTX:
      Serial.println("Actively Transmitting");
      break;

    case ENRF24_STATE_PRX:
      Serial.println("Receive Mode");
      break;

    default:
      Serial.println("UNKNOWN STATUS CODE");
  }
}

Enrf24_TXdemo

#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#include <SPI.h>

Enrf24 radio(PC_7, PD_1, PE_1);  // CE, CSN, IRQ
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

const char *str_on = "ON";
const char *str_off = "OFF";

void dump_radio_status_to_serialport(uint8_t);

void setup() {
  Serial.begin(9600);

  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);

  radio.begin();  // Defaults 1Mbps, channel 0, max TX power
  dump_radio_status_to_serialport(radio.radioState());

  radio.setTXaddress((void*)txaddr);
}

void loop() {
  Serial.print("Sending packet: ");
  Serial.println(str_on);
  radio.print(str_on);
  radio.flush();  // Force transmit (don't wait for any more data)
  dump_radio_status_to_serialport(radio.radioState());  // Should report IDLE
  delay(1000);

  Serial.print("Sending packet: ");
  Serial.println(str_off);
  radio.print(str_off);
  radio.flush();  //
  dump_radio_status_to_serialport(radio.radioState());  // Should report IDLE
  delay(1000);
}

void dump_radio_status_to_serialport(uint8_t status)
{
  Serial.print("Enrf24 radio transceiver status: ");
  switch (status) {
    case ENRF24_STATE_NOTPRESENT:
      Serial.println("NO TRANSCEIVER PRESENT");
      break;

    case ENRF24_STATE_DEEPSLEEP:
      Serial.println("DEEP SLEEP <1uA power consumption");
      break;

    case ENRF24_STATE_IDLE:
      Serial.println("IDLE module powered up w/ oscillators running");
      break;

    case ENRF24_STATE_PTX:
      Serial.println("Actively Transmitting");
      break;

    case ENRF24_STATE_PRX:
      Serial.println("Receive Mode");
      break;

    default:
      Serial.println("UNKNOWN STATUS CODE");
  }
}

When i am upload this, i don't see the Sending objects. I see only in both Serial.monitor this: "Enrf24 radio transceiver status NO TRANSCEIVER PRESENT".

Can someone help me?

Share this post


Link to post
Share on other sites

By default SPI is on SPI(2) which is PB_6 (MISO) PB_7 (MOSI) and PB_4 (SCK). Please see the wiring pin mapping the post you mentioned. It's up a couple posts. Just to make sure, do you have power and ground connected to the NRF as well?

Robert

Share this post


Link to post
Share on other sites
On 24.4.2017 at 6:23 PM, energia said:

By default SPI is on SPI(2) which is PB_6 (MISO) PB_7 (MOSI) and PB_4 (SCK). Please see the wiring pin mapping the post you mentioned. It's up a couple posts. Just to make sure, do you have power and ground connected to the NRF as well?

Robert

Can i change the default SPI settings to my Pins?

Power (3,3V) and Ground are connected, but not a capacitor between ground and Power (read in tutorials). 

I have change to default SPI, it doesnt work :/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×