+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Newbie level 4
    Points: 31, Level: 1

    Join Date
    Feb 2019
    Posts
    5
    Helped
    0 / 0
    Points
    31
    Level
    1

    nRF24L01 and ESP8266 in Arduino UNO

    I have been trying to push data into my API from Arduino UNO with ESP8266. The device connects to WiFi but fails in performing the data push after acquiring from sensor node via the nRF24L01 module attached to the arduino. Any idea?

  2. #2
    Super Moderator
    Points: 29,223, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,698
    Helped
    1102 / 1102
    Points
    29,223
    Level
    41
    Blog Entries
    9

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Are you sure that nRF24L01 is compliant with 802.11 such as ESP8266 is ? It seems like you are trying to connect modules having different wireless communication standards.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 4
    Points: 31, Level: 1

    Join Date
    Feb 2019
    Posts
    5
    Helped
    0 / 0
    Points
    31
    Level
    1

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Since Arduino is working as a medium between both can't I send the acquired data using the esp module



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 29,223, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,698
    Helped
    1102 / 1102
    Points
    29,223
    Level
    41
    Blog Entries
    9

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Initially I assumed a scenario with only one module of each of the above mentioned. Anyway, what do you think of, instead of giving short details, how about showing a description of the overall architecture in a slightly more elaborate way, such as a sketch, scribble or something like that?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  5. #5
    Newbie level 4
    Points: 31, Level: 1

    Join Date
    Feb 2019
    Posts
    5
    Helped
    0 / 0
    Points
    31
    Level
    1

    Re: nRF24L01 and ESP8266 in Arduino UNO

    i am sending here the receiver node code that gets the sent data from a remote node via nRF24L01 module and updates the thingspeak API with the esp8266 module. Arduino Uno is the interface

    Code:
    #include <SPI.h>
    #include <nRF24L01.h>
    #include <RF24.h>
    #include <Wire.h>
    #include <printf.h>
    #include <SoftwareSerial.h>
    
    #define RX 10
    #define TX 11 //for SoftwareSerial to communicate with the Tx and Rx of the WiFi module
    
    RF24 radio(8,9); //CE,CSN
    
    const byte address[6] = "00001";
    
    String AP = "*******";
    String PASS = "******";
    
    String API = "9O1EQOC9QR5LMSS9";
    String HOST = "api.thingspeak.com";
    String PORT = "80";
    String field1 = "field1";
    
    int countTrueCommand;
    int countTimeCommand;
    boolean found = false;
    
    int data;
    
    SoftwareSerial esp8266(RX, TX);
    
    void setup() {
      Serial.begin(9600);
      Serial.println(F("This is the central receiving node"));
    
      esp8266.begin(115200);
      sendCommand("AT",5,"OK");
      sendCommand("AT+CWMODE=1",5,"OK");
      sendCommand("AT+CWJAP=""+AP+"",""+PASS+""",20,"OK");
      countTrueCommand = 0;
        
      radio.begin();
      radio.openReadingPipe(0, address);  //setting the address at which we will receive the data
      radio.setPALevel(RF24_PA_MIN);  //can set this as minimum or maximum depending on the distance between the transmitter and the receiver
      radio.startListening(); //it sets the module to receiver mode
      Serial.print("Radio set for communication");
      radio.printDetails();
    }
    
    void loop() {
      if (radio.available())  //looking for the data
      {
        radio.read(&data, sizeof(data));  //reading the data
        sendCommand("AT+CWJAP?=0",5,"OK");
        String getData1 = "GET /update?api_key="+ API +"&"+ field1 +"="+String(data);
        Serial.print("data received: ");
        Serial.println(getData1);
        sendCommand("AT+CIPMUX=1",5,"OK");
        sendCommand("AT+CIPSTART=0,"TCP",""+ HOST +"","+ PORT,15,"OK");
        sendCommand("AT+CIPSEND=0," +String(getData1.length()+4),4,">");
      }
      delay(5);
    }
    
    void sendCommand(String command, int maxTime, char readReply[])
    {
      Serial.print(countTrueCommand);
      Serial.print(". at command => ?");
      Serial.print(command);
      Serial.print(" ");
      Serial.print("inside sendCommand loop");
      while(countTimeCommand < (maxTime*1))
      {
        esp8266.println(command); //at+cipsend
        if(esp8266.find(readReply)) //ok
        {
          found = true;
          break;
        }
        countTimeCommand++;
      }
      if(found == true)
      {
        Serial.println("Found!");
        countTrueCommand++;
        countTimeCommand = 0;
      }
      if(found == false)
      {
        Serial.println("Fail");
        countTrueCommand = 0;
        countTimeCommand = 0;
      }
      delay(500);
      found = false;
    }
    The device fetches the senor node data, connects to internet but fails in responding to the TCP process
    Last edited by KlausST; 12th February 2019 at 07:58. Reason: added code tags



  6. #6
    Super Moderator
    Points: 29,223, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,698
    Helped
    1102 / 1102
    Points
    29,223
    Level
    41
    Blog Entries
    9

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Sorry to say, but you are not so clear with the words to make explicit what you meant, so once again:

    how about showing a description of the overall architecture in a slightly more elaborate way, such as a sketch, scribble or something like that?
    BTW, regardless of where each module is placed on the process, it is not so evident at which part of the data flow the problem is happening.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  7. #7
    Newbie level 4
    Points: 31, Level: 1

    Join Date
    Feb 2019
    Posts
    5
    Helped
    0 / 0
    Points
    31
    Level
    1

    Re: nRF24L01 and ESP8266 in Arduino UNO

    My architecture:
    there's a remote sensor node and a receiver node. The sensor node is communicating data to the receiver node with nRF24 module. Now the receiver node, along with nRF24 module also has a wiFi module (esp8266) with which it has to update the APIs.

    What I meant is that the receiver is displaying data sent from sensor node, it also connects to WiFi. But I feel the WiFi connection disconnects before uploading the data. Is it any delay related issue the code might have?
    Last edited by anneshabaruah; 12th February 2019 at 13:10.



  8. #8
    Super Moderator
    Points: 29,223, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,698
    Helped
    1102 / 1102
    Points
    29,223
    Level
    41
    Blog Entries
    9

    Re: nRF24L01 and ESP8266 in Arduino UNO

    I feel the WiFi connection disconnects before uploading the data. Is it any delay related issue the code might have?
    Delays are always likely source of problem in programs, so I could bet that, yes. Anyway, your program does not check the connection status, ie do not try to reconnect (or report disconnection) in case this happens, so it is not possible to state that your feeling is correct or not.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  9. #9
    Newbie level 4
    Points: 31, Level: 1

    Join Date
    Feb 2019
    Posts
    5
    Helped
    0 / 0
    Points
    31
    Level
    1

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Quote Originally Posted by andre_teprom View Post
    Delays are always likely source of problem in programs, so I could bet that, yes.
    Keeping delay into consideration which part of the code would have caused it!



  10. #10
    Super Moderator
    Points: 29,223, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,698
    Helped
    1102 / 1102
    Points
    29,223
    Level
    41
    Blog Entries
    9

    Re: nRF24L01 and ESP8266 in Arduino UNO

    Quote Originally Posted by anneshabaruah View Post
    Keeping delay into consideration which part of the code would have caused it!
    At the sendCommand() routine, 500ms.
    Anyway you could find it by yourself.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



--[[ ]]--