Where Technology meets magic

53 Posts
6 Posts
84 Posts
142 Posts
High Voltage
57 Posts
Image processing
5 Posts
4 Posts
3 Posts
27 Posts
11 Posts
7 Posts
3 Posts
21 Posts
19 Posts
9 Posts
9 Posts
91 Posts
2 Posts
23 Posts
Windows Mobile
11 Posts

Sponsored Links


Top Articles!

AVR SDCard FAT support with FatFS | 19620 Views | Rate 38.85
AVR SDCard FAT support with FatFS
Single Chip Computer | 1858 Views | Rate 29.03
Single Chip Computer
3V to 400V regulated inverter for Geiger counters | 2900 Views | Rate 18.71
3V to 400V regulated inverter for Geiger counters
Virtualmin Git return code 22 fatal: git-http-push failed | 111 Views | Rate 13.88
Virtualmin Git return code 22 fatal: git-http-push failed


News & Updates

2014-12-12, Virtualmin Git return code 22 fatal: git-http-push failed

2014-11-25, Electric Fence - 20KV pulses for perimeter defense

2014-10-29, Statie de monitorizare a radiatiei de fond in Timisoara

2014-10-29, uRADMonitor - Online Radiation monitoring station



Atmega8 with Bluetooth radio module

By Radu Motisan Posted on May 27th, 2009 , 2681 Views (Rate 1.32)

Microcontrollers do a great job for allowing the simple user to gain access to advanced electronics applications.

For one of the robots I've built, I had to find a way of connecting an Atmega8 running at 16MHz with a Windows Mobile Smartphone. The idea was that the microcontroller handles some basic sensor data and controls some motors, and the smartphone runs an advanced application that controls the robot.

So how to do it? I've tried Infrared, since the Smartphone had an infrared port, but had little success with that. No way of connecting the two via serial port, since the Smartphone only had an USB connector.

The final solution was a bluetooth radio link.

We all know that connecting an Atmega8 to a computer's serial port is easy, by using the famous MAX232 module:

Using Bluetooth was even easier, since no electrolytic capacitors were needed as in the case of the max 232:

Here's the module's datasheetfor details regarding voltage and other parameters.

The Atmega8 needed a 16MHz crystal to assure reliable UART functionality at 9600bps (to sync with the BT Module). After putting everything together, I could establish a conneciton from my Bluetooth enabled PC, to the Atmega8+BtModule, and serial port service was available and connected as COM4. Using Hyperterminal, exchanging data worked flawlessly.

See my bluetooth enabled Atmega8 as used in my latest robot, Perseus 3.

Wireless Bluetooth connectivity offers a large number of possible applications. Good thing it is so easy to use!

Radu Motisan

More on PocketMagic:

Atmega8 and enc28J60 for ethernet support | 8712 Views | Rate 9.98
Atmega8 and enc28J60 for ethernet support
How to set the AVR Fusebits | 6398 Views | Rate 9.86
How to set the AVR Fusebits
Custom Rotary Knob Control for Android | 3955 Views | Rate 9.65
Custom Rotary Knob Control for Android
Programmatically Injecting Events on Android - Part 1 | 8918 Views | Rate 9.24
Programmatically Injecting Events on Android - Part 1
Variable 0..30V Regulated Power supply for 20A max | 15173 Views | Rate 8.61
Variable 0..30V Regulated Power supply for 20A max
Discussing security in online on TV News show | 2650 Views | Rate 8.41
Discussing security in online on TV News show

