This is a basic question, but I really have tried my best to find a solution on the internet to no avail.
I have a fairly normal setup. HC05 module connected to an Arduino. The HC05 is also connected to my Mac's Bluetooth (fairly sure of this bc I used AT Commands to confirm). However, when I select the HC05 port in the Arduino IDE, nothing is printed in that port's serial monitor. Am I fundamentally misunderstanding something?
How do I make the Arduino print on my Mac's Arduino IDE through Bluetooth?
Here's my code:
#include <SoftwareSerial.h>
SoftwareSerial MegaloDon(10, 11);
bool isConnected = false;
void setup() {
pinMode(9, HIGH); //this pin is connected to "EN" on the HC05 and enables AT commands
Serial.begin(9600);
MegaloDon.begin(9600); //
connectBluetooth();
}
void connectBluetooth() {
digitalWrite(9, HIGH);
MegaloDon.println("AT"); //AT command
if (MegaloDon.find("OK")){
MegaloDon.println("Bluetooth ON");
digitalWrite(9, LOW);
Serial.println("Connected");
} else {
Serial.println("Attempting to reconnect...");
delay(2000); // wait 2 seconds before trying again
}
}
void loop() {
if (isConneced()) {
Serial.println("conneced?");
//I'd like to transmit data to my mac's serial monitor on the Arduino IDE here
} else {
Serial.println("not conneced");
connectBluetooth(); // Attempt to reconnect
}
}
bool isConneced(){
Serial.println("is it conneced?");
digitalWrite(9, HIGH);
MegaloDon.println("AT");
if (MegaloDon.find("OK")){
isConnected = true;
}
else{
isConnected = false;
}
digitalWrite(9, LOW);
}