Arduino Uno with more than one HC-05

Can I have multiple HC-05 modules on the Arduino Uno connected using the SoftwareSerial library?
I have two ESP32 boards and I want them both to communicate with the Uno. The two ESP32 do not communicate with each other. They each only communicate with the Uno.

I have two HC-05 modules, one for each ESP32. I found that when I begin the Serial port for both modules, a connection is established but no messages are sent. Is this to be expected?

1. AT UNO side: Try one BT with Software UART Port (SRX = 5, STX = 6) and the second BT with Hardware UART Port (RX = 0, TX = 1). (During sketch uploading, disconnect BT from DPin-0, 1 and put it back after uploading.)

2. You have to go on Master-Slave scheme.

3. AT ESP32 side: you can use the built-in classic BTs of the ESP32 Dev Boards.

Are you referring to one controller as the Master and the other as the Slave? Since each ESP is only communicating with the Uno, I have both ESPs as master controllers while the Uno is the slave controller.

I mean:
ESP32-1's classic BT is Master and will be paired with BT1 (Slave) of UNO over UART Port.

ESP32-2's classic BT is Master and will be paired with BT2 (Slave) of UNO over SUART Port.

Be aware that only one SoftwareSerial can listen at a time. So you need to design a protocol to confirm to the sending ESP32 that you indeed have received the data; if not, the ESP32 should retry.

You will be far better of using a board with multiple hardware serial ports (e.g. Mega or Nano Every); or at least one free hardware serial port (Leonardo, Micro).

I did this and it kinda works. If I send a message from ESP1's serial input, I can see the message on the Uno's and ESP2's output. This is also true when I send a message from ESP2.

But I dont see the messages I send from the Uno echoed on either ESP Board.

I am using the BTM example code on the ESP boards. The following is my Uno code:
I have ESP2 connected TX 1, RX 2

SoftwareSerial SUART(5, 6);
void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);
}
void loop() {
  if (SUART.available())
  {
    char x = SUART.read();
    Serial.write(x);
    
}
if (Serial.available()) {
    char c = Serial.read();
    SUART.write(c);
    Serial.print(c);
  }
}

Could you elaborate on this protocol? How do I make sure I'm only reading from one ESP at a time. It would be okay for my project if ESP1 sent a message every 5ms and ESP2 sent a message every 10ms. Would this method allow communication with both ESPs from the Uno at the "same time"?

First off, check https://docs.arduino.cc/learn/built-in-libraries/software-serial/#listen so you can switch.

The protocol could be simple.

  1. ESP1
    • ESP1 sends "hello".
    • Uno reads for message and sends it back to ESP1.
    • ESP1 waits for reply from Uno.
  2. ESP2
    • ESP2 sends "world".
    • Uno reads for message and sends it back to ESP2.
    • ESP2 waits for reply from Uno.

You might be better off to let the Uno poll the ESPs.

  1. Uno starts listening to ESP1
  2. Uno sends command "please give me data" over HC05 for ESP1.
  3. ESP1 sends data.
  4. Uno processes data.
  5. Uno starts listening to ESP2
  6. Uno sends command "please give me data" over HC05 for ESP2.
  7. ESP2 sends data.
  8. Uno processes data.