8 Replies Latest reply on Dec 3, 2015 5:59 PM by CMata_Intel

    unable to work with nrf24l01 on Edison

    Rubik

      Hi,

       

      I've been trying to connect a nrf24l01 module to a edison breakout board but unfortunately when I try to run a node based example I always get a Segmentation fault error.

      Below is the code I use:

       

      var m = require('mraa');

      var nrf = require('jsupm_nrf24l01');

      // setup the rf unit with configurable pin options:

      var comm = new nrf.NRF24L01(9,23);

      // debug:

      //console.log(nrf);

      //console.log(comm);

      var running = 0,

          localAddress = [], // ???  [0x01, 0x01, 0x01, 0x01, 0x01]

          broadCastaddress =  [], // ?? [0x01, 0x01, 0x01, 0x01, 0x01] ,

          sigHandler = function(sig){

              var msg = "got signal: ";

              console.log(msg,sig);

              running = 1;

          },

       

       

          nrf_handler = function(){

              var msg = "recieved:: ";

              console.log(msg,nrf.m_rxBuffer[0]);

          }

       

       

      /*  reference:  upm/nrf24l01-receiver.cxx at master · intel-iot-devkit/upm · GitHub

      comm = new upm::NRF24L01(7, 8);

          comm->setSourceAddress ((uint8_t *) local_address);

          comm->setDestinationAddress ((uint8_t *) broadcast_address);

          comm->setPayload (MAX_BUFFER);

          comm->configure ();

          comm->setSpeedRate (upm::NRF_250KBPS);

          comm->setChannel (99);

          comm->dataRecievedHandler = nrf_handler;

          */

      comm.setSourceAddress(localAddress);

      comm.setDestinationAddress(broadCastaddress);

      comm.setPayload(16);

      comm.configure();

      comm.setSpeedRate(nrf.NRF_250KBPS);

      comm.setChannel(99);

      comm.dataRecievedHandler = sigHandler;

      console.log(comm);

       

      Can anyone help me with this issue? Thanks in advance

        • 1. Re: unable to work with nrf24l01 on Edison
          CMata_Intel

          Hi Rubik

           

          I found this thread: Seeking help with Edison + NRF24L01 + upm/node.js with your same issue, in that case intel_dan suggested to use the following code:

           

          var m = require('mraa');
          var nrf = require('jsupm_nrf24l01');
          // setup the rf unit with configurable pin options:
          var comm = new nrf.NRF24L01(7,8);
          // debug:
          //console.log(nrf);
          //console.log(comm);
          var running = 0,
              localAddress = [], // ???  [0x01, 0x01, 0x01, 0x01, 0x01]
              broadCastaddress =  [], // ?? [0x01, 0x01, 0x01, 0x01, 0x01] ,
              sigHandler = function(sig){
                  var msg = "got signal: ";
                  console.log(msg,sig);
                  running = 1;
              },
          
              nrf_handler = function(){
                  var msg = "recieved:: ";
                  console.log(msg,nrf.m_rxBuffer[0]);
              }
          
          /*  reference:  upm/nrf24l01-receiver.cxx at master · intel-iot-devkit/upm · GitHub
          comm = new upm::NRF24L01(7, 8);
              comm->setSourceAddress ((uint8_t *) local_address);
              comm->setDestinationAddress ((uint8_t *) broadcast_address);
              comm->setPayload (MAX_BUFFER);
              comm->configure ();
              comm->setSpeedRate (upm::NRF_250KBPS);
              comm->setChannel (99);
              comm->dataRecievedHandler = nrf_handler;
              */
          comm.setSourceAddress(new ArrayBuffer(localAddress));
          comm.setDestinationAddress(broadCastaddress);
          comm.setPayload(16);
          comm.configure();
          comm.setSpeedRate(nrf.NRF_250KBPS);
          comm.setChannel(99);
          comm.dataRecievedHandler = sigHandler;
          console.log(comm);
          

           

          I tested and did not have the error as before (I was having the same error that you.)  But I'm not sure if it's working fine because I don't have a shield to test it.

          I was looking in the examples of UPM for Javascript and did not find this example. I found another one but is in C++ you can try with this one too. upm/examples/c++ at master · intel-iot-devkit/upm · GitHub

           

          Regards;

          CMata

          1 of 1 people found this helpful
          • 2. Re: unable to work with nrf24l01 on Edison
            f3d

            I tried exactly that code and a simplified version as follows:

            // -- start code

            // Simple test program for the NRF24L01 on the Galileo 2
            var m=require('mraa');
            var nrf=require('jsupm_nrf24l01');
            console.log('MRAA version: ' + m.getVersion());
            var comm = new nrf.NRF24L01(8,9);
            SourceAddress = [1,2,3,4,5];
            comm.setSourceAddress(new ArrayBuffer(SourceAddress)); 
            console.log('Done setting address');
            // --- end code

            This produces an output as follows

             

            MRAA version: v0.6.2
            [11568.327992] node[241]: segfault at 0 ip b76770ee sp bfe9abc0 error ffff0004 in jsupm_nrf24l01.node[b7670000+1d000]

            The hardware is a Galileo Gen 2 board with a fresh install of the IOT dev kit.

            • 3. Re: unable to work with nrf24l01 on Edison
              Rubik

              Hi CMata,

              Thanks for the quick reply.

               

              I've tried to work with the C++ example but I have 2 issues:

              1. I do not know hot to compile it as I'm working directly on Intel Edison, through SSH and I do not know all the parameters required by g++ to compile and link mraa and upm libraries

              2. I'm using the Mini Breakout board and onthis one the CE and CSN pins are not 7 and 8 ... I'm not sure which ones are but I assumed they are MRAA-9 and MRAA-23, as I deducted from the ediosn pinout table

               

              Regards,

              Rubik

              • 4. Re: unable to work with nrf24l01 on Edison
                CMata_Intel

                Hi Rubik,

                 

                In order to compile the UPM examples for C++ you have to do something like the following:

                Let's say you are going to use the Broadcast.cxx example. Once you have the code in your board you need to run:

                root@edison:~# g++ broadcast.cxx -o output -lupm-nrf24l01 -I /usr/include/upm
                
                
                
                

                And for running the executable:

                root@edison:~# ./output
                
                
                
                

                 

                About your second question, do you want to know which is the physical pin in the  Edison Module that is connected to the pins 7 and 8 of the Arduino Expansion Board? If this is the case the pins for 7 and 8 are:

                32 and 34, GP48 and GP49 , J19 - pin 6 and  J20 - pin 6.

                 

                Arduino Expansion Board pin

                Pin NumberLinux PinMini Breakout Board pin
                732GP48 J19 - pin 6
                834GP49 J20 - pin 6

                Edison Compute Module - Hardware Guide

                Breakout Board - Hardware Guide

                Arduino Expansion Board - Hardware Guide

                 

                Kind Regards,

                Charlie

                • 5. Re: unable to work with nrf24l01 on Edison
                  sulejmansarajlija

                  I was trying to compile this and was getting reference error on all nrf24l01 functions.

                  When I applied your solution I got:

                   

                   

                  g++ broadcast.cxx -o output -lupm-nrf24l01 -I /usr/include/upm

                  /tmp/ccdqB9Zu.o: In function `main':

                  broadcast.cxx:(.text+0x3ae): undefined reference to `upm::NRF24L01::~NRF24L01()'

                  collect2: error: ld returned 1 exit status

                  • 6. Re: unable to work with nrf24l01 on Edison
                    CMata_Intel

                    Hi sulejmansarajlija,

                     

                    It could be related with your image, mraa or upm version.

                    For this I suggest you to use the latest image in your board and to update the mraa and upm version you have installed on the board.

                     

                    Regards,

                    Charlie

                    • 7. Re: unable to work with nrf24l01 on Edison
                      sulejmansarajlija

                      Hi CMata_Intel , I think it was version mismatch. Can somebody here help me with pins on Arduino Edison breakout board. Can't figure out for MISO, MOSI, SCK, CE, CS.

                      • 8. Re: unable to work with nrf24l01 on Edison
                        CMata_Intel

                        Hi sulejmansarajlija,

                         

                        The pins for SPI on the Arduino Expansion Board are:

                         

                        PinDefinition
                        IO10CS
                        IO11 MISO
                        IO12 MOSI
                        IO13 SCK

                         

                        Take a look at the hardware guides of:

                        Arduino Expansion Board

                        Compute Module

                         

                        Regards,

                        Charlie