Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

nRF24L01 and ESP8266 in Arduino UNO

Status
Not open for further replies.

anneshabaruah

Newbie level 4
Joined
Feb 11, 2019
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
37
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?
 

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.
 

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

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?
 

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 a moderator:

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.
 

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:

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top