Attiny85 + HC05 - Connection test with source code

In today's tutorial, we'll show you how to test the connection between the bluetooth module HC-05 and the AtTiny85 chip based on simple character transmission via the Android phone terminal application.
The attached program for AtTiny85 can be used for any chip from the AtTiny AtMega family. It can only be different in selected digital pins.
#define RX 3
#define TX 4
#define pinLED 0
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(TX, RX);
void setup() {
bluetooth.begin(9600);
pinMode(pinLED, OUTPUT);
}
void loop() {
byte BluetoothData;
if (bluetooth.available() > 0) {
BluetoothData=bluetooth.read();
switch (BluetoothData) {
case '0':
digitalWrite(pinLED, LOW);
bluetooth.println("Turning LED OFF.");
break;
case '1':
digitalWrite(pinLED, HIGH);
bluetooth.println("Turning LED ON.");
break;
case 'c':
bluetooth.print("System running: ");
bluetooth.print(millis()/1000);
bluetooth.println(" seconds.");
break;
case '\r':
break;
case '\n':
break;
default:
bluetooth.println("Unsupported command.");
}
}
delay(100);
}
Terminal applications for communication with bluetooth modules are hundreds. The best application to me and the way I use it is the Serial Bluetooth Terminal from Shop Play.

Comments

Popular posts from this blog

Web scraper via Arduino & NodeMCU & ESP32

ESP32 control via UDP datagrams

Biking on Google Maps - Arduino Leonardo (32u4) - HID device