Hi, I need to connect two HM-10 BLE modules so I am testing out their connections with them both connecting to an arduino UNO each, which is being used as a softserial. I was following a tutorial that does the exact same thing I was trying to do however I couldn't get the same results.
So, what I did is that I did the test using my phone and it worked perfectly. However, once I tried connecting the two modules to each other (one set as master and the other as slave), I could manage to send AT commands to both, the TX and RX pins were working fine and the connections were right however I couldn't get their serials to communicate.
I was wondering if anyone has any experience with something similar, if there is a solution to this issue or if this is just hardware malfunction. Thanks in advance.
Also here's the code I am using:
// SerialIn_SerialOut_HM-10_01
//
// Uses hardware serial to talk to the host computer and AltSoftSerial for communication with the bluetooth module
//
// What ever is entered in the serial monitor is sent to the connected device
// Anything received from the connected device is copied to the serial monitor
// Does not send line endings to the HM-10
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// Arduino D8 (SS RX) - BT TX no need voltage divider
// Arduino D9 (SS TX) - BT RX through a voltage divider (5v to 3.3v)
//
#include <AltSoftSerial.h>
AltSoftSerial BTserial;
// https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
char c=' ';
boolean NL = true;
void setup()
{
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println(" ");
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
// do not send line end characters to the HM-10
//if (c!=10 & c!=13 )
//{
BTserial.write(c);
//}
// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) { Serial.print("\r\n>"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
The tutorial I was following: https://www.martyncurrey.com/hm-10-bluetooth-4ble-modules/