Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
bluetooth-serial [2017/01/25 15:05]
arthur
bluetooth-serial [2021/02/22 16:47] (current)
Line 15: Line 15:
 You can also use a BLE (Bluetooth Low Energy) or BT4.0 device like the HC-10, but you will need a comms device that talks BLE/BT4.0 and not many computers do (a recent-model Apple Macbook Pro/Air will be able to, my recent-model HP doesn't), so by sticking to the HC-05 you can be sure of being compatible with the majority of devices.  You can also use a BLE (Bluetooth Low Energy) or BT4.0 device like the HC-10, but you will need a comms device that talks BLE/BT4.0 and not many computers do (a recent-model Apple Macbook Pro/Air will be able to, my recent-model HP doesn't), so by sticking to the HC-05 you can be sure of being compatible with the majority of devices. 
  
-[[image http://gd1.alicdn.com/bao/uploaded/i1/14767031049461097/T1RRyXXzXkXXXXXXXX_!!0-item_pic.jpg_400x400.jpg_.webp]]+{{//external/https.web.archive.org.web.20161013235353im.http.gd1.alicdn.com.bao.uploaded.i1.14767031049461097.t1rryxxzxkxxxxxxxx.0.item.pic.jpg.400x400.jpg.webp}}
  
-I prefer the CZ over the JY for a few reasons â€“ it’s really small, it’s really well made, it has the KEY (P34, state pin) already broken out and it does level shifting of all the pins back to the 3.3V required by the HC module, unlike some of the other breakouts.+I prefer the CZ over the JY for a few reasons €“ it is really small, it is really well made, it has the KEY (P34, state pin) already broken out and it does level shifting of all the pins back to the 3.3V required by the HC module, unlike some of the other breakouts.
  
 Of course, some of the US manufacturers make some great boards with superior features and wonderful quality control, but that comes at a price - personally I like paying $4 for a bluetooth module, rather than $25-30. Of course, some of the US manufacturers make some great boards with superior features and wonderful quality control, but that comes at a price - personally I like paying $4 for a bluetooth module, rather than $25-30.
Line 38: Line 38:
 GND to HC-05 GND  GND to HC-05 GND 
 5V to HC-05 VCC  5V to HC-05 VCC 
-5v to HC-05 KEY or HC-05 P34 -  adding a signal (or voltage) to this pin when you power it on puts the HC-05 in command mode, where you can program the features. Some manufacturers break P34 out on the breakout board, but leave the pin un-soldered, some wire it all up just like the CZ, some wire other pins… if they haven’t wired it, you will need to hold a signal high to P34 while you power cycle the HC-05 to get it into command mode. Once you have it in command mode, you can remove the signal â€“ it will stay in command mode until reset or power-cycle the module.+5v to HC-05 KEY or HC-05 P34 -  adding a signal (or voltage) to this pin when you power it on puts the HC-05 in command mode, where you can program the features. Some manufacturers break P34 out on the breakout board, but leave the pin un-soldered, some wire it all up just like the CZ, some wire other pins€¦ if they haven€™t wired it, you will need to hold a signal high to P34 while you power cycle the HC-05 to get it into command mode. Once you have it in command mode, you can remove the signal €“ it will stay in command mode until reset or power-cycle the module.
  
 === Arduino sketch: to program the HC-05 === Arduino sketch: to program the HC-05
  
-[[code]]+<code cpp>
  
 // SERIAL LOOP SKETCH FOR COMMUNICATING WITH A BLUETOOTH SPP MODULE // SERIAL LOOP SKETCH FOR COMMUNICATING WITH A BLUETOOTH SPP MODULE
Line 75: Line 75:
   }   }
 } }
-[[/code]]+</code>
  
 === Configure the Bluetooth Module === Configure the Bluetooth Module
Line 81: Line 81:
 Connect/power on the Arduino, load the Arduino IDE and load the sketch above. Connect/power on the Arduino, load the Arduino IDE and load the sketch above.
  
-Recycle the Arduino and the HC05 should initialise and slowly flash its LED â€“ this indicates it is in Command Mode.+Recycle the Arduino and the HC05 should initialise and slowly flash its LED €“ this indicates it is in Command Mode.
  
 Bring up the Arduino IDE serial monitor and set to 9600+CR+LF Bring up the Arduino IDE serial monitor and set to 9600+CR+LF
Line 92: Line 92:
 Connection mode: Connect to the Bluetooth device specified Connection mode: Connect to the Bluetooth device specified
 Transmission rate: 38,400 bps; Stop bit: 1 bit; Parity bit: None. Transmission rate: 38,400 bps; Stop bit: 1 bit; Parity bit: None.
-Passkey: â€œ1234” +Passkey: €œ1234€ 
-Device name: â€œH-C-2010-06-01” (or some variant depending on what is programmed in the firmware).//+Device name: €œH-C-2010-06-01€ (or some variant depending on what is programmed in the firmware).//
  
 The first thing to do is to ensure the module is set to factory defaults, using the AT+ORGL command. The first thing to do is to ensure the module is set to factory defaults, using the AT+ORGL command.
Line 102: Line 102:
 Change the device name: AT+NAME=Smoothie (or anything you like: KillR3D, MyPrinter, Arthur, KZ223398 - the module don't care. Change the device name: AT+NAME=Smoothie (or anything you like: KillR3D, MyPrinter, Arthur, KZ223398 - the module don't care.
  
-You can also change the pairing key if you want, either for easier access or for privacy â€“ my Macbook defaults to 0000, but the HC-05 defaults to 1234. To make it publicly accessible, give it a pin of 0000: AT+PSWD=0000 - to make it secure, pick any 4-digits that you will remember.+You can also change the pairing key if you want, either for easier access or for privacy €“ my Macbook defaults to 0000, but the HC-05 defaults to 1234. To make it publicly accessible, give it a pin of 0000: AT+PSWD=0000 - to make it secure, pick any 4-digits that you will remember.
  
-[[code]]+<code>
 AT+ORGL (Restore the factory default state) AT+ORGL (Restore the factory default state)
 AT+UART=115200,0,0 (Set transmission rate to 115,200 bps, one stop bit and no parity bit) AT+UART=115200,0,0 (Set transmission rate to 115,200 bps, one stop bit and no parity bit)
 AT+NAME=Smoothie AT+NAME=Smoothie
 AT+PSWD=0000 AT+PSWD=0000
-[[/code]]+</code>
  
 There are other parameters in the AT command set, but none of them are relevant to getting the HC-05 working on the SmoothieBoard. There are other parameters in the AT command set, but none of them are relevant to getting the HC-05 working on the SmoothieBoard.
  
 Connect the female DuPont cables to the 4 UART pins on the Smoothie (next to the USB connector - labelled TX RX V+ GND) and the corresponding pins on the HC-05 breakout and power up the board. Connect the female DuPont cables to the 4 UART pins on the Smoothie (next to the USB connector - labelled TX RX V+ GND) and the corresponding pins on the HC-05 breakout and power up the board.
- 
-[[image https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xap1/v/t1.0-9/10897898_10204780222321017_8021442161976629880_n.jpg?oh=e2c9870f930e48bbec533cf3cb360656&oe=5531704E&__gda__=1428364827_4c5597816c92e509af88f2ee8b5cdec4]] 
- 
-[[image https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/10906575_10204780222361018_7648431575382254051_n.jpg?oh=f3cad5b7fe6a825bdb39a70bc2b6c031&oe=55297F5F&__gda__=1428404041_9d1670126921306950467e62fab75e14]] 
- 
-[[image https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/10704043_10204780222401019_5666862332661991540_n.jpg?oh=1c0633c50841ec4f337771c8cc704da8&oe=55344D0D&__gda__=1429588840_efa18a8777557a928da6ae640ba56761]] 
  
 === Connect: === Connect:
  
-[[Pronterface]]+Reboot the SmoothieBoard and you should now be able to connect using a terminal app like CoolTerm or directly using your printer app (like [[Pronterface]]).
  
 In this configuration, the UART is set to 115,200 bps, but the HC-05 is capable of 230,400bps, 460,800bps - right up to 1,382,400, although at those rates you will probably be experiencing some significant percentage of comms errors. The BT SPP link itself is capable of upwards of 3Mb/s, given perfect radio conditions. In this configuration, the UART is set to 115,200 bps, but the HC-05 is capable of 230,400bps, 460,800bps - right up to 1,382,400, although at those rates you will probably be experiencing some significant percentage of comms errors. The BT SPP link itself is capable of upwards of 3Mb/s, given perfect radio conditions.
Line 129: Line 123:
 In my experience, going over 230400 doesn't really give you anything except the likelihood of more errors. Stick with 115,200 or 230,400 as UART speeds - this is set in the config file: In my experience, going over 230400 doesn't really give you anything except the likelihood of more errors. Stick with 115,200 or 230,400 as UART speeds - this is set in the config file:
  
-[[code]]+<code>
 # Serial communications configuration ( transmission rate default to 9600 if undefined )   # Serial communications configuration ( transmission rate default to 9600 if undefined )  
 uart0.baud_rate  115200   # Baud rate for the default hardware serial port uart0.baud_rate  115200   # Baud rate for the default hardware serial port
-[[/code]]+</code>
  
 It may be that you are able to perform the Bluetooth AT command setting using the SmoothieBoard itself, but I haven't investigated that method. If you have a spare FTDI USB-to-UART module, you can connect that directly to the Bluetooth module and program it using a terminal app. It may be that you are able to perform the Bluetooth AT command setting using the SmoothieBoard itself, but I haven't investigated that method. If you have a spare FTDI USB-to-UART module, you can connect that directly to the Bluetooth module and program it using a terminal app.