Hi All
My BTSerial.write doesn't seem to do anything! Can you help?
I am setting up a very simple Arduino and HC-05 to simulate the output from a heart monitor, emitting (eventually) at 1KHz. I have wired up the HC-05 to the Arduino Uno.The App I'm using is Serial Bluetooth Terminal. The communications function well, excepting on a specific aspect.
In the loop() I have two write/print commands:
BTSerial.write(postString);
Serial.println(postString);
-
With both commands, I get output on both the Serial Monitor and the App. That seems Okay.
-
If I comment out the line BTSerial.write, I STILL get output on BOTH the Serial Monitor and the App. This is NOT Okay.
-
If I comment out the line Serial.println, I get NO output on either the Serial Monitor or the App. This is NOT Okay.
This is what I was expecting:
for 2) If I comment out the line BTSerial.write, I would ONLY get output on the Serial Monitor.
for 3) If I comment out the line Serial.println, I would ONLY get output to the App.
I'm puzzled why the BTSerialwrite doesn't print, and, why the Serial.print writes to both channels!!
Can you help?
Could it have something to do with the pins I am using - or incorrectly using?
I look forward to your replies.
Regards
EGB
==============================
Here's an example of my Serial Output.
64900,12345.67,45678.90,34567,89
64935,12345.67,45678.90,34567,89
64970,12345.67,45678.90,34567,89
65006,12345.67,45678.90,34567,89
65041,12345.67,45678.90,34567,89
65077,12345.67,45678.90,34567,89
65112,12345.67,45678.90,34567,89
65147,12345.67,45678.90,34567,89
65182,12345.67,45678.90,34567,89
65218,12345.67,45678.90,34567,89
65253,12345.67,45678.90,34567,89
65289,12345.67,45678.90,34567,89
65324,12345.67,45678.90,34567,89
65359,12345.67,45678.90,34567,89
Here's my sketch code:
/* Simulates the output from a heart monitor, using HC-05 for the Bluetooth stream
* HR-05 connected to an Arduino
* All default parameters
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(0, 1); //TX, RX respectively
// ESSENTIAL: set pin 10 as OUTPUT/HIGH for initialization
// other pins needed for control by the SPI library):
const int chipSelectPin = 4; // 4 or 7;
const int W5500_SS = 10; // chip select
//Time
unsigned long now = millis();
String readString = "";
char postString[50] = " ";
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
delay(100);
}
void loop() {
now = millis();
readString = String(now);
readString += (",12345.67,45678.90,34567,89");
for (byte i = 0; i < readString.length(); i++) {
postString[i] = (char)readString[i];
postString[i+1] = '\0'; // Add a NULL after each character
}
BTSerial.write(postString);
Serial.println(postString);
}