Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Tutorial 9: Device control using smart phone’s Bluetooth and ATtiny85

By Ashutosh Bhatt

In this tutorial series, we have learned about interfacing potentiometer to get analog input, interfacing of RGB LED by generating PWM output, DC Motor speed control using PWM output, and some other things.

This tutorial explains the serial communication of ATtiny85 with Bluetooth module HC05. ATtiny85 does not have built-in UART or USART with Rx and Tx pins, but it supports configurable USI (universal serial interface). The Arduino programming allows us to use digital IO pins as Tx and Rx pins using SoftwareSerial library. So using this library, we shall make pin 7 (PB2) and pin 2 (PB3) of ATtiny85 work as Rx and Tx pins. The Bluetooth module HC05 communicates with ATtiny85 using these Tx and Rx pins.

The more interesting part is yet to come. The HC05 module gets commands from any smartphone Bluetooth through the Android app – that sends commands from the phone’s built-in Bluetooth. So the smartphone sends a command to ATtiny85 via the HC05 module to control any device. Sounds interesting? Let’s see how it is done.

If you are not following the series from the beginning, you should go through the following two tutorials that explain and demonstrate how to work with ATtiny85 and step by step guide to build hello world (LED blinking) application.

How to work with ATtiny85
LED blinking using ATtiny85

Circuit diagram

Circuit connections
The circuit is built using only three components HC05 module, relay module, and ATtiny85. HC05 (Bluetooth module) has four interfacing pins (1) Vcc (2) GND (3) Tx, and (4) Rx. Tx pin is connected with PB2 (pin 7), and Rx pin is connected with PB3 (pin 2). Vcc pin is connected with 5V, and GND pin is connected to pin four connected to ground. The relay module has three interfacing pins (1) Vcc, (2) GND, and (3) IN.  Vcc pin is connected with 5V because the relay is of 5V. GND pin is connected to pin 4 of ATtiny85. PB0 pin is connected to IN pin to switch relay ON/OFF. A 5 V supply is given  in the circuit.

Note: one may connect any AC (or DC) device with relay to its contact terminals so that when the relay is switched ON/OFF, the device will be turned ON/OFF

Circuit operation

  • When a 5V supply is sent to the circuit, the relay is OFF (so the device will also be OFF). The HC05 module will start blinking to indicate it is searching for another Bluetooth device to which it will be paired (connected)
  • The person, who wants to control the device, will first open the Android application by having Bluetooth data sending facility in his smartphone (you may get so many such applications in Google play store. search for “Bluetooth control for Arduino”). This application will search and pair with HC05 module (for pairing 1st time, it is required to enter Bluetooth passkey for HC05 module, which is by default 1234). When the smartphone get connected with the HC05 module, its blinking rate will be slow
  • Now type and send ‘1’ from the application. The phone Bluetooth will send this ‘1’ to the HC05 module
  • HC05 module will receive this ‘1’ and gives it to ATtiny85 through serial communication
  • When ATtiny85 gets command 1, it will turn ON relay by sending high to pin PB0. The device connected with the relay is also turned ON
  • Now to turn OFF the device (relay), the person has to send the command ‘0’ from the smartphone
  • Thus, the device is turned ON / OFF by sending commands through the smartphone

Program
The program is written in Arduino IDE software using the C programming language. It is compiled, and a HEX file is created that is downloaded into the internal FLASH of ATtiny85

Program logic
Initially, the program sends a message to the user’s smartphone that phone Bluetooth is connected with HC05 and sends command 1/0 to turn ON/OFF the device.

Then it waits for any data available from the serial port. If the ‘1’ or ‘0’ command is received, it will switch ON/OFF the relay by sending HIGH/LOW to the relay module input pin. Also, it sends a message to the user’s smartphone that the device is ON/OFF.

In the next tutorial, we shall learn to build a wireless sensor data logger.

You may also like:


  • ATtiny85 microcontroller tutorials, Part 6: LED intensity control using potentiometer…

  • Tutorial 7: DC motor speed control using ATtiny85
  • ATtiny85
    Tutorial 8: RGB LED interfacing with ATtiny85
  • ATtiny85
    ATtiny85 microcontroller tutorials, Part 1: Introduction

  • ATtiny85 microcontroller tutorials, Part 2: Working with ATtiny85

Filed Under: Tutorials
Tagged With: android, ATtiny85, bluetooth
 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Adjustable 0 to 30V 2A DC Power Supply Circuit (Part 1/13)
  • Adjustable +/- 1.25V to +/-22V 1A Power Supply Circuit (Part 2/13)
  • Adjustable 0 to 15V 1A Mini Power Supply (Part 3/13)
  • Constant 12V Power Supply for LED Circuits (Part 4/13)
  • Constant +/-9V DC Symmetrical Power Supply Circuit (Part 5/13)
  • Making a Circuit Breaker (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • STMicroelectronics and MACOM announce successful RF GaN-on-Si prototypes
  • Infineon expands its CoolSiC portfolio
  • STMicroelectronics and AWS collaborate for secure IoT connections
  • Pet feeding system using WhatsApp (protocol bridging with MQTT)
  • STMicroelectronics launches new MDmesh MOSFETs

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • P-Channel MOSFET always on
  • Space Vector PWM Help Needed
  • DIY test leads - source for lead ends?
  • hardcore floquet bloch scattering problem help
  • Limiting variable DC power source

RSS Electro-Tech-Online.com Discussions

  • 24v dc relays not de-energising
  • How do I test amplifier speaker output polarity?
  • How to get lots of PCBs made cheap?
  • XOR Gate Circuit From Diodes
  • 3.3V microcontroller vs 5V relay
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering