element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Forum How to use raspberry pi and MSP430G2553 launchpad with nRF24L01?
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 6 replies
  • Subscribers 4 subscribers
  • Views 1654 views
  • Users 0 members are here
Related

How to use raspberry pi and MSP430G2553 launchpad with nRF24L01?

vish
vish over 10 years ago

Hi community,

 

I'm trying to make a wireless communication link between my raspberry pi and MSP430G2553 launchpad using nRF24L01 modules.

 

I'm using RF24 library for raspberry pi and Enrf24 library for launchpad.

 

First thing I tried was to configure one of mu launchpad+nRF module as transmitter and other pair as a reciever( as in the sample comes with Enrf24 library ) and it works fine.

 

Now I want my raspberry pi to be the receiver. But Pi is not at all receiving the message.

 

These are the source files I'm using :

 

// For launchpad : MSP430G2553 as transmitter

#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#include <SPI.h>

// For MSP430G2553
Enrf24 radio(P2_0, P2_1, P2_2);  // P2.0=CE, P2.1=CSN, P2.2=IRQ

const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

const char *str_on = "ON";
const char *str_off = "OFF";

void setup() {

  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);

  radio.begin();  // 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() {

      digitalWrite( P1_0, LOW );
      radio.print(str_on);
      radio.flush();  // Force transmit (don't wait for any more data)
      delay(250);
   
      digitalWrite( P1_0, HIGH );
      radio.print(str_off);
      radio.flush();  //
      delay(250);
}

 

// For raspberry pi, as receiver
#include <cstdlib>
#include <iostream>
#include <RF24/RF24.h>

using namespace std;

// Radio pipe addresses for the 2 nodes to communicate.
// First pipe is for writing, 2nd, 3rd, 4th, 5th & 6th is for reading...
const uint64_t pipes[6] =
                    {
                        0xDEADBEEF01LL,
                        0xDEADBEEF01LL,
                        0xDEADBEEF01LL,
                        0xDEADBEEF01LL,
                        0xDEADBEEF01LL,
                        0xDEADBEEF01LL
                       
                        // 0x01EFBEADDELL,
                        // 0x01EFBEADDELL,
                        // 0x01EFBEADDELL,
                        // 0x01EFBEADDELL,
                        // 0x01EFBEADDELL,
                        // 0x01EFBEADDELL
                    };

// CE Pin, CSN Pin, SPI Speed

// Setup for GPIO 22 CE and GPIO 25 CSN with SPI Speed @ 1Mhz
//RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_18, BCM2835_SPI_SPEED_1MHZ);

// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 4Mhz
//RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);

// Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_8MHZ); 


