Wireless sensor network to log LDR and Potentiometer values on Serial terminal. Wireless module used is NRF24L01P. This is the transmitter code.

Dependencies:   mbed nRF24L01P

Fork of kl25Z_nRF_TX by Ganesh Gore

Files at this revision

API Documentation at this revision

Comitter:
ganeshgore
Date:
Mon Jun 01 05:20:18 2015 +0000
Child:
1:52659fc8b32a
Commit message:
test

Changed in this revision

Transmitter.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
nRF24L01P.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Transmitter.cpp	Mon Jun 01 05:20:18 2015 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+#include "nRF24L01P.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+nRF24L01P my_nrf24l01p(PTD6, PTE3, PTE2, PTB8, PTB9, PTD0);    // mosi, miso, sck, csn, ce, irq
+DigitalOut RedLED(LED1);
+
+int main()
+{
+    char count[2];
+    char TxDataCnt;
+    char temp;
+
+
+    my_nrf24l01p.powerUp();
+    my_nrf24l01p.setRfFrequency(2410);
+
+    // Display the (default) setup of the nRF24L01+ chip
+    pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_nrf24l01p.getRfFrequency() );
+    pc.printf( "nRF24L01+ Output power : %d dBm\r\n",  my_nrf24l01p.getRfOutputPower() );
+    pc.printf( "nRF24L01+ Data Rate    : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
+    pc.printf( "nRF24L01+ TX Address   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
+    pc.printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
+
+    pc.printf( "Simple Transmitter (0 - 9 Counter) \r\n");
+
+    TxDataCnt = 2;
+    my_nrf24l01p.setTransferSize(TxDataCnt);
+
+    my_nrf24l01p.enable();
+
+    count[0] = 0x01;
+    count[1] = 0x01;
+
+    while (1) {
+
+        // Send the Transmit buffer via the nRF24L01+
+        temp = my_nrf24l01p.write( NRF24L01P_PIPE_P0,count, TxDataCnt );
+
+        pc.printf( "Sending %d - %d %d\r\n",temp,count[0],count[1]);
+
+        // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
+        RedLED = !RedLED;
+            
+        count[1]++;
+        
+        wait(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 01 05:20:18 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF24L01P.lib	Mon Jun 01 05:20:18 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Owen/code/nRF24L01P/#8ae48233b4e4