How to control arduino using mblock and bluetooth?


#1

Hi,
I want to control arudino using mblock and bluetooth shield HC-05?

Assuming that mblock can control arduino using bluetooth module, I tried few things without success. I am not sure if my bluetooh setup is problem or mBlock is not able to recognize the COM port provided by bluetooth.

I can see the COM device (in fact two??) when I pair HC-05 with PC. I have following questions based on whatever I have tried so far.

  • When I connect HC-05, should I connect Tx to Tx OR reverse them?
    • There are varying articles describing both ways of connection.
  • How much baud rate do I need to set on the bluetooth device?
  • Do I need to use the voltage divider for Rx? Again there are varying tutorials.
  • Is mblock default arduino firmware sufficient for such a setup?
  • what should be the baud rate set for mblock?

Thanks,
Manish


#2

Hi Manish,

In theory, the answer is Yes. In practice, it will take some work on your part. mBlock communicates to an Arduino using the Firmata protocol. I have not done this but I believe these are the steps you should take (generally in order):

  • Find a version of Firmata that communicates using Bluetooth. The Arduino IDE comes with an example StandardFirmataBLE. I don’t know if that works with an HC-05 shield. Also remember that you will need two GPIO pins to communicate with the HC-05. This means that you should NOT use those pins with mBlock. Your Arduino TX is connected to the RX of the HC-05. The baud rate is automatically set to 56700 by the Firmata code.
  • If you’re using Windows, pair your computer with your HC-05. This creates two COM ports, one for outgoing connections and another for incoming connections. You will want to use the outgoing COM port. If I recall correctly, you can use the Device Manager to figure out which is which. Sorry but I can’t help with Mac OS or Linux.
  • In mBlock, connect to the outgoing COM port. mBlock should now connect with your Arduino.

Good luck,
Aram


#3

Hi Aram,
Thank you for the inputs. After toying around things for some time, I could make mBlock control Arduino using Bluetooth. Following are details.

Control Aduino using mBlock with Bluetooth

  • Set the bluetooth baud rate to 115200. The mBlock firmware uses
    this baud rate for serial communication.
  • Connect Bluetooth to Rx and Tx of Arduino.
  • Upload default Arduino firmware (orion firmware) to
    Arudino using mBlock.
  • Use mBlock to interact with Arduino using Bluetooth.
    • Please note that Bluetooth cannot be used to upload
      the sketches to Arduino for offline mode.

Connecting Bluetooth COM device to PC in AT mode to set baud rate.

  • Upload empty (default) sketch to arudino using USB cable.
  • Connect 5V of BT shield to 3.3V of arduino.
  • Connect EN or BT to 5V.
  • Connect Tx to Tx and Rx to Rx.
  • Use USB cable to power on arudino.
  • Before turning the power ON, keep pressing the EN
    button on BT shield. The LED should blink with almost
    a second delay. That is the indication that it is AT mode.
  • Start Arduino IDE, and connect to the COM port of arudino
    and NOT that of the BT.
  • Start serial monitor.
  • Set the baud to 38400 and terminate character settings to
    "Both NL $ CR".
  • In the command of serial monitor type at twice. First time response
    will be error, second time it should be ok.
  • Now use the at commands to set baud rate using “at +uart=115200,0,0” e.g.
  • Use “at +uart?” to see what is the baud rate set on the device.

Connect Bluetooth device to Rx and Tx of Arduino.

Arudino <-> HC - 05
======= =======
5V Vcc
GND GND
Rx Tx
Tx Rx (Via Voltage divider)

Some of the articles talk about connecting 3.3V of Arduino to the
Vcc of HC-05 and not using the voltage divider at all. However this
combination fails as once increases the buad rate.

Check out more details about voltage divider here. https://electronics.stackexchange.com/questions/280500/why-do-you-have-to-use-a-voltage-divider-with-hc-05-bluetooth-module-arduino

What is the story of two COM devices for Bluetooth?

Thanks,
Manish


#4

Hi, msapariya
could you please give me your email address because want to ask you some questions relating bluetooth?
thanks in advance