Arnov Sharma
Published © LGPL

ATtiny85 with HC-05 Bluetooth Module

A simple tutorial on connecting the low-cost ATtiny85 with a Bluetooth module to toggle load.

BeginnerFull instructions provided18 minutes9,341
ATtiny85 with HC-05 Bluetooth Module

Things used in this project

Story

Read more

Schematics

1

2

Code

code

C/C++
#include <SoftwareSerial.h>  //Software Serial Port
#define RxD 1
#define TxD 0

#define DEBUG_ENABLED  1
 
SoftwareSerial blueToothSerial(RxD,TxD);

int led = 4 ;
 
void setup() 
{ 
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
  
  pinMode(led,OUTPUT);

 
} 
 
void loop() 
{ 
  char recvChar;
  while(1){
    //check if there's any data sent from the remote bluetooth shield
    if(blueToothSerial.available()){
      recvChar = blueToothSerial.read();

        if(recvChar==0)
          digitalWrite(4,HIGH);  
       
        else
          digitalWrite(4,LOW); 
    }
  }
} 
 
void setupBlueToothConnection()
{
  blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 38400
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=HC-05\r\n"); //set the bluetooth name as "HC-05"
  blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  
  delay(2000); // This delay is required.
  //blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable 
  blueToothSerial.print("bluetooth connected!\n");
  
  delay(2000); // This delay is required.
  blueToothSerial.flush();
}

Credits

Arnov Sharma

Arnov Sharma

269 projects • 275 followers
Just your average MAKER

Comments