As promised, here is a procedure to run BrewPi over a Bluetooth link to the Arduino UNO R3. I've had this running for a few days without a single hiccup, even have had two instances running (and sharing the host-side Bluetooth/USB dongle) without any issues. btw, I don't know how many BT/Serial links the host BT/USB dongle (et al) can support, but for sure it can handle at least two.
I have parked an archive on my Google Drive here. It contains instructions, a sketch file, wiring diagrams and a copy of the latest BrewPi hex file for the UNO.
So...What follows is taken directly from the contents of brewpi_over_bluetooth.txt.
Hopefully it's lucid enough for others to follow, but as always, let me know if there's something that could use revising.
Finally, I cannot stress enough the importance of obtaining the correct HC-05 module. There's a myriad of variations of similar modules out there, but they sport different pin counts and connections at the header, and different operating firmware. It took me three tries to get a "good" one. First test: if it doesn't have a pin labeled "Key", give it a miss. If you want a sure bet, use the link provided.
The Bluetooth/USB dongle is recommended as it's pretty much the latest/greatest, but other dongles may work fine. The BT/Serial modules had no problem talking to computers in the house using different dongles, fwiw, so that end may be significantly less critical.
Cheers!
----------------------------------------------------------------------------------
BrewPi Over Bluetooth Setup
14dec2014
Forward:
This procedure will enable communication between a BrewPi host and an Arduino UNO R3 over Bluetooth.
It uses a BT/USB dongle in master mode on the host side and a BT/Serial module in slave mode on the UNO side.
NOTE: To free the UNO hardware serial port pins for use by the BT/Serial module instead of the UNO USB-serial bridge, the UNO USB port cannot be plugged.
This requires the UNO to be powered by its power receptacle using a 7V to 12V DC power supply.
This procedure assumes the user has BrewPi already running successfully under Raspbian on a RaspberryPi using an Arduino UNO R3 and wants to change the connection between the BrewPi host and the UNO from USB to Bluetooth.
While most of the instructions will still apply, using a different BrewPi host setup is outside the scope of this procedure.
Stuff needed:
Recommended BT/USB dongle: CSR 4.0 http://www.amazon.com/gp/product/B00L08NCPQ/?tag=skimlinks_replacement-20
Recommended BT/Serial module: Innogear HC-05 http://www.amazon.com/gp/product/B00JP05S6C/?tag=skimlinks_replacement-20
(2) 1K ohm resistors (1/8W axial)
(2) 2K ohm resistors (1/8W axial)
Dupont jumpers or alternative as required
Overview:
The first steps install the necessary packages to support Bluetooth and loading code to the UNO.
Then, as the BT/Serial Module default operating baud rate is usually not what is needed to work with BrewPi, the next steps will set up the Arduino UNO to allow changing the BT/Serial module settings. This includes a wiring scheme and uploading a sketch that will allow the user to communicate with the BT/Serial module in a maintenance mode.
Once the BT/Serial module baud rate has been changed, the BT/Serial module will be removed, and the BrewPi code will be uploaded to the UNO using the BrewPi web gui.
Finally, the BT/Serial module will be wired to the UNO in the operating configuration, the system powered up, the BT/Serial module will be paired with the BT/USB dongle, the BrewPi config file will be changed to use the virtual serial port provided by its BT/USB dongle, and BrewPi will be configured to use the UNO - just as if it was still connected via USB.
====================================================================================================
Procedure:
1. Installing Bluetooth USB Dongle support on the RPi:
First, update package pointers:
$ sudo apt-get update
Clear out orphaned packages:
$ sudo apt-get autoremove
Install the Arduino IDE (if not already installed):
$ sudo apt-get install -y arduino
Install Bluetooth support and tools:
$ sudo apt-get install -y bluetooth bluez-utils blueman
This may install as many as 93 packages!
The vast majority are drivers for Bluetooth devices.
Restart the system
Plug in BT/USB dongle
..............................................................................................
For information only:
$ lsusb - lists all attached USB devices
Example:
pi@rpints ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 005: ID 2341:0043 Arduino SA UNO R3 (CDC ACM)
Bus 001 Device 006: ID 0c40:8000
Bus 001 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
$ /etc/init.d/bluetooth status command shows Bluetooth status
Output should be: Bluetooth is running
Scanning for Bluetooth devices:
$ hcitool scan command to list discovered BT devices
Example:
pi@rpints ~ $ hcitool scan
Scanning ...
30:14:09:02:06:22 HC-05
D0:37:61:51:345 DROIDX
00:02:72:328:2C OBELISK
..............................................................................................
DO NOT PAIR WITH THE HC-05 YET!
2. Wire the BT/Serial Module to the UNO in programming configuration:
Wire the 6-pin BT/serial module to the UNO using resistor dividers on the BT RX and BT KEY input signals.
Refer to first image (hc05_wiring_programming.jpg)
UNO digital IO pin 9 to resistor divider then to BT/serial module KEY pin
UNO digital IO pin 10 from BT/serial module TXD pin
UNO digital IO pin 11 to resistor divider then to BT/serial module RXD pin
UNO 5V pin to BT/serial module VCC pin
UNO GND pin to BT/serial module GND pin
3. Connect UNO to host via USB and power up
BT/serial module LED should be blinking rapidly (~ half-second period)
4. Now load the programming sketch to the UNO:
Launch the Arduino IDE
File - Open to load the HC_05.ino sketch (included in the kit and listed below):
*************************************************************************************************************
*************************************************************************************************************
File - Upload to compile the sketch and upload to the UNO
Tools - Serial Monitor to launch the Arduino terminal session
The Serial Monitor should be set to 9600 baud, 1 stop bit, no parity bit, no flow control
The BT/Serial Module LED should be blinking slowly
Note: Dialogue commands and responses are framed with single quotes for clarity.
Do not use quotes in commands.
5. Change the HC-05 operating baud rate:
Check to see if HC-05 is alive:
Type: 'AT' and click the Send button
Response should be 'OK'
Check the operating baud rate:
Type: 'AT+UART?'
Response could be '+UART:9600,0,0' followed by 'OK'
Change the operating baud rate to 57600 1 stop no parity:
Type: 'AT+UART=57600,0,0' and click Send.
Response should be 'OK'
You can check to see if the command "took":
Type: 'AT+UART?'
Response should be '+UART:57600,0,0' followed by 'OK'
6. Reload the BrewPi hex file to the UNO:
Note: (see the edit3 postscript at bottom of this post - you may not have to revert to the USB connection to reprogram the Uno with the BrewPi hex file)
Remove power from UNO and BT/Serial module
Disconnect BT/Serial module
Connect UNO to BrewPi host via USB and power up.
Load BrewPi web gui and connect to instance
Start the script using the gui.
Use BrewPi Maintenance Panel - Reprogram Arduino to upload BrewPi AVR hex file.
A copy of the latest BrewPi AVR hex file (brewpi-UNO-revC.hex) is included with this kit.
NOTE: I've had varied success with restoring the BrewPi "old settings and devices" to the UNO so I usually don't bother and just set both to "No".
This will wipe the serial eeprom requiring re-entering the settings.
Stop the script using the gui.
Power off the UNO and disconnect from host
7. Wire the BT/Serial module in operating configuration:
Remove USB cable from UNO.
Connect BT/Serial module to UNO.
Refer to second image (hc05_wiring_operating.jpg)
UNO digital IO pin 0 ("RX") from BT/serial module TXD pin
UNO digital IO pin 1 ("TX") to resistor divider then to BT/serial module RXD pin
UNO 5V pin to BT/serial module VCC pin
UNO GND pin to BT/serial module GND pin
NOTE: Do not connect BT/serial module KEY pin to anything
8. Power up in operating configuration:
Connect UNO to power. You must use the UNO power receptacle with a 7V to 12V supply!
The BT/Serial Module LED should be blinking rapidly
You can use hcitool on the RPi to scan for BT devices
pi@rpints ~ $ hcitool scan
Scanning ...
30:14:09:02:06:22 HC-05
9. Pairing the BT/Serial module to the BT/USB dongle:
On the LXDE Desktop: launch Menu>Preferences>Bluetooth Manager (make a desktop shortcut while you're in the menu)
In Bluetooth Manager GUI:
Click Search: Find available BT devices
HC-05 will appear (listed as Unknown with its device address)
Select HC-05 (click once on the item)
Click the green Plus icon to add HC-05 to the Known Devices list
Click the Key icon to pair with HC-05
- pairing code is 1234
The HC-05 device should now have a Key (paired) and Star (trusted) icon
The BT/Serial module LED should now be blinking slowly (~once per two seconds)
Click Setup to view the local serial port associated with the HC-05 connnection - it should be /dev/rfcomm0
The BT/Serial module LED should now be double-blinking slowly (~two blinks per two seconds)
10. To get BrewPi to use the /dev/rfcomm0 port:
Edit the BrewPi config.cfg file for this instance.
This will be somewhere under the /home/brewpi folder.
If this is the only BrewPi AVR instance, the path most likely will be: /home/brewpi/config.cfg
Change the 'port' entry to use /dev/rfcomm0:
$ sudo nano /home/brewpi/settings/config.cfg
scriptPath = /home/brewpi/
wwwPath = /var/www/
port = /dev/rfcomm0
altport = /dev/null
boardType = UNO
Save (ctrl-o) and Exit (ctrl-x)
In this example this Uno is the second BrewPi in a multi-instance system, using the paths shown:
$ sudo nano /home/brewpi/brewpi2/settings/config.cfg
scriptPath = /home/brewpi/brewpi2/
wwwPath = /var/www/brewpi2/
port = /dev/rfcomm0
altport = /dev/null
boardType = UNO
Save (ctrl-o) and Exit (ctrl-x)
11. Finally, in a web browser, load the BrewPi web gui on the host for this instance.
Start the BrewPi script
Launch the Maintenance panel and check the log window.
- Should see script starting on device connected to /dev/rfcomm0
Configure Devices and Settings and you should be good to go!
Notes:
If the BrewPi web gui is unable to communicate with the UNO you will see messages in the log file.
At least one of those messages will list the device that BrewPi is trying to use.
Make sure it is trying to use /dev/rfcomm0 (note that's a ZERO)
If it's looking in the right place, check the wiring.
If it's not looking in the right place, go back and check the config.cfg file.
Cheers!
/dave t. aka day_trippr on homebrewtalk.com
[edit1] Corrected the voltage dividers in the two graphics
[edit2] Fixed an error in the programming graphic, added picture of Uno with the BT/serial module (note I ran out of 2K resistors so I used all 1K)
[edit3] fwiw, curiosity got the better of me so I tried reprogramming one of the BT Unos with the BrewPi revC hex file over the Bluetooth link.
And it totally worked - restored all the settings and automagically restarted the running script perfectly.
While a short USB connection is undoubtedly the most robust, if you want to try programming the Uno via BT, give it a try. Basically skip over step 6, execute steps 7 to 11, then once you get the BrewPi web gui up, use it to reprogram the Uno.
I have parked an archive on my Google Drive here. It contains instructions, a sketch file, wiring diagrams and a copy of the latest BrewPi hex file for the UNO.
So...What follows is taken directly from the contents of brewpi_over_bluetooth.txt.
Hopefully it's lucid enough for others to follow, but as always, let me know if there's something that could use revising.
Finally, I cannot stress enough the importance of obtaining the correct HC-05 module. There's a myriad of variations of similar modules out there, but they sport different pin counts and connections at the header, and different operating firmware. It took me three tries to get a "good" one. First test: if it doesn't have a pin labeled "Key", give it a miss. If you want a sure bet, use the link provided.
The Bluetooth/USB dongle is recommended as it's pretty much the latest/greatest, but other dongles may work fine. The BT/Serial modules had no problem talking to computers in the house using different dongles, fwiw, so that end may be significantly less critical.
Cheers!
----------------------------------------------------------------------------------
BrewPi Over Bluetooth Setup
14dec2014
Forward:
This procedure will enable communication between a BrewPi host and an Arduino UNO R3 over Bluetooth.
It uses a BT/USB dongle in master mode on the host side and a BT/Serial module in slave mode on the UNO side.
NOTE: To free the UNO hardware serial port pins for use by the BT/Serial module instead of the UNO USB-serial bridge, the UNO USB port cannot be plugged.
This requires the UNO to be powered by its power receptacle using a 7V to 12V DC power supply.
This procedure assumes the user has BrewPi already running successfully under Raspbian on a RaspberryPi using an Arduino UNO R3 and wants to change the connection between the BrewPi host and the UNO from USB to Bluetooth.
While most of the instructions will still apply, using a different BrewPi host setup is outside the scope of this procedure.
Stuff needed:
Recommended BT/USB dongle: CSR 4.0 http://www.amazon.com/gp/product/B00L08NCPQ/?tag=skimlinks_replacement-20
Recommended BT/Serial module: Innogear HC-05 http://www.amazon.com/gp/product/B00JP05S6C/?tag=skimlinks_replacement-20
(2) 1K ohm resistors (1/8W axial)
(2) 2K ohm resistors (1/8W axial)
Dupont jumpers or alternative as required
Overview:
The first steps install the necessary packages to support Bluetooth and loading code to the UNO.
Then, as the BT/Serial Module default operating baud rate is usually not what is needed to work with BrewPi, the next steps will set up the Arduino UNO to allow changing the BT/Serial module settings. This includes a wiring scheme and uploading a sketch that will allow the user to communicate with the BT/Serial module in a maintenance mode.
Once the BT/Serial module baud rate has been changed, the BT/Serial module will be removed, and the BrewPi code will be uploaded to the UNO using the BrewPi web gui.
Finally, the BT/Serial module will be wired to the UNO in the operating configuration, the system powered up, the BT/Serial module will be paired with the BT/USB dongle, the BrewPi config file will be changed to use the virtual serial port provided by its BT/USB dongle, and BrewPi will be configured to use the UNO - just as if it was still connected via USB.
====================================================================================================
Procedure:
1. Installing Bluetooth USB Dongle support on the RPi:
First, update package pointers:
$ sudo apt-get update
Clear out orphaned packages:
$ sudo apt-get autoremove
Install the Arduino IDE (if not already installed):
$ sudo apt-get install -y arduino
Install Bluetooth support and tools:
$ sudo apt-get install -y bluetooth bluez-utils blueman
This may install as many as 93 packages!
The vast majority are drivers for Bluetooth devices.
Restart the system
Plug in BT/USB dongle
..............................................................................................
For information only:
$ lsusb - lists all attached USB devices
Example:
pi@rpints ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 005: ID 2341:0043 Arduino SA UNO R3 (CDC ACM)
Bus 001 Device 006: ID 0c40:8000
Bus 001 Device 007: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
$ /etc/init.d/bluetooth status command shows Bluetooth status
Output should be: Bluetooth is running
Scanning for Bluetooth devices:
$ hcitool scan command to list discovered BT devices
Example:
pi@rpints ~ $ hcitool scan
Scanning ...
30:14:09:02:06:22 HC-05
D0:37:61:51:345 DROIDX
00:02:72:328:2C OBELISK
..............................................................................................
DO NOT PAIR WITH THE HC-05 YET!
2. Wire the BT/Serial Module to the UNO in programming configuration:
Wire the 6-pin BT/serial module to the UNO using resistor dividers on the BT RX and BT KEY input signals.
Refer to first image (hc05_wiring_programming.jpg)
UNO digital IO pin 9 to resistor divider then to BT/serial module KEY pin
UNO digital IO pin 10 from BT/serial module TXD pin
UNO digital IO pin 11 to resistor divider then to BT/serial module RXD pin
UNO 5V pin to BT/serial module VCC pin
UNO GND pin to BT/serial module GND pin
3. Connect UNO to host via USB and power up
BT/serial module LED should be blinking rapidly (~ half-second period)
4. Now load the programming sketch to the UNO:
Launch the Arduino IDE
File - Open to load the HC_05.ino sketch (included in the kit and listed below):
*************************************************************************************************************
Code:
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
*************************************************************************************************************
File - Upload to compile the sketch and upload to the UNO
Tools - Serial Monitor to launch the Arduino terminal session
The Serial Monitor should be set to 9600 baud, 1 stop bit, no parity bit, no flow control
The BT/Serial Module LED should be blinking slowly
Note: Dialogue commands and responses are framed with single quotes for clarity.
Do not use quotes in commands.
5. Change the HC-05 operating baud rate:
Check to see if HC-05 is alive:
Type: 'AT' and click the Send button
Response should be 'OK'
Check the operating baud rate:
Type: 'AT+UART?'
Response could be '+UART:9600,0,0' followed by 'OK'
Change the operating baud rate to 57600 1 stop no parity:
Type: 'AT+UART=57600,0,0' and click Send.
Response should be 'OK'
You can check to see if the command "took":
Type: 'AT+UART?'
Response should be '+UART:57600,0,0' followed by 'OK'
6. Reload the BrewPi hex file to the UNO:
Note: (see the edit3 postscript at bottom of this post - you may not have to revert to the USB connection to reprogram the Uno with the BrewPi hex file)
Remove power from UNO and BT/Serial module
Disconnect BT/Serial module
Connect UNO to BrewPi host via USB and power up.
Load BrewPi web gui and connect to instance
Start the script using the gui.
Use BrewPi Maintenance Panel - Reprogram Arduino to upload BrewPi AVR hex file.
A copy of the latest BrewPi AVR hex file (brewpi-UNO-revC.hex) is included with this kit.
NOTE: I've had varied success with restoring the BrewPi "old settings and devices" to the UNO so I usually don't bother and just set both to "No".
This will wipe the serial eeprom requiring re-entering the settings.
Stop the script using the gui.
Power off the UNO and disconnect from host
7. Wire the BT/Serial module in operating configuration:
Remove USB cable from UNO.
Connect BT/Serial module to UNO.
Refer to second image (hc05_wiring_operating.jpg)
UNO digital IO pin 0 ("RX") from BT/serial module TXD pin
UNO digital IO pin 1 ("TX") to resistor divider then to BT/serial module RXD pin
UNO 5V pin to BT/serial module VCC pin
UNO GND pin to BT/serial module GND pin
NOTE: Do not connect BT/serial module KEY pin to anything
8. Power up in operating configuration:
Connect UNO to power. You must use the UNO power receptacle with a 7V to 12V supply!
The BT/Serial Module LED should be blinking rapidly
You can use hcitool on the RPi to scan for BT devices
pi@rpints ~ $ hcitool scan
Scanning ...
30:14:09:02:06:22 HC-05
9. Pairing the BT/Serial module to the BT/USB dongle:
On the LXDE Desktop: launch Menu>Preferences>Bluetooth Manager (make a desktop shortcut while you're in the menu)
In Bluetooth Manager GUI:
Click Search: Find available BT devices
HC-05 will appear (listed as Unknown with its device address)
Select HC-05 (click once on the item)
Click the green Plus icon to add HC-05 to the Known Devices list
Click the Key icon to pair with HC-05
- pairing code is 1234
The HC-05 device should now have a Key (paired) and Star (trusted) icon
The BT/Serial module LED should now be blinking slowly (~once per two seconds)
Click Setup to view the local serial port associated with the HC-05 connnection - it should be /dev/rfcomm0
The BT/Serial module LED should now be double-blinking slowly (~two blinks per two seconds)
10. To get BrewPi to use the /dev/rfcomm0 port:
Edit the BrewPi config.cfg file for this instance.
This will be somewhere under the /home/brewpi folder.
If this is the only BrewPi AVR instance, the path most likely will be: /home/brewpi/config.cfg
Change the 'port' entry to use /dev/rfcomm0:
$ sudo nano /home/brewpi/settings/config.cfg
scriptPath = /home/brewpi/
wwwPath = /var/www/
port = /dev/rfcomm0
altport = /dev/null
boardType = UNO
Save (ctrl-o) and Exit (ctrl-x)
In this example this Uno is the second BrewPi in a multi-instance system, using the paths shown:
$ sudo nano /home/brewpi/brewpi2/settings/config.cfg
scriptPath = /home/brewpi/brewpi2/
wwwPath = /var/www/brewpi2/
port = /dev/rfcomm0
altport = /dev/null
boardType = UNO
Save (ctrl-o) and Exit (ctrl-x)
11. Finally, in a web browser, load the BrewPi web gui on the host for this instance.
Start the BrewPi script
Launch the Maintenance panel and check the log window.
- Should see script starting on device connected to /dev/rfcomm0
Configure Devices and Settings and you should be good to go!
Notes:
If the BrewPi web gui is unable to communicate with the UNO you will see messages in the log file.
At least one of those messages will list the device that BrewPi is trying to use.
Make sure it is trying to use /dev/rfcomm0 (note that's a ZERO)
If it's looking in the right place, check the wiring.
If it's not looking in the right place, go back and check the config.cfg file.
Cheers!
/dave t. aka day_trippr on homebrewtalk.com
[edit1] Corrected the voltage dividers in the two graphics
[edit2] Fixed an error in the programming graphic, added picture of Uno with the BT/serial module (note I ran out of 2K resistors so I used all 1K)
[edit3] fwiw, curiosity got the better of me so I tried reprogramming one of the BT Unos with the BrewPi revC hex file over the Bluetooth link.
And it totally worked - restored all the settings and automagically restarted the running script perfectly.
While a short USB connection is undoubtedly the most robust, if you want to try programming the Uno via BT, give it a try. Basically skip over step 6, execute steps 7 to 11, then once you get the BrewPi web gui up, use it to reprogram the Uno.
Last edited by a moderator: