Skip navigation
2015

I received a Raspberry Pi2 from element14 and in this post i will share about my experience. Pi is really evolving and getting better with the time. Here are my experiences and observations.

1.BOOT TIME

The first difference you will find when you will make the Pi2 boot is there are 4 raspberries on the top of screen instead of 1 raspberry on B+ representing the quardcore nature of the processor. The time taken by Pi 2 to boot is significantly lesser than the B+.


2. NOOBS

If you have an older version of NOOBS you need to update it to run it on Pi2 since the ARM  architecture is different on the two boards.The new version of NOOBS is compatible with the B+ model and the Pi2. However the new Noobs have very few operating systems to select from. Future releases will definitely and should definitely have more options.

However i had a queer observation i ran the new noobs on B+ and on Pi2 using the same SD card. When i run it on Pi2 and boot into the desktop i get the following message on screen.

GDBus.Error.org.feedesktop.Policykit1.Error.Failed: Cannot determine user of subject. Apart from this the operating system works fine.

 

3. RESOLUTION

since there is no bios on the Pi there is pain in getting the resolution right.The GPU reads the config.txt file everytime it boots up. I connected my Pi on a LG LED TV.And when i swap the Pi2 and B+ keeping the same SD card resolutions get disturbed. Had to fix it time and again if you also have such problem it can be fixed by firing Sudo nano/boot/config.txt. in the LX terminal . Paste the config.txt in your SD card if it is not there ,the file can be found on the raspberry pi official website. You will need to change a few values.

 

4. GAMES AND APPLICATIONS

I ran minecraft and the game play is much smoother on the Pi 2. Also the game loads faster. Similarly mathematica loads much earlier on Pi2. I also found the webpages load much better on PI2


5. VIDEOS

Ran the sample video by using omxplayer /opt/vc/scr/hello_pi/hello_video/test.h264. The video runs great on both. Also ran a movie "book_of _life". To put the movie on pi i first put the file on the pendrive connected it to pi ,from the pendrive i copied it to the desktop.Changed the directory  using cd/home/pi/Desktop. Then used omxplayer -o local book_of _life.mp3  to play it and have the audio through the 3.5 mm jack.I couldn't see any difference in the video playback on both the pi.

 

 

I have also done a video about the Pi ecosystem and comparison of the two Pi boards i used. I have made the video with the view that anybody who is not familiar with the Pi is able to have a understanding of what it is and for those who are already familiar with it i have info about the new things we are likely to see in the Pi ecosystem. Hope you will enjoy the video.

 

 

WHAT I DON'T LIKE ABOUT PI :

1. while booting the pi. The pi asks for username and password. After you enter the user name as Pi and then when you will  try to enter the password  you will see nothing appearing on the screen when you will press the  keys on you keyboard.But actually if you have faith in yourself and you type raspberry and then if you will press enter you will find that you have successfully logged in. There should be  stars****** on key press.

2. Pi doesn't have a power on /off button. Usually most of us connect our pi's adapter  to a multisocket board but it is annoying to turn it off from there. It would be great if there is a button on pi to do this. Till it gets there on the board there is another solution for the people like me ,there comes a used cable that has a on/off button which can be used to as an alternate.

 

ABOUT  THE PERIPHERALS I USED:


I used a wireless keyboard and mouse for the first time,earlier i use to go with a wired one. For those who want to buy one ,Logitech MK220 works flawless on the pi,no hassel just plug and play. Moreover this is the cheapest one available right now.

For wireless connectivity i used  EDUP Mini Wireless N 11n Wi-Fi Nano USB Adapter. This is also just plug and play.

One last thing, do use a good quality power adapter otherwise it might deter the quality of your experience,the B+ and pi2 has good brown out detection and the power LED blinks if there is not enough power available.

coolbox

My Pi 2 arrived

Posted by coolbox Apr 28, 2015

Sorry it's late.But I want to share some Pics here.Thanks element14Dave for appreciating me by sending this amazing thing.I am planning some interesting projects.I will post them soon.

IMG_20150426_212341.jpg

pi_pic.png

 

This technote covers setting up the Xfce desktop environment and session manager on a Raspberry Pi.  Folks who use a Linux distribution that make use of Xfce will find the Raspbian Xfce quite familiar.  I find that the look and feel of the desktop and the application menu organization is almost identical to that of Xubuntu which I use at home on Mini-ITX builds.


The latest Raspbian image (2015-02-16) from http://www.raspberrypi.org/downloads/ includes Openbox and LXDE as desktop environment options on top of LightDM.  Xfce also uses LightDM so I was not surprised that Xfce installed so easily and was immediately available for use without any “tweaks”.

Note that one can also install the MATE desktop session manager that Linux Mint users are quite familiar with.  Maybe other desktop session managers too although the gating factor would be that they should interoperate with LightDM in order to avoid a lot of re-tooling.

Start with the following and go have a snack or walk the dog while its running:

sudo apt-get -y install Xfce4 Xfce4-screenshooter

This installs the desktop environment and session manager, the related applications, and a screen-shot application that is the best that I have ever used [(-:].

To try out Xfce once,

    • Logout.
    • At the login prompt, select “Xfce Session” in place of “Default Xsession”.
    • Login.

Note that the next time that you reboot/logout and come back, you will be back to whatever desktop session manager that you were using before.  To make use of Xfce from now on as the default, execute the following:

sudo update-alternatives --config x-session-manager

This will bring up a menu that should look like the following (or similar, depending on what you have been tinkering with):

   Selection    Path                      Priority   Status
------------------------------------------------------------
  0            /usr/bin/startlxde-pi      90        auto mode
  1            /usr/bin/lxsession         49        manual mode
  2            /usr/bin/openbox-session   40        manual mode
  3            /usr/bin/startlxde         50        manual mode
  4            /usr/bin/startlxde-pi      90        manual mode
  5            /usr/bin/startXfce4        50        manual mode
  6            /usr/bin/Xfce4-session     40        manual mode

Assuming your #6 looks like the above, select 6 to make Xfce the default session from now on.

Reboot.  That's it!  Feel free to comment or mail me if you have issues with installing or using Xfce.

Intro

In this blog post I will describe how I used the SPI interface of the Raspberry Pi 2 (and Raspberry Pi) to communicate with an Arduino board.

Both the RPi and Arduino are connected to a nRF24L01+ chip to communicate with each other via the SPI interface.

I will describe the practical details of the setup and will also share the sources which were used.

The GPIO usage on the Raspberry Pi 2 is exactly the same as on the Raspberry Pi B(+). In practice it might be that some expansion boards which fit on the Raspberry Pi B do not fit on the RPiB+ or RPi2 because pins 27,28 are right next to pins 25,26.

 

Setup

To use the GPIO pins on the Raspberry Pi 2 I used some (additional) electronic parts. I did the same tests with Raspberry Pi B Rev. 2.0 and Raspberry Pi 2 B.

The most important parts I used:

2x nRF24L01+

1x Raspberry Pi 2 / 1x Raspberry Pi B

1x Arduino UNO R3

2x Capacitor 220uF(*) (for the power to the nRF24L01+ chip)

 

To connect to the nRF24L01+ chip I used a straight 20 pin ribbon cable and for connecting to the GPIO pins of the Raspberry Pi an old IDE40 cable. (Note that if you try this yourself, you should pay attention that you have 40 pin cable without any shorts, a 80-wire / 40 pin cable will most likely have shorts to reduce crosstalk.)


(*) I still had this capacitor laying around, probably 10uF would have been sufficient.


Raspberry Pi (2) GPIO PINs

For both Raspberry Pi's the pins that I use are the same.

P01 : 3.3V : dark orange (*)
P25 : GND : black

P15 : GPIO22 : white (CE)

P19 : MOSI : yellow

P21 : MISO : green

P23 : SCLK : orange (*)

P24 : CSN  : blue


We connect the pins from the RPi(2) to the nRF24L01+ chip. Vcc is 3.3V and for CE we use pin 15 (GPIO22) on the RPi(2). (For the rest we connect the MOSI of the RPi to the MOSI of the nRF24L01+ chip, ... )

In the test setup I used an old IDE40 cable. On both the RPi2 and RPi, pin 1 and 2 are at the edge of the board. Since some pins of the IDE cable are next to the board you will see that the wires on the other side of the IDE cable are inserted in a different position.

(*) It might not be that easy to see the difference between dark orange and orange in the pictures, but the dark orange is the "lonely" cable (7 pins next to the white cable).

 

IDE40 color
RPi(2) function
RPi(2) pinnRF24L01+ pinnRF24L01+ function20-pin color
dark orange3.3V012Vcc / 3.3Vyellow
blackGND251GNDwhite
whiteGPIO22153CEwhite
yellowMOSI196MOSIyellow
greenMISO217MISOgreen
orangeSCLK235SCKorange
blueCSN244CSNblue

 

Raspberry Pi 2 B:

The following table tries to show the relation between the pins on the RPi2 and the pins on the IDE40 cable:

__________________------__________________
403836343230282624222018161412108642
39373533312927252321191715131197531

The "---" in the middle represents the notch in the midlle of the IDE cable (see pictures "RPi2: IDE40 ribbon cable / dupont wires").

 

{gallery} Raspberry Pi 2 IDE40

RPi2B_IDE40.jpg

RPi2: IDE40 ribbon cable

RPi2B_IDE40_dupont.jpg

RPi2: IDE40 ribbon cable / dupont wires

 

Raspberry Pi B:

The following table tries to show the relation between the pins on the RPi and the pins on the IDE40 cable (xx means not used; pins sticking out next to the board):

__________________------__________________
2624222018161412108642xxxxxxxxxxxxxx
252321191715131197531xxxxxxxxxxxxxx

 

 

{gallery} Raspberry Pi IDE40

RPiB_IDE40.jpg

RPi: IDE40 ribbon cable

RPiB_IDE40_dupont.jpg

RPi: IDE40 ribbon cable / dupont wires

nRF24L01+

"Top" view of the nRF24L01+ chip

|__|__|__|__|--
|___________
|||
|||
|||
2468
1357

 

1 : GND

2 : VCC (3.3V)

3 : CE    : white

4 : CSN  : blue

5 : SCK  : orange

6 : MOSI : yellow

7 : MISO : green

8 : IRQ : xx

 

The following table tries to show the relation between the nRF24L01+ pins and the pins on the 20-pin ribbon cable (xx means not used):

________------________
2468xxxxxxxxxxxx
1357xxxxxxxxxxxx

 

{gallery} nRF24L01+

nRF24L01_180.jpg

nRF24L01+: chip

nRF24L01_dupont_180.jpg

nRF24L01+: dupont

 

Software

By default SPI is not enabled on Raspbian to load it during the boot process execute sudo raspi-config then select Advanced and then enable the SPI kernel module.

You can also do sudo modprobe spi-bcm2708.

For both the RPi and Arduino, I used the TMRh20 library available on github (some RPi specific info).

If you download the library and do not follow the installation procedure, then you'll need to do sudo make and sudo make install to install the library.

The modified sources are just to transmit data between RPi and Arduino. By default this Arduino sketch will start in transmit mode, by pressing d it will go in "dump" mode, where it will dump the contents of the data array when it's received.

 

Arduino Sketch:

/*
2015-04-06 : Johan Boeckx - Arduino/RPi(2) nRF24L01+ : Arduino UNO R3 code
  Tested on Arduino UNO R3 and Raspberry Pi B Rev. 2.0 and Raspberry Pi 2 B


TMRh20 2014
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
/** Reliably transmitting large volumes of data with a low signal or in noisy environments
* This example demonstrates data transfer functionality with the use of auto-retry
and auto-reUse functionality enabled. This sketch demonstrates how a user can extend
the auto-retry functionality to any chosen time period, preventing data loss and ensuring
the consistency of data.

This sketh demonstrates use of the writeBlocking() functionality, and extends the standard
retry functionality of the radio. Payloads will be auto-retried until successful or the
extended timeout period is reached.
*/
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
/*************  USER Configuration *****************************/
RF24 radio(7,8);                        // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
unsigned long timeoutPeriod = 3000;     // Set a user-defined timeout period. With auto-retransmit set to (15,15) retransmission will take up to 60ms and as little as 7.5ms with it set to (1,15).
                                        // With a timeout period of 1000, the radio will retry each payload for up to 1 second before giving up on the transmission and starting over
/***************************************************************/
const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL };   // Radio pipe addresses for the 2 nodes to communicate.
byte data[32] = {"_This is a message via NRF24L+!"};                           //Data buffer
volatile unsigned long counter;
unsigned long rxTimer,startTime, stopTime, payloads = 0;
//bool TX=1,RX=0,role=0, transferInProgress = 0;
bool transferInProgress = 0;
unsigned int TX=1,RX=0,role=1,lastrole=0,SKIP=2,RXPRINT=3,RXDUMP=4;
unsigned int offset=0;
void setup(void) {
  Serial.begin(57600);
  printf_begin();
  radio.begin();                           // Setup and configure rf radio
  radio.setChannel(1);                     // Set the channel
  radio.setPALevel(RF24_PA_HIGH);
  radio.setDataRate(RF24_250KBPS);
  //radio.setDataRate(RF24_2MBPS);
  radio.setAutoAck(1);                     // Ensure autoACK is enabled
  radio.setRetries(2,15);                  // Optionally, increase the delay between retries. Want the number of auto-retries as high as possible (15)
  radio.setCRCLength(RF24_CRC_16);         // Set CRC length to 16-bit to ensure quality of data
  if (role == RX)
  {
    radio.openWritingPipe(pipes[0]);         // Open the default reading and writing pipe
    radio.openReadingPipe(1,pipes[1]);

    radio.startListening();                 // Start listening
  }
  else{
    radio.openWritingPipe(pipes[1]);         // Open the default reading and writing pipe
    radio.openReadingPipe(1,pipes[0]);
    radio.stopListening();
  }
  radio.printDetails();                   // Dump the configuration of the rf unit for debugging

  printf("\n\rRF24/examples/Transfer Rates/\n\r");
  printf("*** PRESS 'T' to begin transmitting to the other node\n\r");

  /*
  randomSeed(analogRead(0));              //Seed for random number generation
  for(int i=0; i<32; i++){
     data[i] = random(255);               //Load the buffer with random data
  }
  */
  radio.powerUp();                        //Power up the radio

}
void showData(void)
{
      printf("Data: ");
      for(int i=0; i<32; i++){
         if(isprint(data[i]))
           printf("%c", data[i]);
         else
           printf(".");
      }
      printf("\n\r");
}
void loop(void){
  if(role == TX){
    delay(500);                                              // Pause for a couple seconds between transfers
    printf("Initiating Extended Timeout Data Transfer\n\r");
    unsigned long cycles = 1000;                              // Change this to a higher or lower number. This is the number of payloads that will be sent.

    unsigned long transferCMD[] = {'H','S',cycles };          // Indicate to the other radio that we are starting, and provide the number of payloads that will be sent
    radio.writeFast(&transferCMD,12);                         // Send the transfer command
    if(radio.txStandBy(timeoutPeriod)){                       // If transfer initiation was successful, do the following

        startTime = millis();                                 // For calculating transfer rate
        boolean timedOut = 0;                                 // Boolean for keeping track of failures

        for(int i=0; i<cycles; i++){                          // Loop through a number of cycles
          data[0] = i;                                        // Change the first byte of the payload for identification
          if(!radio.writeBlocking(&data,32,timeoutPeriod)){   // If retries are failing and the user defined timeout is exceeded
              timedOut = 1;                                   // Indicate failure
              counter = cycles;                               // Set the fail count to maximum
              break;                                          // Break out of the for loop
          }
        }


        stopTime = millis();                                  // Capture the time of completion or failure

       //This should be called to wait for completion and put the radio in standby mode after transmission, returns 0 if data still in FIFO (timed out), 1 if success
       if(timedOut){ radio.txStandBy(); }                     //Partially blocking standby, blocks until success or max retries. FIFO flushed if auto timeout reached
       else{ radio.txStandBy(timeoutPeriod);     }            //Standby, block until FIFO empty (sent) or user specified timeout reached. FIFO flushed if user timeout reached.

   }else{                                      
       Serial.println("Communication not established");       //If unsuccessful initiating transfer, exit and retry later
       counter = cycles+1;
   }
   if (counter <= cycles )
   {
     float rate = cycles * 32 / (stopTime - startTime);         //Display results:

     Serial.print("Transfer complete at "); Serial.print(rate); printf(" KB/s \n\r");
     Serial.print(counter);
     Serial.print(" of ");
     Serial.print(cycles); Serial.println(" Packets Failed to Send");
     //if (counter == 0)
     showData();
   }
   counter = 0;
   Serial.print("------------------------------------------------------------\r\n\r\n");
}

if(role == RX){

  if(!transferInProgress){                       // If a bulk data transfer has not been started
     if(radio.available()){
        //Serial.print("Rx\r\n");
        //Serial.print(".");
        radio.read(&data,32);                    //Read any available payloads for analysis
        if(data[0] == 'H' && data[4] == 'S'){    // If a bulk data transfer command has been received
          payloads = data[8];                    // Read the first two bytes of the unsigned long. Need to read the 3rd and 4th if sending more than 65535 payloads
          payloads |= data[9] << 8;              // This is the number of payloads that will be sent
          counter = 0;                           // Reset the payload counter to 0
          transferInProgress = 1;                // Indicate it has started
          startTime = rxTimer = millis();        // Capture the start time to measure transfer rate and calculate timeouts
        }
     }
  }else{
     if(radio.available()){                     // If in bulk transfer mode, and a payload is available
       //Serial.print("Rx\r\n");
       radio.read(&data,32);                    // Read the payload
       rxTimer = millis();                      // Reset the timeout timer
       counter++;                               // Keep a count of received payloads
     }else
     if(millis() - rxTimer > timeoutPeriod){    // If no data available, check the timeout period
       Serial.println("Transfer Failed");       // If per-payload timeout exceeeded, end the transfer
       transferInProgress = 0;
       //Serial.print("!\r\n");
     }else
     if(counter >= payloads){                   // If the specified number of payloads is reached, transfer is completed
      //Serial.print("!\r\n");
      startTime = millis() - startTime;         // Calculate the total time spent during transfer
      float numBytes = counter*32;              // Calculate the number of bytes transferred
      Serial.print("Rate: ");                   // Print the transfer rate and number of payloads
      Serial.print(numBytes/startTime);
      Serial.println(" KB/s");
      printf("Payload Count: %d (%c)\n\r", counter, (char* )data[1]);
      showData();
      transferInProgress = 0;                   // End the transfer as complete
    }
  }
}
if(role == RXDUMP){
     if(radio.available()){
        radio.read(&data,32);                    //Read any available payloads for analysis
        showData();
     }
}
if(role == RXPRINT){
  if(!transferInProgress){                       // If a bulk data transfer has not been started
     if(radio.available()){
        //Serial.print("Rx\r\n");
        Serial.print(".");
        radio.read(&data,32);                    //Read any available payloads for analysis
        if(data[0] == 'H' && data[4] == 'S'){    // If a bulk data transfer command has been received
          payloads = data[8];                    // Read the first two bytes of the unsigned long. Need to read the 3rd and 4th if sending more than 65535 payloads
          payloads |= data[9] << 8;              // This is the number of payloads that will be sent
          counter = 0;                           // Reset the payload counter to 0
          transferInProgress = 1;                // Indicate it has started
          startTime = rxTimer = millis();        // Capture the start time to measure transfer rate and calculate timeouts
        }
     }
  }else{
     if(radio.available()){                     // If in bulk transfer mode, and a payload is available
       Serial.print(".");
       radio.read(&data,32);                    // Read the payload
       rxTimer = millis();                      // Reset the timeout timer
       counter++;                               // Keep a count of received payloads
     }else
     if(millis() - rxTimer > timeoutPeriod){    // If no data available, check the timeout period
       Serial.println("Transfer Failed");       // If per-payload timeout exceeeded, end the transfer
       transferInProgress = 0;
       Serial.print("!\r\n");
     }else
     if(counter >= payloads){                   // If the specified number of payloads is reached, transfer is completed
      Serial.print("!\r\n");
      startTime = millis() - startTime;         // Calculate the total time spent during transfer
      float numBytes = counter*32;              // Calculate the number of bytes transferred
      Serial.print("Rate: ");                   // Print the transfer rate and number of payloads
      Serial.print(numBytes/startTime);
      Serial.println(" KB/s");
      printf("Payload Count: %d (%c)\n\r", counter, (char* )data[1]);
      showData();
      transferInProgress = 0;                   // End the transfer as complete
      delay(500);
    }
  }
}
if(role == SKIP){
}

  //
  // Change roles
  //
  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    printf("*** SERIAL : %c %d\n\r", c, c);
    if ( c == 'C' && role == SKIP)
    {
      role = lastrole;
      printf("*** CONTINUING PREVIOUS ROLE\n\r");
    }
    else if ( c == 'D' && (role != RXDUMP ))
    {
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
      radio.startListening();
      printf("*** CHANGING TO RECEIVE DUMP ROLE -- PRESS 'T' TO SWITCH BACK\n\r");
      role = RXDUMP;                // Become the primary receiver (pong back)
    }
    else if ( c == 'T' && (role != TX ))
    {
      printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");
      radio.openWritingPipe(pipes[1]);
      radio.openReadingPipe(1,pipes[0]);
      radio.stopListening();
      role = TX;                  // Become the primary transmitter (ping out)
    }
    else if ( c == 'P' && (role != RXPRINT ) )
    {
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
      radio.startListening();
      printf("*** CHANGING TO RECEIVE PRINT ROLE -- PRESS 'T' TO SWITCH BACK\n\r");
      role = RXPRINT;                // Become the primary receiver (pong back)
    }
    else if ( c == 'R' && (role == RX) )
    {
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
      radio.startListening();
      printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");
      role = RX;                // Become the primary receiver (pong back)
    }
    else if ( c == 'S' && role != SKIP)
    {
      lastrole = role;
      role = SKIP;
      showData();
      printf("*** WAITING -- PRESS 'C' TO CONTINUE\n\r");
    }
    else if ( c == 'M' ){
      offset = 1;
      while ( c != 13 )
      {

        if ( Serial.available() )
        {
          c = Serial.read();
          if ( c != 13 ){
          offset++;
          if (offset>=32)
            offset = 1;
          data[offset] = c;
          printf("*** SERIAL : %c data[%d]=(%c)\n\r", c, offset, data[offset]);
          }
        }
      }
    }
  }
}








 

Raspberry Pi (2) c code:

/*
2015-04-06 : Johan Boeckx - Arduino/RPi(2) nRF24L01+ : Raspberry Pi (2) code
  Tested on Arduino UNO R3 and Raspberry Pi B Rev. 2.0 and Raspberry Pi 2 B

 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.

 03/17/2013 : Charles-Henri Hallard (http://hallard.me)
              Modified to use with Arduipi board http://hallard.me/arduipi
                          Changed to use modified bcm2835 and RF24 library
TMRh20 2014 - Updated to work with optimized RF24 Arduino library

*/

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <RF24/RF24.h>

using namespace std;
//
// Hardware configuration
// Configure the appropriate pins for your connections

/****************** Raspberry Pi ***********************/

// Radio CE Pin, CSN Pin, SPI Speed
// See http://www.airspayce.com/mikem/bcm2835/group__constants.html#ga63c029bd6500167152db4e57736d0939 and the related enumerations for pin information.

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

// NEW: Setup for RPi B+
//RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ);

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

// RPi generic:
RF24 radio(22,0);

/*** RPi Alternate ***/
//Note: Specify SPI BUS 0 or 1 instead of CS pin number.
// See http://tmrh20.github.io/RF24/RPi.html for more information on usage

//RPi Alternate, with MRAA
//RF24 radio(15,0);

//RPi Alternate, with SPIDEV - Note: Edit RF24/arch/BBB/spi.cpp and  set 'this->device = "/dev/spidev0.0";;' or as listed in /dev
//RF24 radio(22,0);


/****************** Linux (BBB,x86,etc) ***********************/

// See http://tmrh20.github.io/RF24/pages.html for more information on usage
// See http://iotdk.intel.com/docs/master/mraa/ for more information on MRAA
// See https://www.kernel.org/doc/Documentation/spi/spidev for more information on SPIDEV

// Setup for ARM(Linux) devices like BBB using spidev (default is "/dev/spidev1.0" )
//RF24 radio(115,0);

//BBB Alternate, with mraa
// CE pin = (Header P9, Pin 13) = 59 = 13 + 46
//Note: Specify SPI BUS 0 or 1 instead of CS pin number.
//RF24 radio(59,0);

/********** User Config *********/
// Assign a unique identifier for this node, 0 or 1
// 0 Rx / 1 Tx
bool radioNumber = 0;
unsigned long timeoutPeriod = 3000;     // Set a user-defined timeout period. With auto-retransmit set to (15,15) retransmission will take up to 60ms and as little as 7.5ms with it set to (1,15).

/********************************/

// Radio pipe addresses for the 2 nodes to communicate.
// const uint8_t pipes[][6] = {"1Node","2Node"};
const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL };   // Radio pipe addresses for the 2 nodes to communicate.
char data[32] = {"_A message from RPi w/ NRF24L+!"};            //Data buffer

