HC05 and esp8266 wifi module not working together

trying to use both HC05 and esp8266 wifi module together with arduino nano, but observed that only one works at a time. Is there arduino limitation on using 2 SoftwareSerials together? any solution for this?

if BTserial.begin() is called after esp8266.begin(), then bluetooth send-receive works fine, but esp8266 functionality stops, and if i reverse their begin() function call sequence, then esp8266 works fine and bluetooth stops working.


#include <SoftwareSerial.h>
#include <Wire.h>                   // Library for I2C communication
#include <LiquidCrystal_I2C.h>      // Library for LCD

SoftwareSerial BTserial(17, 16); // RX | TX
SoftwareSerial esp8266(3,2);


void setup() {
  Serial.begin(9600);  


  BTserial.begin(38400);  
  esp8266.begin(115200);     
}

void loop(){
	String cmd = readBluetoothCommand();    
    
    if (cmd == "<toggle>"){
        DoSomething();
    }
}

String readBluetoothCommand(){       
  String s = "";
  if (BTserial.available()){
    s = BTserial.readStringUntil('\n');    
  } 
  s.trim();    
  return s;
}
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.