Go Down

Topic: HC-05 bluetooth module Outputting beat not voices (Read 409 times) previous topic - next topic


We have two hc-05's communicating via AT commands. Baud rate: 115200
We have a DAC, DAC buffer, Low Pass filter, Signal amplitude, Amplifier, DC offset then amplifier connected to the slave Arduino and Microphone connected to Master Arduino.

The problem is we can only hear the beat of songs and audio. Anyway my code is wrong? Thank you.


Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial EEBlue(10, 11); // RX | TX
unsigned char incomingAudio = 0;

void setup(){
  EEBlue.begin(115200);  //Baud Rate for command Mode.
void loop(){
    incomingAudio = (analogRead(A0));//read voltage at A0


Code: [Select]

#include <SoftwareSerial.h>
SoftwareSerial EEBlue(10, 11); // RX | TX
unsigned char data = 0;
void setup() {
    TCCR0A = 0;// set entire TCCR1A register to 0
    TCCR0B = 0;// same for TCCR1B
    TCNT0  = 0;//initialize counter value to 0
    // set compare match register for 1000000hz increments with 8 bits prescaler
    OCR0A = 49;// = (16*10^6) / (1000000*8) - 1 (must be <65536)
    // turn on CTC mode
    TCCR0A |= (1 << WGM12);
    // Set CS11 bit for 8 prescaler. Each timer has a different bit code to each prescaler
    TCCR0B |= (1 << CS11); 
    // enable timer compare interrupt
    TIMSK0 |= (1 << OCIE1A);
   // sei();
    DDRD = 0xFF;

void loop() {
    if (EEBlue.available() > 0)
       data = EEBlue.read();

  PORTD = data;
  //insert your code here that you want to run every time the counter reaches OCR1A


There are some things to improve:

  • Doesn't seem like you're using the hardware serial port (Serial), so why using the software version instead?
  • For 115 kbps expect at most a sampling rate of 8 KHz, good enough for speech but not so great for music.
  • In the transmitter (not the receiver), adjust the timer so it fires the interrupt at 8 KHz (every 125 microseconds). Since it is the timer0, also disable the overflow interrupt to avoid jitter.
  • It is a good idea to speed up the ADC. I don't remember right now the register name, but you have to decrease its prescaler to its minimum.
  • If the transmitter stream data at a given pace, the receiver should as well (without having to time the output). If this actually leads to audio cuts or "slowdowns", you should consider buffering the receiver or both (if latency is not an issue).

And last: that's not how an analog readout should fit in a single byte, you have to discard two least significant bits:
Code: [Select]
Serial.write(analogRead(A0) >> 2);

The problem is we can only hear the beat of songs and audio.
Probably the ADC is too slow or the "data narrowing" is done incorrectly. I've said this in two of my suggestions.

If there's a low-pass filter at some point, it could be that its cutoff frequency is too low.

Anyway my code is wrong?
Partially. Everything I've pointed out mostly has to do with improving performance (and my experience since long ago I've made a similar experiment).


why do you keep posting the same issue with new posts?
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man


why do you keep posting the same issue with new posts?
Because it is a well known fact that if you keep asking enough times you will get the answer you like. It might not be right but there it is.

Go Up