void showData(void)
{
      printf("Data: ");
      for(int i=0; i<32; i++){
         if(isprint(data[i]))
           printf("%c", data[i]);
         else
           printf(".");
      }
      printf("\n\r");
}

int main(int argc, char** argv){

  const int role_rx=0, role_tx=1;
  int role=role_rx;
/********* Role chooser ***********/

  printf("\n ************ Role Setup ***********\n");
  string input = "";
  char myChar = {0};

  cout << "Choose a role: Enter 0 for Rx, 1 for Tx (CTRL+C to exit) \n>";
  getline(cin,input);

  if(input.length() == 1) {
    myChar = input[0];
    if(myChar == '0'){
        cout << "Role: Rx " << endl << endl;
    }else{  cout << "Role: Tx " << endl << endl;
        role = role_tx;
    }
  }
  switch(role) {
      case role_rx :
        radioNumber=0;
        break;

      case role_tx :
        radioNumber=1;
        break;
  }

/***********************************/
  // Setup and configure rf radio
  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);
  // Set the channel
  radio.setChannel(1);
  // Set the data rate
  //radio.setDataRate(RF24_2MBPS);
  radio.setDataRate(RF24_250KBPS);
  //radio.setPALevel(RF24_PA_MAX);
  radio.setPALevel(RF24_PA_MIN);

    if ( !radioNumber )    {
        radio.openWritingPipe(pipes[0]);
        radio.openReadingPipe(1,pipes[1]);
        memset(&data,'\0',sizeof(data));
        radio.startListening();
    } else {
        radio.openWritingPipe(pipes[1]);
        radio.openReadingPipe(1,pipes[0]);
        radio.stopListening();
    }
    // Dump the configuration of the rf unit for debugging
    radio.printDetails();
    printf("Start loop:\n");
    // forever loop
    while (1)
    {
        if (radioNumber) {
            if (radio.writeBlocking(&data,sizeof(data),timeoutPeriod)) {
                printf(".");
            }
            else {
                printf("?");
            }
            fflush(stdout);
            //printf("\n");
        }
        else {
        //
        // Receive each packet, dump it
        //
            if(radio.available()){
                // Read any available payloads for analysis
                radio.read(&data,32);
                // Dump the printable data of the payload
                showData();
                fflush(stdout);
            }
        }
        delay(5);
    } // forever loop

  return 0;
}









 

