so i had the hm-10 ble module set up. basically, it was slowing down my program at 9600 baud. so then i increased the baud rate using a separate sketch by sending a couple AT commands. so after that, the baud rate was like 230400 (highest hm-10 can go), then i ran my original program and it was running faster (loop rate measure using micros)!
only downside was the BLE data it was writing was complete garbage when i read it on my phone. it was just random hex values instead of what it was actually supposed to send using BTSerial.write
so then i went back to change the baud of hm-10 using that sketch, and now i cannot even send AT commands to it. i tried changing the baud of the Serial Monitor and BTSerial, as well as the NL/CR options but no success.
i have no idea what to do because the first problem was the higher baud rate (altho made program faster) was sending broken data to my phone and then the second problem is now i can't change the baud rate of the HM-10 with AT commands.
i can show the code if needed but is there any advice anyway?
can't i just use one sketch and change the baud rate in there? this is the sketch. so like changing the 9600s to different bauds. i tried this though but no avail
#include <SoftwareSerial.h>
const int TX = 1;
const int RX = 0;
SoftwareSerial BTserial = SoftwareSerial(RX, TX);
char c=' ';
boolean NL = true;
void setup() {
Serial.begin(9600);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println(" ");
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
// do not send line end characters to the HM-10
if (c!=10 & c!=13 )
{
BTserial.write(c);
}
// Echo the user input to the main window.
// If there is a new line print the ">" character.
if (NL) { Serial.print("\r\n>"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
oh then that might be the case. yea i did try baud rates up to 230400. no avail. i thought there would be some logic though where i should know that it works at 230400 since the hm-10 is set to 230400 rate as well. also as to why i was getting junk data on my phone.
should i use the AltSoftwareSerial library that i have seen other people use? or wait, maybe i should use hardware serial? because i am using the Teensy 4.0 and the RX TX pins on it. therefore, i don't need software serial since i am using serial pins for serial comm in the first place.