This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

System Look up error : NRF24L01 Raspeberry Pi C++

Hi 

I am  able to successfully compile  my C++ code on Raspberry Pi3 however while running an executable file. I am getting below error. 

pi@raspberrypi:~/RF24/librf24-rpi/librf24/examples $ ./Test2
./Test2: symbol lookup error: ./Test2: undefined symbol: _ZN4RF24C1ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjh
pi@raspberrypi:~/RF24/librf24-rpi/librf24/examples $

My Scenario : 

I am capturing a humidity  & temp data from Arduino and passing them as structure through NRF 24 module. My objective is to capture the structure  coming out from Arduino into Raspberry Pi3.

BTW, Arduino code is working fine and I am able to receive the structure in another Arduino sensor but not on Raspberry. 

Appreciate your help.

 Plz see the code below for both Raspberry Pi & Arduino code below. 

****************** Raspberry Code*********

#include <cstdlib>
#include <iostream>

#include "../RF24.h"
#include "MyLibrary.h"

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10


RF24 radio("/dev/spidev0.0",8000000 , 25); //spi device, speed and CSN,only CSN is NEEDED in RPI


// sets the role of this unit in hardware. Connect to GND to be the 'pong' receiver

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xE8E8F0F0E9LL, 0xF0F0F0F0D2LL };

Init_sensors Sensor;


struct HuMotion1{
float value;
float Humidity;
float Temp;
bool Humidifier_Status;
bool Lamp_Status;
int Daytime;
int HuMotion_loc;
};

HuMotion1 HuMotion11;
void setup(void)
{

radio.begin();

// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);

// optionally, reduce the payload size. seems to
// improve reliability
radio.setDataRate(RF24_250KBPS);
radio.setPayloadSize(sizeof(HuMotion11));
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(0x4c);
radio.setPALevel(RF24_PA_MAX);

//
// Open pipes to other nodes for communication
//

// This simple sketch opens two pipes for these two nodes to communicate
// back and forth.
// Open 'our' pipe for writing
// Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

radio.openReadingPipe(1,pipes[0]);
radio.startListening();

//
// Dump the configuration of the rf unit for debugging
//

radio.printDetails();
}

void loop(void)
{

sleep(1);
if ( radio.available() )
{
// Dump the payloads until we've gotten everything
//unsigned long got_time;
bool done = false;
while (!done)
{
// Fetch the payload, and see if this was the last one.
done = radio.read( &HuMotion11, sizeof(unsigned long) );


printf(" Humidity Date From Arduino...",HuMotion11.Humidity);

// Delay just a little bit to let the other unit
// make the transition to receiver
delay(20);
}

radio.stopListening();

}
}

int main(int argc, char** argv)
{
setup();
while(1)
loop();

return 0;
}

*********************** Arduino code*************

#include <SPI.h>
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include<dht.h>
#include "MyLibrary.h"
/**
* Connect module inputs to Arduino pins D13, D12,
 * D10. Open serial console at 38400 baud, and send
 * value "0" to reset all relays, or a channel number to
 * activate that relay.
**/
#define CE_PIN   9
#define CSN_PIN 10
#define CHANNEL1 A2  //Lamp
#define CHANNEL2 A3  //Humidifie
#define DHT11_PIN 3
int ledPin_Yellow = A5;                // the pin that the LED is atteched to
int ledPin_Blue = A4;
int ledPin_RED = A6;
int PIRsensor = 4;
int counter =0;
const int pResistor = A0;  // Analog Pin A0
dht DHT;
int ackMessg[6];
byte ackMessgLen = 4;
const uint64_t   deviceID = 0xE8E8F0F0E9LL; 
RF24 radio(CE_PIN, CSN_PIN);
/*
  Motion based humidity sensor and photo resistor driven relay switch
  when motion sensor will sense a movement , it will first ask Photoresistor to check of it is a day or night. 
  Depending on Day/Night photoresistor will turn on Lamp. Then DHT will check the current humidity level.
  If hudity level is less <  than 25 then it will switch on humidifier. 
  DHT is connected at Pin D3
*/
// Test
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;        
 
//the time when the sensor outputs a low impulse
long unsigned int lowIn;         
 
//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 5000;  
 
boolean lockLow = true;
boolean takeLowTime;  
//
//the time when the sensor outputs a low impulse  
int value;          // Store value from photoresistor (0-1023)
int cnt;
int cnt1=100;
Init_sensors Lib;
// the setup routine runs once when you press reset:
 struct HuMotion{
     float value;
     float Humidity;
     float Temp;
     boolean Humidifier_Status;
     boolean Lamp_Status;
     int Daytime;
     int HuMotion_loc;
    }myHuMotion;
