can one arduino work with esp8266 and RF ?

hi, can i ask if one arduino can work when i connect esp8266 and RF?

i did the programming, but its not working.

can anyone help me? i think the problem is the programming…

testwifi1.0.ino (3.64 KB)

//include anything needed for sensor
#include<SoftwareSerial.h>
#include <VirtualWire.h>

SoftwareSerial SoftSerial(10,11); // RX, TX pin

int i,a=0,b=0,c=0;

#define SSID "Lenovo P70-A"
#define PASS "aaaa4444"
#define IP "184.106.153.149" //api.thingspeak.com IP Address
String apiKey = "85OUN0FQEUFO576B"; //Thingspeak key
// Initialization (the int, boolean, etc)
int retry_attempt = 0;


void setup() { //setup for sensors

  vw_set_ptt_inverted(true);
  vw_set_rx_pin(12);  //receiver pin
  Serial.begin(9600);
  vw_setup(4000);  // Bits per sec
  vw_rx_start();       // Start the receiver PLL running
  
  SoftSerial.begin(9600);
  delay(100);
 // reset ESP8266 (no need change)
  debugPrint("AT+RST");
  debugPrint("AT");
  if(SoftSerial.find("OK")){
    Serial.println("ESP8266 detected!");
    connectWiFi();
  }
  else{
    Serial.println("ESP8266 not detected!");
    debugPrint("AT+RST");
    connectWiFi();
  }
}

void loop() {
  // Read all the sensors' data
  uploadData();
  // thingspeak has a 15 secs interval between updates
  delay(100);
}

void uploadData()
  {
    uint8_t buf[VW_MAX_MESSAGE_LEN];    //msg
    uint8_t buflen = VW_MAX_MESSAGE_LEN;//lenght of the msg

    if (vw_get_message(buf, &buflen)) // Non-blocking, received the data
    {
      Serial.println("Received");
      for(i=1;i==0;i--)
      {  //receive 11, switch one and Mode:on
      if( buf[0]=='1' && buf[1]=='1' )
        {Serial.println(11);a=1;}
         if( buf[0]=='1' && buf[1]=='0' )
        {Serial.println(10);a=0;}
      } 
                        

     for(i=1;i==0;i--)
     {  //receive 21, switch two and Mode:on
      if(buf[0]='2')
    {
     if(buf[1]=='1')
     {Serial.println(21);b=1;}
      if(buf[1]=='0')
    {Serial.println(20);b=0;}
    }  
    } 

      for(i=1;i==0;i--)
      {  //receive 31, switch three and Mode:on
      if(buf[0]=='3')
    {
      if(buf[1]=='1')
      {Serial.println(31);c=1;}
      if(buf[1]=='0')
     {Serial.println(30);c=0;}
    }
    }
  }

  char buffer1[16];
  char buffer2[16];
  char buffer3[16];
  String strA = dtostrf(a, 4, 1, buffer1);
  String strB = dtostrf(b, 4, 1, buffer2);
  String strC = dtostrf(c, 4, 1, buffer3);

  Serial.print("a");Serial.print(a);
  Serial.print("b");Serial.print(b);
  Serial.print("c");Serial.print(c);

  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  SoftSerial.println(cmd);
  if(SoftSerial.find("Error"))
  {Serial.println("AT+CIPSTART error");return;}

  // Prepare GET string(edit this for our sensors)
  String getStr = "GET /update?api_key=";
  getStr += apiKey;
  getStr += "&field1=";
  getStr += String(strA);
  getStr += "&field2=";
  getStr += String(strB);
  getStr += "&field3=";
  getStr += String(strC);
  getStr += "\r\n\r\n";

  // send data length (no change)
  cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  SoftSerial.println(cmd);
  if(SoftSerial.find(">")){
    debugPrint(getStr);
  }
  else{
    SoftSerial.println("AT+CIPCLOSE");
    Serial.println("AT+CIPCLOSE");
    connectWiFi();
  }
 
  }

  void debugPrint(String cmd)
  {SoftSerial.println(cmd);Serial.println(cmd);}

  boolean connectWiFi(){
  delay(5000);
  SoftSerial.println("AT+CWMODE=1");
  SoftSerial.flush();
  if(SoftSerial.find("OK"))
  {Serial.println("STA mode Selected!");}

  String cmd = "AT+CWJAP=\"";
  cmd += SSID;
  cmd += "\",\"";
  cmd += PASS;
  cmd += "\"";
  debugPrint(cmd);
  SoftSerial.flush();
  delay(5000);
  if(SoftSerial.find("OK"))
  {Serial.println("Succesfully joined AP");return true;}
  else{
    retry_attempt++;
    Serial.print("Error connecting to AP \n Retry attempt:");
    Serial.println(retry_attempt);
    return connectWiFi();
    }
  }

What are you trying to achieve? engage in a communication between an nRF24L01 module to an ESP8266 module? are you trying to use the nRF24L01 to be a serial input for an ESP?

in what way have you wired this?

if you just try to get communication between nRF24L01 and the ESP without additional hardware, not that won't work. They don't speak the same protocol

(the code you have with the 2 roles is to get a nRF24L01 talking to another nRF24L01)

my project is the RF receiver get the data from RF transmitter and then send to online (thingspeak)

ah did not see the second code you posted.

what error do you get? your code has many lines testing for possible errors. do you get one of those?

Also are you sure

  • your ESP is setup to discuss at 9600 bauds?
  • you connected the 10 and 11 pins correctly to the right Rx and Tx of the ESP? (10 should go to the Tx of the ESP, 11 to the Rx of the ESP)?
  • you are using 3.3V logic from your arduino to the ESP?

Double-posting is frowned upon here, and only leads to confusion. You should just stick to one copy of your thread.