public void Start() { /* This code assumes a pin configuration as follows: * * nRF24 -> Netduino 2 Purpose * -------- ---------- -------------- * 1 (GND) -> GND Ground * 2 (VCC) -> 3V3 3v Power * 3 (CE) -> D9 Chip Enable * 4 (CSN) -> D10 Chip Select * 5 (SCK) -> D13 SPI Serial Clock (SCLK) * 6 (MOSI)-> D11 SPI Transmit (MOSI) * 7 (MISO)-> D12 SPI Recieve (MISO) * 8 (IRQ) -> D8 Interupt * */ // Initialize the radio on our pins _radio.Initialize(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8); _radio.Configure(new byte[] { 0xF5, 0xF0, 0xF0, 0xF0, 0xF2 }, 76, NRFDataRate.DR1Mbps); _radio.OnDataReceived += _radio_OnDataReceived; _radio.Enable(); Debug.Print("Listening on: " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Zero, 5)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.One, 5)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Two, 5)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Three, 5)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Four, 5)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Five, 5))); _timer = new Timer(TimerFire, null, new TimeSpan(0, 0, 0, 10), new TimeSpan(0, 0, 0, 3)); }
static void Main(string[] args) { SPI SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1)); OutputPort nCE = new OutputPort(Cpu.Pin.GPIO_Pin2, true); InterruptPort nINT = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); NRF24L01Plus n = new NRF24L01Plus(); n.Initialize(SPIport, nCE, nINT); byte[] address = n.GetAddress(AddressSlot.Zero, 5); Console.WriteLine("First Address: " + ByteArrayToHexString(address)); byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 }; n.SetAddress(AddressSlot.Zero, b, false); address = n.GetAddress(AddressSlot.Zero, 5); Console.WriteLine("Second Address: " + ByteArrayToHexString(address)); nCE.Dispose(); nINT.Dispose(); }
public static void Main() { count = 0; oled.Inital(); Thread.Sleep(100); oled.DisplayString("***"); globalSPIDevice.Config = nrf24L01PConfig; _radio.Initialize(); //TX // _radio.Configure(new byte[] { 138, 138, 138 }, 76, NRFDataRate.DR1Mbps); // _radio.SetAddress(AddressSlot.One, new byte[] { 0, 0, 1 }); //RX _radio.Configure(new byte[] { 0xF0, 0xF0, 0xE1 }, 76, NRFDataRate.DR1Mbps); _radio.SetAddress(AddressSlot.One, new byte[] { 0, 0, 2 }); _radio.OnDataReceived += _radio_OnDataReceived; _radio.Enable(); string outputinfo = "Listening on: " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Zero, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.One, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Two, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Three, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Four, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Five, 3)); Debug.Print(outputinfo); //TX // _timer = new Timer(TimerFire, null, new TimeSpan(0, 0, 0, 2), new TimeSpan(0, 0, 0,5)); globalSPIDevice.Config = oledSpiConfig; oled.DisplayString(outputinfo); Thread.Sleep(50); globalSPIDevice.Config = nrf24L01PConfig; Thread.Sleep(Timeout.Infinite); /* * * globalSPIDevice.Config = oledSpiConfig; * oled.DisplayString("Receiving ---"); * Thread.Sleep(100); * globalSPIDevice.Config = nrf24L01PConfig; */ }