#define RxD 7 #define TxD 6 #define KEY 5 SoftwareSerial SoftSerial(RxD,TxD); #define debugline Serial // Port for debugging #define dataline SoftSerial // Port for communication with BT //#define debugline SoftSerial // Port for debugging //#define dataline Serial // Port for communication with BT
// inquire_HC05(); // configure_HC05(); debugline.println("Setup finished... Key LOW"); //For debugging, Comme nt this line if not required digitalWrite(KEY, LOW); // Disable commands dataline.println("R!"); //For debugging, Comment this line if not requ ired
debugline.println("ERROR(0): Line not recognized: "+line); dataline.println("ERROR(0)"); } void loop() { // echo_dataline(); accept_commands(); }
void inquire_HC05() { debugline.println("Setting up Bluetooth Command mode. Key HIGH, wait 10 sec. .."); //For debugging, Comment this line if not required digitalWrite(KEY, HIGH); // Disable commands //TODO Here it would be nice to do a reset delay(10000); debugline.println("Querying BT..."); //For debugging, Comment this lin e if not required sendBlueToothCommand("at"); sendBlueToothCommand("at"); sendBlueToothCommand("AT+VERSION?"); sendBlueToothCommand("AT+ADDR?"); sendBlueToothCommand("AT+NAME?"); sendBlueToothCommand("AT+ROLE?"); sendBlueToothCommand("AT+CLASS?"); sendBlueToothCommand("AT+UART?"); sendBlueToothCommand("AT+MRAD?"); sendBlueToothCommand("AT+STATE?"); sendBlueToothCommand("AT+PSWD?"); } void configure_HC05() { debugline.println("Configuring BT..."); //For debugging, Comment this line if not required sendBlueToothCommand("AT+NAME=HG"); sendBlueToothCommand("AT+UART=38400,0,0"); sendBlueToothCommand("AT+PSWD=7707"); delay(2000); // This delay is required. debugline.println("Setup complete, resetting BT..."); digitalWrite(KEY, LOW); // Disable commands sendBlueToothCommand("AT+RESET"); }