void setup() 
{
  
    Serial.begin(9600); 
    radio.begin();
    initializeSensor(); //Initialize Sensor Data as Input or Output
    resetSensors(); // Reset all Sensors 
    delay(50);
}
void loop() 
{
     Sensor_Data_Loading(); // load Sensor data and initialize LED
     InvokePIR_Sensor(); // Before activating HuMotion first check if there is any motion in the room   
}
void InvokePIR_Sensor()
{
  if(digitalRead(PIRsensor) == LOW)
       {
       //Serial.println(Lib.put(402));
       Serial.println("Motion Detected");
       //Lib.Display(999);
       Serial.println(cnt1);
       cnt1++;
       lockLow = true;
        digitalWrite(ledPin_RED, HIGH);   //the led visualizes the sensors output pin state
        if(lockLow){  
        Pull_Photo_DHT(); //if there is movement then check photo Register and DHT
        Push_data_to_Hub(); //Push the current cycle data to Hub for monitoring
        //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
         Serial.println("---");
         Serial.print("motion detected at ");
         Serial.print(millis()/1000);
//         Serial.println(" sec"); 
         delay(50);
         }         
         takeLowTime = true;
       }
 
  if(digitalRead(PIRsensor) == HIGH)
       {       
         counter++;
         Serial.println("No Movment:");
         //Serial.println(counter);
         digitalWrite(ledPin_RED, LOW);  //the led visualizes the sensors output pin state
   
         if(takeLowTime){
          lowIn = millis();          //save the time of the transition from high to LOW
          takeLowTime = false;       //make sure this is only done at the start of a LOW phase
          }
         //if the sensor is low for more than the given pause, 
         //we assume that no more motion is going to happen
         if(!lockLow && millis() - lowIn > pause){  
             //makes sure this block of code is only executed again after 
             //a new motion sequence has been detected
             lockLow = true;                        
             Serial.print("motion ended at ");      //output
             Serial.print((millis() - pause)/1000);
             Serial.println(" sec");
             delay(50);
             }
       }
}
  void Sensor_Data_Loading()
  {
    //digitalWrite(ledPin, HIGH);
    int chk = DHT.read11(DHT11_PIN); 
    if(DHT.temperature >=0 && DHT.humidity >=0)
      {
      myHuMotion.Humidity = DHT.humidity;
      myHuMotion.Temp = DHT.temperature;
      myHuMotion.HuMotion_loc = 801; //Loft Area
      Push_data_to_Hub();
      }
  }
  void Pull_Photo_DHT()
  {
//    Serial.println(cnt1);
//    cnt1++;
    Pull_photoResistor();
    Pull_DHT();
   delay(1000);
   
  }
void Pull_photoResistor()
  {
   value = analogRead(pResistor);
    Serial.print("Photo Resister Day/Night Value: ");
    Serial.println(value);
   //You can change value "25"
    if (value > 400){
      digitalWrite(ledPin_Yellow, HIGH);  //Turn led off
      digitalWrite(CHANNEL1, LOW); //Turn OFF Lamp Relay
      Serial.println("Day");
      myHuMotion.Daytime = 403;
      Serial.println("Realy 13 not active");
      myHuMotion.Lamp_Status =false;
   // Launch Relay
    }
    else
    {
      digitalWrite(ledPin_Yellow, LOW); //Turn led on
      digitalWrite(CHANNEL1, LOW); //Turn ON Lamp Relay
      Serial.println("Night");
      myHuMotion.Daytime = 404;
      Serial.println("Realy 13  active");
      myHuMotion.Lamp_Status = true;
    }
  }
void Pull_DHT()
{
  
  if(myHuMotion.Temp >=0 && myHuMotion.Humidity >=0)
      {
      Serial.println(cnt);
      //cnt++;
      Serial.println("Data Sent from DHT :");  
      Serial.print("Humidity");
      Serial.print(" | ");
      Serial.print(myHuMotion.Humidity);
      Serial.print(" Temperature");
      Serial.print(" | ");
      Serial.println(myHuMotion.Temp);
      
      if (myHuMotion.Humidity >=34)
        {
        //digitalWrite(CHANNEL2, LOW); //Turn OFF Humidifier
        Serial.println("Realy 12 not active");
        myHuMotion.Humidifier_Status = false;
        }
      else
        {
        //digitalWrite(CHANNEL2, HIGH); //Turn ON Humidifier
        myHuMotion.Humidifier_Status = true;
        Serial.println("Realy 12 active");
        }
     }  
}
  void Push_data_to_Hub()  //Push Datat to Raspeberry/Hub for further processing 
  {
    bool HuMotion_rslt;
    HuMotion_rslt = radio.write(&myHuMotion , sizeof(myHuMotion) );
    if ( radio.isAckPayloadAvailable() ) 
        {
        digitalWrite(ledPin_Blue, LOW);
        radio.read(ackMessg,ackMessgLen);
        Serial.print("Acknowledgement received");
        Serial.print(ackMessg[0]);
        }
  }
  
void initializeSensor()
{
    pinMode(PIRsensor, INPUT);
    pinMode(ledPin_RED, OUTPUT);
    pinMode(pResistor, INPUT);  //Set pResistor - A0 pin as an input
    pinMode(ledPin_Yellow, OUTPUT);
    pinMode(CHANNEL1, OUTPUT);  //Relay Starting
    pinMode(CHANNEL2, OUTPUT);  //Relay Starting
}
  void resetSensors() //Reset and initialized Sensors
  {
    Lib.Initial_Env_Chk();
    boolean lockLow = true;
    radio.setDataRate( RF24_250KBPS );
    radio.enableAckPayload();
    radio.setRetries(3,5); 
    radio.openWritingPipe(deviceID);
    digitalWrite(PIRsensor, LOW);
    digitalWrite(CHANNEL1, HIGH);
    digitalWrite(CHANNEL2, HIGH);
  
  }
Parents Reply Children
No Data
Related