Raspberry Pi (2) output

Receive mode

When we receive a message, dump the data.

************ Role Setup ***********

Choose a role: Enter 0 for Rx, 1 for Tx (CTRL+C to exit)

>0

Role: Rx

 

================ 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     = 0xabcdabcd71 0x544d52687c

RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6

TX_ADDR         = 0xabcdabcd71

RX_PW_P0-6     = 0x20 0x20 0x00 0x00 0x00 0x00

EN_AA         = 0x3f

EN_RXADDR     = 0x02

RF_CH         = 0x01

RF_SETUP     = 0x21

CONFIG         = 0x0f

DYNPD/FEATURE     = 0x00 0x00

Data Rate     = 250KBPS

Model         = nRF24L01+

CRC Length     = 16 bits

PA Power     = PA_MIN

Start loop:

Data: H...S...........................

Data: .This is a message via NRF24L+!.

Transmit mode

If the write succeeds write a "." else a "?".

************ Role Setup ***********

Choose a role: Enter 0 for Rx, 1 for Tx (CTRL+C to exit)

>1

Role: Tx

 

================ 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     = 0x544d52687c 0xabcdabcd71

RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6

TX_ADDR         = 0x544d52687c

RX_PW_P0-6     = 0x20 0x20 0x00 0x00 0x00 0x00

EN_AA         = 0x3f

EN_RXADDR     = 0x03

RF_CH         = 0x01

RF_SETUP     = 0x21

CONFIG         = 0x0e

DYNPD/FEATURE     = 0x00 0x00

Data Rate     = 250KBPS

Model         = nRF24L01+

CRC Length     = 16 bits

PA Power     = PA_MIN

Start loop:

...????................................................................................................................................................................................................................................................................................................^C

Arduino Output

By default the Arduino starts in Transmit mode. When you press "d" it goes to "dump" mode, which means just dump the packet which is received.

STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0

RX_ADDR_P0-1     = 0x544d52687c 0xabcdabcd71

RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6

TX_ADDR          = 0x544d52687c

RX_PW_P0-6       = 0x20 0x20 0x00 0x00 0x00 0x00

EN_AA            = 0x3f

EN_RXADDR        = 0x03

RF_CH            = 0x01

RF_SETUP         = 0x25

CONFIG           = 0x0e

DYNPD/FEATURE    = 0x00 0x00

Data Rate        = 250KBPS

Model            = nRF24L01+

CRC Length       = 16 bits

PA Power         = PA_HIGH

 

Transmit mode

The Arduino sketch which was taken as basis, was meant to send a header packet and then x times a payload packet.

When we stop listening on the RPi to the packets coming from the Arduino, we will see errors on the serial output of the Arduino:

Initiating Extended Timeout Data Transfer

Transfer complete at 5.00 KB/s

0 of 1000 Packets Failed to Send

Data: .This is a message via NRF24L+!.

------------------------------------------------------------

 

Initiating Extended Timeout Data Transfer

Communication not established

------------------------------------------------------------

Dump mode

Data: _A message from RPi w/ NRF24L+!.

 

 

Sources

 

Github : https://github.com/TMRh20/RF24

Class documentation : Optimized High Speed NRF24L01+ Driver Class Documenation: Optimized High Speed Driver for nRF24L01(+) 2.4GHz Wireless Tr…

Raspberry Pi info : Optimized High Speed NRF24L01+ Driver Class Documenation: Raspberry Pi

