0

Is it possible to control an Arduino using mBlock and Bluetooth?

Assuming yes, I tried various things, but was not able to come to a conclusion.

I am trying to get this combination working using a HC-05 Bluetooth module. I am not sure if my Bluetooh setup is the problem or is 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 the 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 setup?
0
  • When I connect HC-05, should I connect Tx to Tx OR reverse them?
    • There are varying articles describing both ways of connection.

Yes, swap them. TX on the HC-05 to RX on the Arduino. However you could struggle to use pins 0/1 since they are the USB connection. SoftwareSerial (which is nasty) is what most people use instead.

  • How much baud rate do I need to set on the bluetooth device?

Whatever rate you want to communicate at. It's up to you. However all baud rates must match throughout the system - the baud rate on the Arduino, the baud rate of the HC-05, the baud rate of the SPP port on your PC, etc.

  • Do I need to use the voltage divider for Rx? Again there are varying tutorials.

Which RX? Arduino TX to HC-05 RX yes. HX-05 TX to Arduino RX no.

  • Is mblock default arduino firmware sufficient for such a setup?

What is mblock?

  • thanks for the comments. mblock is the visual programmer tool which has arduino eco system integrated. mblock.cc. – Manish Sapariya Jul 7 '17 at 11:47
  • Majenko Could you please explain why using 0/1 is not good idea? I think the default firmware that I use for mblock may be expecting the serial communication to happen over 0/1 pin of arduino. – Manish Sapariya Jul 7 '17 at 12:14
  • 0/1 is used for communication with the PC and uploading new sketches. You can't do that whilst at the same time communicate with an external module such as bluetooth. – Majenko Jul 7 '17 at 12:22
0

I got it working. Following are steps.

  • 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 Arduino 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 Arduino 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 Arduino.
  • 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 Arduino 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 input field 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.

Arduino <-> 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 baud 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.