MBED LPC1768 NRF24L01 question

12 Apr 2018

Hello Everyone,

I am trying to get my MBED LPC1768 board working with nrf24l01. I have seen that there are a number of libraries some which are ported from the Arduino TMRh20 . I have tried to get 2 arduinos talk to each other it works without problems, but with my embed as a receiver i could never get it to work. my nrfs have a base module with a regulator and capacitor... Any got this working with mbed-arduino communication ? please let me know if anyone had any luck and can share some info with some libs and source .

Many Thanks Nart

22 Apr 2018

Hello Nart,

You can try to use Maniacbug's RF24 Arduino library ported to MBED by Akash Vibhute.

Transmitter program running on Arduino board

#include "Arduino.h"
#include "RF24.h"

const int       ledPin = 13;
const uint64_t  ADDRESS = 0xF0F0F0F0F0F0F0F0LL; // The addresses that this primary TX is going to use for transmission.
                                                // It shall match the RX address of the target primary RX.
                                                // To receive automatic acknowledge, pipe 0 RX address (RX_ADDR_P0) of this PTX
                                                // is set to the actual TX_ADDR when calling stopListening().

RF24            radio(6, 7);                    // ce, csn

bool sendRadioMsg()
{
    uint8_t dataToSend = digitalRead(ledPin);
    radio.stopListening();
    radio.openWritingPipe(ADDRESS);
    return radio.write(&dataToSend, 1);
}

void setup(void)
{
    Serial.begin(9600);
    Serial.println("Starting ...");
    pinMode(ledPin, OUTPUT);
    radio.begin();
    radio.setPALevel(RF24_PA_LOW);
    radio.setRetries(5, 15);
    radio.setPayloadSize(1);
    radio.setAutoAck(true);
}

void loop(void)
{
    digitalWrite(ledPin, !digitalRead(ledPin));
    if (sendRadioMsg())
        Serial.println("Radio message was delivered successfully.");
    else
        Serial.println("Radio message was not delivered.");
    delay(2000);
}

Receiver program running on MBED board

#include "mbed.h"
#include "RF24.h"

const uint64_t  ADDRESS = 0xF0F0F0F0F0F0F0F0L;

DigitalOut      led(LED1);
uint8_t         dataReceived;
RF24            radio(p11, p12, p13, p14, p15); // mosi, miso, sck, ce, csn

int main()
{
    printf("Starting ...\r\n");
    radio.begin();
    radio.setPALevel(RF24_PA_LOW);
    radio.setRetries(5, 15);
    radio.setPayloadSize(1);
    radio.setAutoAck(true);
    radio.openReadingPipe(0, ADDRESS);  // use pipe 0 of this slave to receive messsages and send back auto acknowledgement
    while (true)
    {
        if (radio.available())
        {
            radio.read(&dataReceived, 1);
            printf("A radio message received.\r\n");
            led = dataReceived;
        }
    }
}