Can't read monitor serial data with nodemcu
Posted: Sun Dec 18, 2016 3:40 pm
Hello, I'm currently developing a beacon detector. I am using a nodemcu board and the HM-10 bluetooth module with the Arduino IDE. In my code, which I tested with the arduino nano, I can see the result of the AT command sent to the HM-10. However in nodemcu I can't see the result of this command, what is my error?
Code: Select all
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(14, 12);
int cnt = 0;
int started = 0;
int ind = 0;
const char endTag[] = "DISCE";
void setup()
{d
bluetooth.begin(115200);
Serial.begin(115200);
}
void loop()
{
if (started == 0)
{
bluetooth.print("AT+DISI?");
started = 1;
}
if (started ==1 && bluetooth.available())
{
char charIn = bluetooth.read();
Serial.print(charIn);
// look for the endTag while we are processing
if (charIn == endTag[ind])
{
ind++;
}
else
{
ind = 0;
}
// have we found the endTag?
if (ind == 5)
{
Serial.println("*"); //line end
started = 0;
ind = 0;
}
}
}