I'm trying to create a wireless setup for measuring ECG from the human body using a Sparkfun AD8232, Nano, and HC-05. My HC-05 doesn't have ZS-040 written on it, but it has the button and EN pin. So far, I have been able to successfully observe ECG by replacing Serial.begin(9600) with Serial.begin(57600) in the tutorial Arduino code at this link: AD8232 Heart Rate Monitor Hookup Guide - SparkFun Learn
So it seems that the arduino baud rate is 57600. The console confirms this when I upload the script from that tutorial:
Using Port : COM7
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega328P
Chip Erase delay : 9000 us
So I've been trying to make sure that the HC-05 operates at this baud rate because the arduino nano/AD8232 combination works with this baud rate when connected to the serial port. I've tried using the code from Martyn (Arduino with HC-05 (ZS-040) Bluetooth module – AT MODE | Martyn Currey) as is and following these steps (not using a voltage divider at the moment):
- Setup all the connections (apart from voltage divider)
- Keep the Rx, Tx pins on the HC-05 disconnected and plug in USB to computer.
- Upload the code. Then connect the Rx, Tx pins back to the HC-05.
- Disconnect the Vcc on the HC-05, hold the button, connect the Vcc on HC-05, then release button.
- Open serial monitor, which is set at 9600 baud rate, both NL&CR chosen, and type 'AT' and press enter.
The serial monitor gives no output in response to the 'AT' command:
Sketch: C:\Users\fahee\Desktop\BTTry4\BTTry4.ino
23:41:36.589 -> Uploaded: Mar 10 2019
23:41:36.623 ->
23:41:36.623 -> BTserial started at 38400
23:41:36.623 ->
23:41:40.701 -> >AT
I have tried holding the button and sending the command, but no difference. I've also tried changing the Serial.begin(9600) in the code with Serial.begin(57600) and changing the serial monitor baud rate to 57600, but still doesn't work. I just want to make sure the baud rate is set correctly on the HC-05. Any ideas on what could be wrong? I'm thinking that maybe the voltage divider will fix the issue, based on the comments posted on his website.
Below is the code I'm trying to use for bluetooth:
// Sketc: basicSerialWithNL_001
//
// Uses hardware serial to talk to the host computer and software serial
// for communication with the Bluetooth module
// Intended for Bluetooth devices that require line end characters "\r\n"
//
// Pins
// Arduino 5V out TO BT VCC
// Arduino GND to BT GND
// Arduino D9 to BT RX through a voltage divider
// Arduino D8 BT TX (no need voltage divider)
//
// When a command is entered in the serial monitor on the computer
// the Arduino will relay it to the bluetooth module and display the result.
//
#include <SoftwareSerial.h>
SoftwareSerial BTserial(8, 9); // RX | TX
const long baudRate = 38400;
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(baudRate);
Serial.print("BTserial started at "); Serial.println(baudRate);
Serial.println(" ");
}
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();
BTserial.write(c);
// Echo the user input to the main window. The ">" character indicates the user entered text.
if (NL) { Serial.print(">"); NL = false; }
Serial.write(c);
if (c==10) { NL = true; }
}
}
And here is the code I'm using for the AD8232 to function with the Arduino, based on the tutorial provided from Sparkfun:
/******************************************************************************
Heart_Rate_Display.ino
Demo Program for AD8232 Heart Rate sensor.
Casey Kuhns @ SparkFun Electronics
6/27/2014
https://github.com/sparkfun/AD8232_Heart_Rate_Monitor
The AD8232 Heart Rate sensor is a low cost EKG/ECG sensor. This example shows
how to create an ECG with real time display. The display is using Processing.
This sketch is based heavily on the Graphing Tutorial provided in the Arduino
IDE. http://www.arduino.cc/en/Tutorial/Graph
Resources:
This program requires a Processing sketch to view the data in real time.
Development environment specifics:
IDE: Arduino 1.0.5
Hardware Platform: Arduino Pro 3.3V/8MHz
AD8232 Heart Monitor Version: 1.0
This code is beerware. If you see me (or any other SparkFun employee) at the
local pub, and you've found our code helpful, please buy us a round!
Distributed as-is; no warranty is given.
******************************************************************************/
void setup() {
// initialize the serial communication:
Serial.begin(57600);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO -
}
void loop() {
if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
Serial.println('!');
}
else{
// send the value of analog input 0:
Serial.println(analogRead(A0));
}
//Wait for a bit to keep serial data from saturating
delay(1);
}