Hello!
I’ve got this HM-10 bluetooth module. I’ve pulled up putty and at the AT kommand “AT” i get “OK” so in some regards it works. But now I want to get two of them to talk to each other, and I’m having some problems.
To accomplish this I use SoftwareSerial library, and really just copy pasted the example code. I stuffed up somewhere, because it does not work. I’ll post my code and maybe someone could spot it:
Node 1, sending data:
#include <SoftwareSerial.h>
// 10 - Goes to HM-10 module pin marked "TX"
// 11 - Goes to HM-10 module pin marked "RX"
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
// Setting up serial com with pc
Serial.begin(9600);
// Setting up serial with HM-10 module
BTSerial.begin(9600);
// Init complete
Serial.println("Init done!");
}
void loop()
{
// Outputting something so I know it's doing _something_
Serial.println("Writing data...");
// Write simple data to the HM-module
BTSerial.write("FOO");
// Sleeping for 1s before going at it again...
delay(1000);
}
Node 2, receiving data:
#include <SoftwareSerial.h>
// 10 - Goes to HM-10 module pin marked "TX"
// 11 - Goes to HM-10 module pin marked "RX"
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
// Setting up serial com with pc
Serial.begin(9600);
// Setting up serial with HM-10 module
BTSerial.begin(9600);
BTSerial.listen();
// Init complete
Serial.println("Init done!");
}
void loop()
{
// Checking if there is data on the HM-module, ifso output it
if(BTSerial.available())
{
Serial.println("GOT DATA!");
Serial.println(BTSerial.read());
}
}
“GOT DATA” never appears :’(. These are two Arduino UNO. The LEDs on the bluetooth module is blinking steady. Anyone got an idea?