35 Responses to “Atmega8 with Bluetooth radio module”

  1. 1


  2. 2
    Radu Motisan:


    I’ll do my best to help you, so let me know what you need.

  3. 3

    Could you send me a link or something about how to write the program or a program itself to atmega8 and bluetooth module connection ( mine is a rayson BTM 222 ). I mean program for the atmega microcontroller to handle the module. ( Basic would be the best,but anything would be a good help. )

  4. 4
    Radu Motisan:

    Szia Zsolt,

    I’m simply using the RX/TX to send/recieve serial data via UART. It worked from the first try

    Let me know if you need an UART sample.

  5. 5

    en si estioy en nada sobre ek proyecto no se por donde empesar pero no seria mas facil utilizar el usar antes que el uart bueno
    lo que estoy buscando haorita es un simulador para lo que va ser la tx y rx si tu vieras un simulador o algo que me ayude te lo agradeseria

  6. 6


    De unde ai cumparat modulul BT ?

  7. 7
    Radu Motisan:

    @razvan: ebay.

  8. 8
    Manas Paul:

    Dear Radu,
    I have needed the Bluetooth serial converter.I am in Kolkata.I dnt get this device in here market.So plz give me any site or address about this device.It too much important for me.So plz give me the site.I will buy in limited cost.So plz help me.
    Thank You.And nice Job.

  9. 9
    Radu Motisan:

    Paul, are you referring to the UART Bluetooth Module?

  10. 10
    Radu Motisan:

    You can purchase the module online from: http://cgi.ebay.com/Bluetooth-serial-converter-UART-interface_W0QQitemZ350323499668QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item5190e86294

  11. 11

    Salut! Poti sa ma ajuti un pic? Am un modul BT foarte asemanator, si nu stiu cum ar fi bine sa-l montez pe PCB.

  12. 12
    Radu Motisan:

    ce modul e? poti pune niste poze?

  13. 13

    Hi, first of all I have to thank you for share your work whit everyone, and second I have a question, I have an Atmega48P, can I use this mricrocontroller or do I need to get one different?

  14. 14
    Radu Motisan:

    Hello Diego, thanks.

    Yes you can use the Atmega48, to interface the bluetooth module you will only need the two uart pins tx and rx.

    Good luck, and feel free to post pictures with your project when completed.

  15. 15

    Did you have any interference problem using bluetooth? I’m using a roving networks rn-41 bt module with an atmega328 and a gyro (via ADC), and i get interference from bt module. If i try the board via serial cable, it works just fine, accurate and stable. When I change te cable for the rn-41 some kind of RF noise shows up, and it just never get stable, it’s always sending little variations (as if the gyro was being rotated, wich is not). I tried changing the supply of bt module just in case it would be a matter of high current consumption of BT, but it didn’t solve the problem. Later i tried to get the BT module away from atmega328 via cable extension (about 10 inches), and altough the noise still existed, it starter to show up in bigger intervals of time (there was more time between noise and noise). Sorry about my english, i’m not to good at it yet. Then i restored the bt to the board and extenden the gyro via cable to get it far away from BT, but the problem persisted. So i think the noise problem it’s between BT module and atmega328 … any hint on how to solve this? The size of the board it’s pretty important on my project, so getting the BT away it’s not really a solution since distance its huge (the entire board it’s 4 inches lenght)

  16. 16
    Radu Motisan:

    Hi Jorge,

    I didn’t get such issues, but,

    let’s not forget we are talking about digital transmissions, where information is digitally encoded, it also comes with checksums and error correction mechanisms, it is unlikely for a RF interference to corrupt the data at Bluetooth serial port profile protocol level.

    So I suspect there is a software bug somewhere, you might want to double check the Bluetooth code part , or post it here.

    Hope this helps,

  17. 17

    It’s not that the data sended by the bluetooth get corrupted. In a steady position, gyro shouldn’t send any data towards the MCU, since there is no angular velocity being applied to it. Therefore, MCU shouldn’t send any data towards the computer via BT module. But when in a steady position (i.e. laying in a table) the MCU sends constant data at the computer, as if the gyro was detecting constant movement being applied to him, wich is not. My first tought was that the gyro was being afected by the RN-41 (let’s remember that via cable, this doesn’t happen). Now after several tests (described above) i think the problem its somewhere between the RN-41 and the atmega MCU. I’m trying filters to see if i can get it stable.

    I know that gyro has an error range, that makes him detect angular velocitys even when there is none (or maybe some “natural” oscillations of the floor because of traffic or something), but according to datasheet, and to the tests i made via cable, these variations are a lot smaller than the ones i detect via Bluetooth. Lets say after ADC in range of 0-1023, normal variaton of gyro goes from +-3 of the “zero” reference (wich is 500), and when i connect via Bluettoth i detect variations from +-30. That’s a lot if you consider that moving the gyro really fast you’ll get aproximately +- 120 (so +-30 it’s actually a 25% noise signal).

    Thanks four your fast reply!

  18. 18

    Jorge, what are you building?

  19. 19

    I manage myself to find the cause of the problem. After re-cheking the complete pcb i found that one of the Power supply tracks that I was cutted in order to separate BT supply from MCU supply was not completley cutted. So i re-cutted it, test different Power Supplies for each part of the board and it worked just fine. So it was a problem of noise being generated by the RN-42 in the supply line, because of dramatic changes from low to high current consumption during TX.

    Klein: I’m trying to build a sort of stability control for my robot. The idea it’s to carry things in a container that is keept paralell to horizon all the time (so things don’t fall when climbing or descending).

  20. 20

    you mentioned that you connect your smartphone with atmega via BT. But you said connect with computer.Recently some people succeed in connect atmega with phone via BT.there is a library by mit on android.But i’m looking for ios.

  21. 21
    Radu Motisan:

    @feng, you don’t need any fancy library! Just some basic programming skills. Have a look here: http://www.pocketmagic.net/?p=869

  22. 22

    @Radu Motisan,yes.And I see your Android controlled robot ,that is what i’m serching for on ios.Sometimes i just do without PC.

  23. 23

    @Radu Motisan,see work by someone else.you both have well program skill

  24. 24
    Radu Motisan:

    Sorry feng, that would take time to develop.

  25. 25

    this make me consider to buy an android or flash android to itouch later

  26. 26

    hi…this is Titus
    i hv one doubt from bluetooth link
    can i do bluetooth link betwn android mobile to PIC controller(16F877A) ???
    if it is “yes”
    tel me hw
    give some idea to start and examples
    plzz help me

    this is my email id


  27. 27
    Radu Motisan:

    yes titus you can.

    the best example is this article, read it and see the schematics.

    what you need to do is connect the BT module to PIC’s UART pins.

  28. 28

    Radu, over on http://www.slideshare.net/erinyueh/android-bluetooth-introduction you mentioned “Using Bluetooth, I managed to control a 4×4 Robot (Drone) remotely, using my Android G1. I’m using a serial connection over bluetooth”.

    Is that code available for review somewhere? I would like to have a look at it if so.



  29. 29
    Radu Motisan:

    Hi Darrin, see the code here : http://www.pocketmagic.net/?p=1398

  30. 30
    Android controlled robot (via Bluetooth) – Part 1 « PocketMagic:

    […] a previous article, I've shown that it is possible to connect a bluetooth module to an ATMega micro controller via the […]

  31. 31

    Hi Radu,
    I have to make in my last year project a rectifier controlled by microcontroller PIC16F887, how can i use this rectifier to make my robot?

  32. 32

    Hello Radu, Do we need to use MAX232 if we are not using RS232 ? I wanna send data to my AtMega32 via android. So all I need is Atmega32 and Bluetooth Module, right ? Also suggest me Bluetooth Module for this

  33. 33
    Radu Motisan:

    @Shree: you are correct, the MAX232 is not needed for your purpose. You can use HC-05 Bluetooth modules, also available on Ebay.

  34. 34

    Hi Radu, Thanks for the Response. I see many HC-05 Bluetooth modules there, which one you suggest for ATmega32 ?

  35. 35

    Hello, I would like to use a HC-06 bluetooth module, but no success yet. The microcontroller doesnt get the right data from PC, but if I send something from the controller, I get it. Some suggestion?:)

Thank you for commenting. Your comment won't show until approved, which can take some time.