HC-05 Bluetooth speed issues with arduino and atmega16

Hi. Does anyone have any ideas as to why the HC-05 bluetooth modules would have the transmission speed get slower after the modules have been connected for a while ?
Everything works fine when they are first powered on and they have basically a 1/2 second delay in transmission. If they are on and connected for 5 minutes, this time increases to 3 seconds and it gets worse, the longer they stay connected.
If I power off either one of the Hc-05 modules for a few seconds and turn it back on, then everything is back up to speed .
the 2 modules and atmega16 are set at 9600 baud. the atmega16 are both at 1mhz internal clock speed.
Thanks


#include "header.h"
  const int LED_BKL    = 16; // BACKLIGHT  
  const int PIN_M      =  2; // MOTOR 7     
  const int SW_UP      = 31; // UP SWITCH  
  int state = 0; 
void setup() {

    pinMode(LED_BKL,  OUTPUT);  
    pinMode(PIN_M,    OUTPUT);  
    pinMode(SW_UP,   INPUT_PULLUP); 
 
    Serial.begin(9600);
 }
void loop() {
 if(Serial.available() > 0){ 
    state = Serial.read(); 
 }
 if (state == 'A') {
  digitalWrite(LED_BKL, HIGH); 
 }
 if (state == '0') {
  digitalWrite(LED_BKL, LOW);
 }
if (digitalRead(SW_UP) == LOW) {
   Serial.write('B'); 
   digitalWrite(PIN_M, HIGH);
 }
 if (digitalRead(SW_UP) == HIGH) {
  Serial.write('0'); 
  digitalWrite(PIN_M, LOW);
 }  
}

Here is a bet.
Your problem has nothing to do with Bluetooth and everything to do with your code, which is apparently a secret.

I JUST POSTED THAT.
FYI: I have an led on each atmega16 that lights when the serial is sent and turns off when the switch is released and there is NO lag time there.

ALSO
the code on the two chips is the same , except the B and the A are reversed

Looks like I solved it.
I changed the baud rate on all 4 items to 38400 and it seem to be stable after 20 minutes
and, there is no time lag at all

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.