Hi there,
I want to build something that detects a Smartphone when it comes into reach of an hm-10 Bluetooth module using an Arduino nano.
But I was not able to connect to the Bluetooth module in any way yet.
I tried to connect the BT module to my phone (Motorola moto g 2), but it told me that the paring code was wrong. I tried different pairing codes, only when I tried 0000 it didn’t show the error message, but it also didn’t pair.
So I wanted to connect it to my PC using the Arduino and serial communication and try it out, but I can’t get it to work. I used different code options for the Arduino, but when I send AT in the serial monitor I never got a response.
// Basic serial communication sketch using AltSoftSerial (ASS).
// Uses hardware serial to talk to the host computer and ASS for communication with the Bluetooth module
//
// When a command is entered in the serial monitor on the computer
// the Arduino will relay it to the Bluetooth module and display the result in the serial monitor.
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// Arduino D8 ASS RX - BT TX no need voltage divider
// Arduino D9 ASS TX - BT TX through a voltage divider
//
#include <AltSoftSerial.h>
AltSoftSerial BTSerial;
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");
// If using an HC-05 in AT command mode the baud rate is likely to be 38400
// Comment out the above 2 lines and uncomment the following 2 lines.
// BTSerial.begin(38400);
// Serial.println("BTserial started at 38400");
Serial.println("");
}
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();
BTSerial.write(c);
// Echo the user input to the main window. The ">" character indicates the user entered text.
if (NL) { Serial.print(">"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
I’m using this BT modul: https://www.ebay.de/itm/Bluetooth-4-0-CC-2541-HM-10-Transceiver-DIY-Modul-RS232-fur-Arduino-Raspberry-Pi/401269171562?hash=item5d6d81a56a:g:454AAOSw6n5Xvcmm
And this board for mounting it: https://www.amazon.de/TOOGOO-Arduino-Bluetooth-Bord-Transceiver-Empfaenger-gruen/dp/B0714DKT3W/ref=sr_1_2?ie=UTF8&qid=1534950520&sr=8-2&keywords=Bluetooth++arduino
Since I don’t know if the second board is the right one for what I want, I also soldered wires to the BT module itself and tried to connect it, but that didn’t help. I followed this schematic, even though I don’t know how the switch should work in this case.
I also tried holding down the button on the board while powering it up, but that didn’t help either.
I hope someone can help me, that would be very nice.