For my wireless head mouse project using electro-house voice recognition module V3.1 and InvenSense MPU6050 IMU sensor, I chose HC-05 pairs as the Bluetooth medium. The sender Arduino has to send calculated data of the MPU and the voice command flag through a data structure to the receiver Arduino Micro. I have to use two software serials for HC-05 and Voice modules on the sender side. But the problem is that I can’t use two software serials parallelly which I need to decrease lag of the mouse cursor due to transmission latency. So, I can’t activate one and listen on the other. I need parallel transmission. My HC-05 pairs didn’t work on hardware serial. They did on the soft serial. but I could only use the MPU6050 because the Voice module also uses software serial. Then, I opted for NeoSoftSerial but it has the same problem as SoftwareSerial. Lastly, I tried to read the documentation of AltSoftSerial which can emulate a serial port and simultaneously transmit and receive. And one of the forum posts suggested that it can be used for parallel softserial connections. But I can’t get it to work transmit and receive data between my Arduino Micros. I followed their documentation as best as I could. Made sure to check the connection table for Arduino Micro on the PJRC website. Went into the library files to understand, saw the documentation. But couldn’t even transmit a byte or an int in the most basic circuit connection leaving out the Voice module and MPU.
Connection on both Arduinos
HC-05 BT Arduino Micro
VCC VCC
TX 5
RX 13
GND GND
Code: send and receive.ino respectively
#include <AltSoftSerial.h> AltSoftSerial altSerial; byte b=0; void setup() { Serial.begin(9600); altSerial.begin(9600); // HC-05 default speed in AT command more } void loop() { altSerial.write(b); if(!altSerial.write(b))Serial.println("TX Error"); else Serial.println(b); ++b; delay(100); }
#include <AltSoftSerial.h> AltSoftSerial altSerial; byte b =0; void setup() { //Wire.begin(); Serial.begin(9600); altSerial.begin(9600); // HC-05 default speed in AT command more altSerial.println("Hi"); } void loop() { int a = altSerial.available(); Serial.print(a); if(altSerial.available()){ byte b = altSerial.read(); altSerial.println(b); } //Mouse.move(Gyro_data.gyro_X, Gyro_data.gyro_Y); delay(100); }
a returns 0. So, I can say that number of bytes received on the receiver’s end is 0.