Hello all,
I'm trying to set up a wireless connection between my raspberry pi and an TI MSP430G2 launchpad. I'm using RF24 library from TMRh20 at my raspberry pi and Enrf24 from spirilis with energia for my launchpad.
I want to send some analog data from launchpad to rPi using nRF24. Between rPis, nRF link is working. Aldo between launchpads also it's working. But my rPi is not able to receive the data send from launchpad.
Please find below the code I'm using :
In rPi :
#include <cstdlib> #include <iostream> #include <sstream> #include <string> #include <RF24/RF24.h> using namespace std; // Setup for GPIO 15 CE and CE0 CSN with SPI Speed @ 8Mhz RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ); // const uint64_t linkAddress = 0xE7D3F035FF; int main(int argc, char** argv){ // Setup and configure rf radio radio.begin(); // set channel radio.setChannel( 76 ); // set datarate radio.setDataRate( RF24_1MBPS ); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); radio.openWritingPipe( linkAddress ); radio.openReadingPipe( 1, linkAddress ); // Dump the configuration of the rf unit for debugging radio.printDetails(); radio.startListening(); // forever loop while (1) { // if data ready if( radio.available() ) { unsigned long data = 0; // fetch the payload while( radio.available() ) { radio.read( &data, sizeof(unsigned long) ); } printf( "Recieved data : %lu\n", data ); delay( 500 ); } } return 0; }
Once I start this( after starting my lauchpad ), the output is like this
================ SPI Configuration ================ CSN Pin = CE0 (PI Hardware Driven) CE Pin = Custom GPIO22 Clock Speed = 8 Mhz ================ NRF Configuration ================ STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 = 0xe7d3f035ff 0xe7d3f035ff RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6 TX_ADDR = 0xe7d3f035ff RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00 EN_AA = 0x3f EN_RXADDR = 0x02 RF_CH = 0x4c RF_SETUP = 0x07 CONFIG = 0x0e DYNPD/FEATURE = 0x00 0x00 Data Rate = 1MBPS Model = nRF24L01+ CRC Length = 16 bits PA Power = PA_MAX
And the program stays there -- meaning nothing is detected as received.
In my launchpad :
#include <Enrf24.h> #include <nRF24L01.h> #include <string.h> #include <SPI.h> Enrf24 radio(P2_0, P2_1, P2_2); // P2.0=CE, P2.1=CSN, P2.2=IRQ const uint8_t txaddr[] = { 0xE7, 0xD3, 0xF0, 0x35, 0xFF }; const int sensorPin = A4; int sensorValue = 0; int dataPacket = 0; void setup() { // Serial.begin(9600); SPI.begin(); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); radio.begin( 1000000, 76 ); // Defaults 1Mbps, channel 0, max TX power radio.setTXaddress((void*)txaddr); // set push button pinMode( P1_3, INPUT ); // set leds pinMode( P1_0, OUTPUT ); // do some startup animation for( int i = 0; i < 5; i++ ) { digitalWrite( P1_0, HIGH ); delay( 250 ); digitalWrite( P1_0, LOW ); delay( 250 ); } digitalWrite(P1_0, LOW); } void loop() { sensorValue = analogRead( sensorPin ); dataPacket = map( sensorValue, 0, 1023, 0, 255 ); radio.print( dataPacket ); radio.flush(); // Force transmit (don't wait for any more data) delay(50); }
Any clue what I'm doing wrong??
With thanks,
vish