Ethernet library : RF24Ethernet - TCP/IP over RF24Network: RF24Ethernet library: TCP/IP over RF24Network

A few folks seem to have stumbled over network set up and using SSH in OpenELEC on Pi 2.  So this technote shares my experience in hopes that it might help others clear those hurdles.  Also, I added overclocking here because I found that it eliminated some video playback anomalies.

 

Topics covered in detail where I had put in effort beyond what I saw written up elsewhere:

 

  1. Setting up wireless with or without a static IP address
  2. Setting up SSH service
  3. Overclocking for Higher Performance

 

1. Setting up wireless with or without a static IP address

 

There are a number of reasons why one might (at least, initially) set up a wireless connection for OpenELEC.  In my case, my Pi went from sitting in my dining room (no Ethernet) to sitting in my kitchen breakfast nook (no Ethernet) with its power adapter plugged into the same electric wall plate as my coffee machine [(-:].  My home is currently another project (long story).

 

In the OpenELEC home menu, select:

 

    PROGRAMS > Openelec Configuration

 

In Network, select Wireless and

 

    Turn off Wired Network

    Turn on Wireless Network

 

In Connections, select your router and enter the usual network pass-code for connecting.

 

A static IP address for a server such as OpenELEC is convenient for using client service requesters such as SSH (the next subject in this technote).  If a static IP address is desired, select the router's connection entry > Edit > IPv4 and enter the values that make sense for your home network.  My Pi (an example) is configured as follows:

 

        IP Address Method              Manual

        IP Address                     192.168.1.102

        Netmask                        255.255.255.0

        Default Gateway                192.168.1.1 (router)

 

Note that the above static address scheme would also work for a wired Ethernet connection (default IP Address Method = dhcp).

 

2. Setting up SSH service

 

Sometimes, it is useful to get a command line terminal on the OpenELEC Pi.  Some examples of use are as follows:

 

  • Future system update operations.
  • Trouble-shooting using the contents of /var/log.
  • Modifying the config.txt system configuration file (E.g. overclocking).

 

To set this up, in the OpenELEC home menu, select:

 

    PROGRAMS > Openelec Configuration

 

In Services, enable SSH.

 

3. Overclocking for Higher Performance

 

See the discussion at http://wiki.openelec.tv/index.php/Raspberry_Pi_FAQ#Overclocking and the overclocking settings under the paragraph, "How do I overclock my PI?".

 

I have no issues doing this for myself or my family.  Other people might feel differently.  My Pi is still running cool, even while throwing up an MKV video at 1080p.  And, the normal-clocking Pi occasionally stuttered video and audio and video horizontal line anomalies were occasionally visible.  Maybe that was my hardware.  In any case, after overclocking, the anomalies have not yet re-appeared.

 

The following is what my OpenELEC file system list looks like through the eyes of `ssh`:

 

ssh root@192.168.1.102

root@192.168.1.102's password:

##############################################

# OpenELEC - The living room PC for everyone #

# ...... visit http://www.openelec.tv ...... #

##############################################

 

OpenELEC (official) Version: 5.0.8

raspy:~ # df -k

Filesystem           1K-blocks      Used Available Use% Mounted on

devtmpfs                371968         0    371968   0% /dev

/dev/mmcblk0p1          261868    107508    154360  41% /flash

/dev/mmcblk0p2        60139035     34254  60100685   0% /storage

/dev/loop0               96640     96640         0 100% /

tmpfs                   377168         0    377168   0% /dev/shm

tmpfs                   377168      5048    372120   1% /run

tmpfs                   377168         0    377168   0% /sys/fs/cgroup

tmpfs                   377168         4    377164   0% /tmp

tmpfs                   377168       224    376944   0% /var

 

As you can see, OpenELEC does not mount /boot on /dev/mmcblk0p1.  It mounts /flash on that device as read-only; the config.txt file is filed under /flash.

 

You can edit config.sys by either (a) editing config.txt on another computer or (b) ssh to OpenELEC Pi and change the config.txt there.

 

If you choose (a), the instructions for Windows are on the OpenELEC wiki page referenced earlier; Linux users can probably figure out the equivalent.

 

If you choose (b) as I did, the instructions can be found here: http://wiki.openelec.tv/index.php/Config.txt

OpenELEC is a special Linux distribution because it runs a single specialized application: Kodi.  As a consequence of being understandably cautious, there are limitations to what a user can do in terms of administration in this environment.

 

For example, many of the Debian Linux utilities found in Raspbian are not present in OpenELEC.  Examples include the `dpkg*` and `apt*` families for system update and maintenance.  I don't mind those limitations at all.  However, one irksome situation concerns time synchronization.  While the user has full ability to configure the local time zone, we seem to have been left to our own devices for setting and updating the clock time.  Note that `ntpd` (network time protocol daemon) is installed but it is not configured nor started - at least in Raspberry Pi OpenELEC version 5.0.8.

 

So, I just finished a band-aid which will probably work for you if you are also observing time drift issues like I have (E.g. after powering off for a bit). Hopefully, at some time in the future, OpenELEC will include automatic periodic execution of `ntpd`.

 

1. ssh to the OpenELEC Pi 2 server as the root.  The remaining steps (2-7) take place in the ssh window.

 

2. Edit /storage/.config/autostart.sh with your favorite Linux text editor.  If you have never added anything to this file before, it will not yet exist.  Don't worry, just create it.

 

3. Append the following 2 lines to autostart.sh:

#!/bin/sh

(sleep 10; /sbin/ntpd -p pool.ntp.org; )&


The URL pool.ntp.org points to a global pool of time servers.  You can also address a continent-specific or country-specific pool of time servers.  See http://www.pool.ntp.org/zone/@ for details.


Do not use the -q command line option of `ntpd` or the daemon will execute once on OpenELEC startup and then quit (unless, of course, that is what you want). 


The sleep parameter of 10 seconds is a delay to allow networking to be established before trying to fetch network time.


4. Save and exit the editor.  If in doubt of your editing, cancel (E.g. `vi` :q!), exit, and go back to step 2.

 

5. Make sure that autostart.sh is executable:

chmod +x /storage/.config/autostart.sh

 

6. Test:

sh /storage/.config/autostart.sh

sleep 10; date

echo 'How does the time display look in the command line?'

 

7. When okay to do so, execute:

reboot

 

How does the time display look now on the GUI?

 

Afterthought: I would have thought that the contents of /storage/.config would have been under /etc where they usually are in Unix and Linux.  Also, an autostartup.sh would have been /etc/rc.local (Debian-sh) or some other "rc" mechanism.  Maybe the OpenELEC folks are trying to remind us that this distribution is different.  No worries.

A couple of months ago, while visiting the element14 community blog, I chanced upon the “Tis the Season for Inventing” contest announcement. The challenge was to submit innovative ideas using either the Arduino, Raspberry-Pi or BeagleBone Black platforms.

Element 14 Package

I had just wrapped up my desktop CNC ShapeOko build and set it up at the Makers’ Asylum garage. This build used the Raspberry-Pi as the control computer for the CNC. It was hooked to the network via WiFi, and we could SSH in to it remotely from other computers. This made life easier as it meant we didn’t have to have a computer kept in close proximity of the CNC and muck it up with dust from the mill. On top of the Raspberry-Pi sat the AlaMode Arduino clone, that I had helped design along with my buddies at WyoLum. The ShapeOko itself was paid for by WyoLum. Since the build used both – a Raspberry-Pi and an Arduino Clone, I could have entered it in either category. I settled for the Raspberry-Pi category, since most existing CNC controllers already used an Arduino hooked up to an external Computer.

I pretty much forgot about this once I submitted my idea. So it was with great surprise (and a fair amount of dis-belief ) that I read the mail from element14 informing me that I’d won the first prize ! Woot ! Me and my friends at WyoLum decided to gift the Shopping Spree prize to the Makers’ Asylum to help kit up our makerspace with useful items.

I ordered out a bunch of stuff via the local retailer of element14 – CrazyPi – and cool hawtness just landed on my desk a few days later. $1000 worth of goodies for  Makers to use at the Asylum. Let’s get Makin’ !

Here’s some pictures of what’s in the Box :

  • An 11″ HDMI display
  • Four Raspberry-Pi’s
  • Two BeagleBone Black’s
  • One Intel Edison
  • Eight Arduino UNO’s
  • One Arduino Mega
  • A Robot Kit
  • Some Power adapters, cables and breakout boards and odds and ends.

DSCN0759-1024x768.jpg?resize=1024%2C768?w=660

 

DSCN0757-1024x768.jpg?resize=1024%2C768?w=660

But that's not the end of it. A few days after we received the goddies, came news about the new Raspberry Pi 2 Model B. It seems we missed getting those for the Makers Asylum ! Drat


But Providence shined on us again. The Community Lead at Element14 got in touch with me and asked if I would like to receive a Raspberry Pi 2 Model B. whoa! That just made my day. Once again, I sent in my address, and pretty much forgot about it. Many weeks later, the package landed on my desk exactly on April 1st, 2015. This is what arrived on my desk today.

DSCN0921

Opening it up, and out popped a delicious Pi ! As with the earlier prize, this one too goes to the Makers’ Asylum.

DSCN0930

The discerning viewer will instantly recognize the all new, yummy, Raspberry Pi 2 Model B 1GB.

  • 6X Faster
  • Broadcom BCM2836 ARMv7 Quad Core Processor powered Single Board Computer running at 900MHz
  • 1GB RAM so you can now run bigger and more powerful applications
  • Identical board layout and footprint as the Model B+, so all cases and 3rd party add-on boards designed for the Model B+ will be fully compatible.
  • Fully HAT compatible
  • 40pin extended GPIO to enhance your “real world” projects
  • 10/100 Ethernet Port to quickly connect the Raspberry Pi to the Internet

We plan to use it to build some kick ass project. One of the projects we are working on at the Makers Asylum is a DIY Book Scanner. The Raspberry-Pi 2 coupled to the Ras Pi Cam looks like an ideal solution instead of using an expensive Camera.

Here’s a closer look at the board itself :

 

 

For a look at the improvements compared to the previous models, check out “Specifications” on this Wikipedia page. Besides this, the provision of four mounting holes is a nice improvement, as is the use of a micro SD card. If you’d like to play around with this delicious board, or any of the other interesting stuff we have at the Asylum, do get in touch with us.