Arduino Micro and HC-05: unable to communicate

Hello,
I am able to send AT commands to my Arduino Micro + HC-05 module as described here: Getting Started with Johnny Five and HC 05 Bluetooth Serial Port Module · rwaldron/johnny-five Wiki · GitHub

I then wire up the HC-05 to pins Tx and Rx (crossover style config) and then:

  • open arduino ide and select tools => port => RandomBot (the Bluetooth port)

Upload the following code to the Arduino:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial mySerial(rxPin, txPin); // RX, TX
char myChar ;

void setup() {
  Serial.begin(38400);   
  Serial.println("Goodnight moon!");

  mySerial.begin(38400);
  mySerial.println("Hello, world?");
}

void loop(){
  while(mySerial.available()){
    myChar = mySerial.read();
    Serial.print(myChar);
  }

  while(Serial.available()){
   myChar = Serial.read();
   mySerial.print(myChar);
  }
}

At this point, the bluetooth icon on my mac goes to "connected" mode and shows that the HC05 bluetooth device is connected.

However, the arduino IDE shows the following error:

Sketch uses 5598 bytes (19%) of program storage space. Maximum is 28672 bytes.
Global variables use 298 bytes (11%) of dynamic memory, leaving 2262 bytes for local variables. Maximum is 2560 bytes.
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding
Found programmer: Id = "߿K"; type = �
    Software Version = �.; Hardware Version = .
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: butterfly_recv(): programmer is not responding
avrdude: error: programmer did not respond to command: leave prog mode
avrdude: error: programmer did not respond to command: exit bootloader
avrdude: error: programmer did not respond to command: exit bootloader

I have selected board as "Arduino Micro" and port as equivalent Bluetooth port that shows in Arduino IDE.

Any suggestions on how I can fix this issue?

You won't be able to upload to your Micro over the Bluetooth connection unless you change to a custom bootloader. The bootloader of the Micro is written to do uploads over the USB CDC serial port. Pins 0 and 1 on the micro are the hardware serial port (Serial1 in your Arduino sketches). That is a completely different communication interface from the USB CDC port, and thus the standard Micro bootloader has no way of handling uploads over the hardware serial port.

You're probably trying to follow a tutorial for an Uno, Nano, or Mega, which use the hardware serial port connected to pins 0 and 1 for uploads, and thus have a bootloader that is made for this purpose.

Pert:
Thank you for the reply. In that case, do you have suggestions on what I can do to control my Arduino Micro using Johnny-Five?
I am following this tutorial for ArduinoUno

However, I get the following error thrown:

1579306266223 Connected /dev/tty.BotMe2-SPPDev
1579306276230 Device or Firmware Error A timeout occurred while connecting to the Board.

Please check that you've properly flashed the board with the correct firmware.
See: https://github.com/rwaldron/johnny-five/wiki/Getting-Started#trouble-shooting

If connecting to a Leonardo or Leonardo clone, press the 'Reset' button on the board, wait approximately 11 seconds for complete reset, then run your program again.
events.js:173
    throw err; // Unhandled 'error' event
    ^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at Board.emit (events.js:171:17)
    at Board.EventEmitter.emit (domain.js:442:20)
    at Board.log (/Users/aphadke/webfast/postleaf/code/node_modules/johnny-five/lib/board.js:645:8)
    at Board.(anonymous function) [as error] (/Users/aphadke/webfast/postleaf/code/node_modules/johnny-five/lib/board.js:656:14)
    at Board.<anonymous> (/Users/aphadke/webfast/postleaf/code/node_modules/johnny-five/lib/board.js:387:14)
    at ontimeout (timers.js:424:11)
    at tryOnTimeout (timers.js:288:5)
    at listOnTimeout (timers.js:251:5)
    at Timer.processTimers (timers.js:211:10)

I have opened an issue with JohnnyFive here: HC-05 bluetooth connection timeout with Arduino Micro · Issue #1648 · rwaldron/johnny-five · GitHub

Also, is there a tutorial that talks about connecting HC-05 to Arduino-Micro and controlling it via Macbook (or PC). I tried How to: Setup a bluetooth connection between Arduino and a PC/Mac | ./notes but the LED doesn't turn on/off.

Just connect your Micro to your computer with a USB cable and upload that sketch to it.

Note that it's not necessary to use software serial for the HC-05 on the Micro. The Micro has an unused serial port on pins 0 and 1, Serial1, you can use for that purpose. Hardware serial is superior to software serial. So you might consider eventually modifying the code to use Serial1 instead of creating that mySerial SoftwareSerial object.

Also be sure to note this part of the SofwareSerial library's documentation:

  • Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

You are trying to use pin 2 for RX, and that's not going to work.

1 Like