Node 1 for WSN communication, sending Pot values over nRF

Dependencies:   mbed nRF24L01P

Fork of WSN_Node1 by Akashlal Bathe

Files at this revision

API Documentation at this revision

Comitter:
akashlal
Date:
Tue Jul 12 15:52:34 2016 +0000
Parent:
5:c44298b018f4
Commit message:
na

Changed in this revision

node1.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c44298b018f4 -r 47347a642702 node1.cpp
--- a/node1.cpp	Mon Jun 06 11:05:41 2016 +0000
+++ b/node1.cpp	Tue Jul 12 15:52:34 2016 +0000
@@ -1,10 +1,7 @@
 /****PIPE1 Transmitter****/
-
 #include "mbed.h"
-#include "nRF24L01P.h"
- 
+#include "nRF24L01P.h" //Including nRF library
 Serial pc(USBTX, USBRX); // tx, rx
- 
 nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4);    // mosi, miso, sck, csn, ce, irq
 DigitalOut RedLED(PTA5);
 AnalogIn pot(A0);
@@ -14,17 +11,13 @@
     char count[1];
     char TxDataCnt;
     char temp;
-    
     //set tx and rx address for pipe1: 5bytes long; different for every pipe
     long long TxAddress_PIPE1 = 0xE2E2E2E2E2;
     long long RxAddress_PIPE1 = 0xE2E2E2E2E2;
- 
     my_nrf24l01p.powerUp();
     my_nrf24l01p.setRfFrequency(2410);
-    
     //set tx address
     my_nrf24l01p.setTxAddress(TxAddress_PIPE1);
-    
     //set rxaddress with default width for specified pipe
     my_nrf24l01p.setRxAddress(RxAddress_PIPE1, DEFAULT_NRF24L01P_ADDRESS_WIDTH, NRF24L01P_PIPE_P1);
     
@@ -33,32 +26,21 @@
     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 - PIPE1   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
-    
     pc.printf( "Wirelesss sensor network \r\n");
-        
     TxDataCnt = 1;
-    
     //set transfer size for each pipe
     my_nrf24l01p.setTransferSize(TxDataCnt, NRF24L01P_PIPE_P1);
     my_nrf24l01p.enable();
-    
-    char pot_val;
-    
+    char pot_val; //Variable to store value of potentiometer
     while (1) {
-        
         //adjusting data to 0-255 with char data type
         pot_val = 255*(pot.read());
-        
         count[0] = pot_val;
-        
         //transmit on specified pipe
         temp = my_nrf24l01p.write( NRF24L01P_PIPE_P1,count, TxDataCnt );
- 
-        pc.printf( "Sending %d bytes from PIPE1; POT=%d\r\n",temp,count[0]);
- 
+        pc.printf( "Sending %d bytes from PIPE1; POT=%d\r\n",temp,count[0]); //Print on serial terminal
         // Toggle LED1 (to help debug Host -> nRF24L01+ communication)
         RedLED = !RedLED;
-          
         wait(1);
     }
 }
\ No newline at end of file