int main(int argc, char** argv)
{
    uint8_t len;

    // Refer to RF24.h or nRF24L01 DS for settings
    radio.begin();
    radio.enableDynamicPayloads();
    radio.setAutoAck(1);
    radio.setRetries(15,15);
    radio.setDataRate(RF24_1MBPS);
//    radio.setPALevel(RF24_PA_MAX);
    radio.setChannel(0);
    radio.setCRCLength(RF24_CRC_16);

    radio.openReadingPipe(0,pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
    radio.openReadingPipe(2,pipes[2]);
    radio.openReadingPipe(3,pipes[3]);
    radio.openReadingPipe(4,pipes[4]);
    radio.openReadingPipe(5,pipes[5]);

    // Start listening
    radio.startListening();

    // Dump the configuration of the rf unit for debugging
    radio.printDetails();
   
    printf("Output below : \n");
    delay(1);
   
    while(1)
    {
        char receivePayload[32];
        uint8_t pipe = 1;
       
        // Start listening
        radio.startListening();
                   
        while ( radio.available(&pipe) )
        {
            len = radio.getDynamicPayloadSize();
            radio.read( receivePayload, len );

            // Display it on screen
            printf("Recv: size=%i payload=%s pipe=%i\n",len,receivePayload,pipe);

            pipe++;
            // reset pipe to 0
            if ( pipe > 6 )
                pipe = 0;
        }
       
        delayMicroseconds(20);
    }
   
    return 0;
}

 

 

Can anybody please tell me what I'm doing wrong ??

 

 

 

 

I also tried to scan the spectrum using raspberry Pi in order to ensure that my connections are correct. I used this code :

 

// To report channel activity , running on raspberry pi
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <RF24/RF24.h>

using namespace std;

// CE Pin, CSN Pin, SPI Speed

// Setup for GPIO 22 CE and CE1 CSN with SPI Speed @ 1Mhz
//RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_1MHZ);

// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 4Mhz
//RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_4MHZ);

// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_26, BCM2835_SPI_SPEED_8MHZ);


// Radio pipe addresses for the 2 nodes to communicate.
//const uint8_t pipes[][6] = {"1Node","2Node"};
// const uint8_t rxAddress[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
const uint8_t rxAddress[] = { 0x01, 0xEF, 0xBE, 0xAD, 0xDE };

//const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL };


int main(int argc, char** argv){
    printf("RF24 Test Program\n");

    // Setup and configure rf radio
    radio.begin();
    // set channels to 0
    radio.setChannel( 79 );
    // optionally, increase the delay between retries & # of retries
    radio.setRetries(15,15);
    // Dump the configuration of the rf unit for debugging
    radio.printDetails();
    // start listening
    printf( "Opening Address : " );
    radio.openReadingPipe(1, rxAddress);
    printf( " [COMPLETED]\n " );
    printf( "Listening...\n" );
    radio.startListening();
    // Dump the configuration of the rf unit for debugging
    radio.printDetails();
    int16_t i, j;
    uint8_t strength, chan=0, dumpbuf[33];

    printf("nRF24L01+ Channel Activity Scan\n");
    printf("-------------------------------\n");

  // Sample channels 0 through 125.
  for (chan=0; chan < 126; chan++) {
    // Force RX off, change channel & force back on.
    radio.startListening();
    delay( 10 );
    radio.stopListening();
    delay( 10 );
    radio.setChannel(chan);
    radio.startListening();
    delay(1);  // Strawman delay to make sure the RF engine is fully spun-up on the new channel
   
    /* Sample the RPD register (Receive Power Detect, >= -64dBm signal detected)
     * 256 times, once every 4 milliseconds, incrementing the 'strength' variable each
     * time it's detected.  This will be used to produce a relative estimate of how
     * strong the ambient noise/crosstalk is on this channel.
     */
    strength = 0;
    for (i=0; i<100; i++) {
      if (radio.testRPD())
        strength++;
      delay(4);
    }
   
    /* Discover the highest bit set in our 'strength' variable; that will
     * be the size of the bargraph we'll show for this channel.
     */
    j = 0;
    for (i=7; i >= 0; i--) {
      if (strength & (1 << i)) {
        j = i+1;
        break;
      }
    }

    /* Each channel represents a 1MHz bandwidth starting at 2400MHz, e.g.
     * channel 125 is 2525MHz, channel 64 is 2464MHz.
     */
    printf("\nChannel %d", chan);
    printf(" ("); printf("%d", 2400+chan); printf("MHz): ");
    for (i=0; i < j; i++) {
      printf("*");
    }
    printf("   %d - %d", j, strength );
   
    if (radio.available()) {  /* Just in case some data got inadvertently received while
                               * we were doing our scan, clear it out.
                               */
      radio.read(dumpbuf, 33);
    }
  }  // Loop to the next channel...

  printf("\nChannel scan done; halting CPU.  Hit RESET to do another scan.\n");
  // Serial.flush();
  // radio.deepsleep();
  // while(1) ;  // Permanently halt the CPU.  Using while(1) is more portable e.g. to Stellaris LP.

    return 0;
}

 

And I got this output :

 

Channel 0 (2400MHz): *******   7 - 80
Channel 1 (2401MHz):    0 - 0
Channel 2 (2402MHz):    0 - 0
Channel 3 (2403MHz):    0 - 0
......



Channel 54 (2454MHz):
0 - 0


Channel 55 (2455MHz):
0 - 0



Channel 56 (2456MHz): ***   3 - 4



Channel 57 (2457MHz):
0 - 0



Channel 58 (2458MHz): **   2 - 3
Channel 59 (2459MHz): *   1 - 1
Channel 60 (2460MHz): **   2 - 2
Channel 63 (2463MHz): ***   3 - 4
Channel 64 (2464MHz): ***   3 - 6
Channel 65 (2465MHz): ***   3 - 4
Channel 66 (2466MHz): ***   3 - 6
Channel 67 (2467MHz): *****   5 - 16



Channel 68 (2468MHz):
0 - 0


Channel 69 (2469MHz):
0 - 0

 

 

( sorry for messing up the output, I don't know what is happening )

 

So now I'm sure that my transmitter is at channel0 and the activity around channel 60 may be due to my router.

  • Sign in to reply
  • Cancel
Parents
  • ipv1
    0 ipv1 over 10 years ago

    We all got a scope so I would recommend probing the spi output to see what's is going on. Just might be a simple addressing isuue. Will revert once I run the code myself but it would be useful to probe it yourself.

     

    Spi module enabled in RPi?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • ipv1
    0 ipv1 over 10 years ago

    We all got a scope so I would recommend probing the spi output to see what's is going on. Just might be a simple addressing isuue. Will revert once I run the code myself but it would be useful to probe it yourself.

     

    Spi module enabled in RPi?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • vish
    0 vish over 10 years ago in reply to ipv1

    I didn't have the scope image

     

    SPI is enabled, and even channel strength scanning is working fine....but data is not detected...

    I tried little-endian big-endian thing also but of no hope image

    Let's see what I can do...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ipv1
    0 ipv1 over 10 years ago in reply to vish

    The easy way out would be to use a USB to spi converter and if not then simply get an arduino with an ftdi chip and make it sub task the wireless stuff.

    Last but not the least you can try the rpisoc

    And use it as an spirit controller. Ironically rpisoc connects to the RPI using spirit image

    Lemme know if I can help in any way.

     

    All the best

    Ip

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ipv1
    0 ipv1 over 10 years ago in reply to vish

    See if this helps

    https://github.com/jpbarraca/pynrf24

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube