Also I would have thought blasting FOUR characters at the HM10 each and every time through loop., but at most reading only one coming back from the module, would be a recipe for disaster.
Try sending AT less often. e.g. every 1 second.
Then listen for a response.
pcbbc:
Also I would have thought blasting FOUR characters at the HM10 each and every time through loop., but at most reading only one coming back from the module, would be a recipe for disaster.
Try sending AT less often. e.g. every 1 second.
Then listen for a response.
you mean like this?
#include <SoftwareSerial.h>
#include "src\imLibrary\Relay.h"
#define BT_RX 10
#define BT_TX 11
#define STATE 12
SoftwareSerial HM10(BT_RX,BT_TX); // RX핀(7번)은 HM10의 TX에 연결
// TX핀(8번)은 HM10의 RX에 연결
bool once = false;
long mtime = 0;
void setup() {
Serial.begin(9600);
HM10.begin(9600);
pinMode(STATE, INPUT);
}
void loop() {
if(millis() - mtime > 1000)
{
char* c = "AT\n\r";
int i = 0;
while(i < 4)
{
HM10.write(c[i]);
i++;
}
mtime = millis();
}
if (HM10.available()) {
Serial.write(HM10.read());
}
if (Serial.available()) {
char c = Serial.read();
HM10.write(c);
}
}
but it won't reply "OK". it just nothing reply anything.