Hi i have a question i am trying to control wireless servo with 4 bluetooth hc05 modules (2 receiver and 2 transmitter modules to not overload a single transceiver circuit) and potentiometer because i am going to make a bionic arm and it needs to react instantly but my problem is that sometimes modules not connecting together sometimes the module in the first transceiver circuit controls all the servos
The first transceiver (Coder) module will control 3 servos
The second transceiver (Maker) module will control 2 servos
footnote: I've programmed the hc05s to only connect to each other as AT+BIND=ADDR there may be an error in the code
When you need multiple serial devices to be connected, it is possible to create multiple software serial ports. But due to hardware limitation, Arduino UNO can only listen to one software serial at a time. Here provides an example for multiple software serial:
#include <SoftwareSerial.h>
SoftwareSerial serialOne(2, 3); // Software Serial ONE
SoftwareSerial serialTwo(8, 9); // Software Serial TWO
void setup() {
Serial.begin(9600);
while (!Serial) { // wait till Serial
}
serialOne.begin(9600);
serialTwo.begin(9600);
}
void loop() {
serialOne.listen(); // listening on Serial One
Serial.println("Data from port one:");
while (serialOne.available() > 0) {
char inByte = serialOne.read();
Serial.write(inByte);
}
Serial.println();
serialTwo.listen(); // listening on Serial Two
Serial.println("Data from port two:");
while (serialTwo.available() > 0) {
char inByte = serialTwo.read();
Serial.write(inByte);
}
Serial.println();
}
it may be simpler to move to an Arduino with multiple hardware serial ports, e.g. Mega, Due, etc or even ESP32 which has WiFi, Bluetooth clasic and BLE builtin
Why do you think that a single tranceiver-pair can get overloaded?
I don't think that you can overload a single tranceiver-pair
If you need a very fast reaction-time in the range of 10 milliseconds or even faster
The whole approach of using an arduino is wrong. You would need a controller with much more calculation-power than an arduino-uno with hardware serial or even using a different wireless technology than bluetooth
Why do you need a "coder" module and a "maker" module?
Please describe in detail what this means.
I am pretty sure that a solution can be found where a single pair of trancievers is enough for doing it all.
this sounds as though you are reading from a Serial port which is timing out, i.e. when you call Serial1.read(), etc if nothing is available it waits a second in case something arrives then times out returning -1
this is a common cause of 1 second delays in many programs
upload your code?
Yet, the transmitter code contains this delay(100);
I do not think you will need two sets of BT modules. A single sender and single receiver will do what you want.
I would recommend you send 5 bytes (mapped analog readings) with start and stop markers.
I also like the suggestion of the ESP32 with the built in Classic Bluetooth.
If you do choose to use a board like the Uno or Nano, you can probably speed things up by connecting the HC05 modules to the hardware serial pins. I don't see you using input from the Monitor. You will have to disconnect the modules when loading code.