Hi,
I have a G120HDR and an Arduino Pro Mini, with two Nordic NRF24L01 spi modules.
I mounted a module for each MCU, on NETMF using Gralin library, and on Arduino using RF24 (full) library.
I’m trying to make a simple send/receive (unidirectional) communication between the two boards. (NETMF is receiving, arduino is transimitting)
I succeded (I hope) in connecting hardware, since getting infos from the NRF24L01 board, it replies with correct data. So I expect SPI is working on both boards.
If I connect two boards on the G120 and i try to send and receive, it works, so the code in netmf should be good.
I cannot try the same thing on arduino since the pro mini ha s only one spi port, but I’m using the GettingStarted sample, so I think is correct.
SHould there be a known difference to be considered, or someone has an idea of what can I try?
Here the code on NETMF side:
static NRF24L01Plus n;
public static void Main()
{
n = new NRF24L01Plus();
n.OnDataReceived += n_OnDataReceived;
n.OnTransmitSuccess += n_OnTransmitSuccess;
n.OnTransmitFailed += n_OnTransmitFailed;
n.Initialize(SPI.SPI_module.SPI1, Pin.P0_6, Pin.P0_1, Pin.P2_0);
byte[] address = Encoding.UTF8.GetBytes("NetP1");
n.Configure(address, 10, NRFDataRate.DR1Mbps);
n.SetAddress(AddressSlot.Zero, address);
n.SetAddress(AddressSlot.One, address);
n.SetAddress(AddressSlot.Two, address);
n.SetChannel(10);
n.Enable();
Thread.Sleep(Timeout.Infinite);
}
static void n_OnDataReceived(byte[] data)
{
Debug.Print(new string(Encoding.UTF8.GetChars(data)));
}
and on the Arduino side:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9,10);
void setup(void)
{
Serial.begin(9600);
printf_begin();
printf("\n\rRF24\n\r");
//
// Setup and configure rf radio
//
radio.begin();
// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);
radio.setChannel(10);
// optionally, reduce the payload size. seems to
// improve reliability
//radio.setPayloadSize(8);
----tryed with or without
radio.enableDynamicPayloads();
radio.setAutoAck(true);
radio.setCRCLength(RF24_CRC_16);
------
//
// Open pipes to other nodes for communication
//
// This simple sketch opens two pipes for these two nodes to communicate
// back and forth.
// Open 'our' pipe for writing
// Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
radio.openWritingPipe((uint64_t)0x4E65745031LL);
//
// Dump the configuration of the rf unit for debugging
//
radio.printDetails();
}
void loop(void)
{
// Take the time, and send it. This will block until complete
unsigned long time = millis();
printf("Now sending %lu...",time);
bool ok = radio.write( &time, sizeof(unsigned long) );
if (ok)
printf("ok...");
else
printf("failed.\n\r");
// Try again 1s later
delay(3000);
}
Thanks for help!
J