Sunday, December 20, 2015

Using HC-06 to program Arduino

I have been fighting the HC-06 module for a bit longer than I am usually comfortable with and decided to put it all together here.

The instructions should be the same on all Linux distributions with the bluez package installed. I have verified it on Ubuntu 15.10 with all the updates and it doesn't work. It does however work on Linux Mint 17.2...

  1. Configure the HC06 module to connect at 115200bps - best done with Arduino IDE and a USB-to-TTL converter

    AT+BAUD8

  2. Using a USBAsp programmer (or another Arduino) burn the Arduino Mini bootloader (Pro Mini didn't work at all in my case!)
  3. Find out the MAC address of module you want to use:

    hcitool scan

  4. Connect the module (replace xx:xx:xx with actual MAC of your module)

    sudo rfcomm connect /dev/rfcomm0 98:D3:32:xx:xx:xx 1

    The red LED on the HC-06 should go solid at this point

  5. Reset the board using on-board reset switch or short-circut the RST pin to the ground
  6. Validate the connection with AVRDUDE

    avrdude -c arduino -p m328p -P /dev/rfcomm0

    You should see something like this:

    user@host:~$ avrdude -c arduino -p m328p -P /dev/rfcomm0 
    
    avrdude: AVR device initialized and ready to accept instructions
    
    Reading | ################################################## | 100% 0.07s
    
    avrdude: Device signature = 0x1e950f
    
    avrdude: safemode: Fuses OK (H:00, E:00, L:00)
    
    avrdude done.  Thank you.
    

Happy connecting!

No comments: