User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Is bluetooth on rpi3 compatible with BLE hm10 modules?

Mon May 14, 2018 11:31 pm

I currently have anhm10 module world to gpio pins on a rpi2. I use it to send serial port commands to an hm10-based BLE relay board.

I'm wondering if I could use the rpi3 on board bluetooth to send serial commands like that to the BLE hm10 relay board?

W. H. Heydt
Posts: 10878
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 12:48 am

That's what standards are for. If everything adheres to the BLE standards, it will work. If either one doesn't, it may not. (Some companies are...notorious...for not adhering to standards.)

The easiest way to find out is to get a Pi3B+ and try it. You'll only be out the cost of the Pi (and possibly a PSU) and you'll have another Pi to do projects with whether it works or not.

ericcooper
Posts: 125
Joined: Sat Apr 08, 2017 6:23 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 1:15 am

The BLE part of the protocol will almost certainly not be a problem. The challenge will be to inter-operate with the HM10's proprietary "serial port over BLE" firmware. But even that looks possible: see the description midway down this page: http://blog.blecentral.com/2015/05/05/hm-10-peripheral/

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 11:52 am

I've done some simple communication between my Pi and an HM-10.. Not too hard.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 3:24 pm

well I ran

Code: Select all

sudo bluetoothctl
then I did

Code: Select all

agent on 
default-agent [not sure what these are for]
finally

Code: Select all

scan on
got my mac and did

Code: Select all

pair mac
and it automatically connected my rpi3 to the ble-hm10-relay board which is great, but I have no idea how to interface with it now.

I know the commands I need to send the relay board but I dont know how to do it serially now that im on a gui rpi interface.

ericcooper, i saw the post, ive used that post as reference but for arduino. But how do i send commands to an hm10 module from the rpi3?

Douglas6, great, could you point me in the right direction. The relay board takes simple commands to activate each relay, how do I send them from the rpi3 to the hm10 module?

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 3:42 pm

The HM-10 is a BLE device (as you know), and I'm not aware of any Linux utilities that would create a virtual serial device out of it, like rfcomm does for classic Bluetooth modules. So I used Python and the Bluepy library. There's some sample code for writing to a characteristic and reading notifications here: viewtopic.php?f=28&t=193923&p=1232385

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 4:23 pm

Thanks Douglas, although what Im doing is not really writing to the ble characteristic. I currentlhy use python to simply send commands over the uart:

Code: Select all

ser = serial.Serial(
		port='/dev/serial0',
		baudrate=9600,
		parity=serial.PARITY_NONE,
		stopbits=serial.STOPBITS_ONE,
		bytesize=serial.EIGHTBITS,
		timeout=1
	)
	
	ser.write("[")
and that's it!

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 4:28 pm

I'm not sure I understand. I thought you wanted to use the Pi's onboard Bluetooth to write to a remote HM-10.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 4:33 pm

I just really need a wireless medium for the data between the pi and the relay board. At present I am writing data in this fashion. Im using serial over bluetooth.

But I need to switch from my rpi2, to which i hardwired a hm10 module in order to communicate with the relay-board's-hm10 module...and replace it with an rpi3 with bluetooth on board.

So now i need to communicate between rpi3's-bluetooth and the relay-board's-hm10 module.

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 4:49 pm

OK. So, while removing the HM-10, you are also removing a lot of hardware and firmware that makes an HM-10 look to the Pi like a serial communications device. Removing the HM-10 means you'll need to forget about using serial communications. The HM-10 simulates serial communication by writing data to a characteristic, and reading data from notifications. That's what you will now need to do.

If you're dead-set on using serial, connect another HM-10 to the Pi's UART.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 6:07 pm

Well actually I did it that way because i didnt have bt onboard the rpi2 and so i guess the quickest example i found was using bt over serial. So youre right, now that I have onboard ble, I guess I could use it directly to write to the characteristic.

Any good articles or post to point me to?

Thanks!

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 6:17 pm

Well, that working code I linked to above should help. Otherwise, just search for tutorials on BLE and Bluepy.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 6:33 pm

Thanks, Im working around installing bluepy cause so far i get this error:

SHORT VERSION
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-uKLCqE/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-NZut7Q-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-uKLCqE/bluepy/

LONG VERSION
[email protected]:~ $ sudo pip install bluepy
Collecting bluepy
Using cached https://files.pythonhosted.org/packages ... 1.4.tar.gz
Building wheels for collected packages: bluepy
Running setup.py bdist_wheel for bluepy ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-uKLCqE/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpE3oNlcpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
Working dir is /tmp/pip-build-uKLCqE/bluepy
execute make -C ./bluepy clean
execute make -C bluepy -j1
Failed to compile bluepy-helper. Exiting install.
Command was 'make -C bluepy -j1' in /tmp/pip-build-uKLCqE/bluepy
Return code was 2
Output was:
make: Entering directory '/tmp/pip-build-uKLCqE/bluepy/bluepy'
tar xzf bluez-src.tgz
touch ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
gcc -L. -Os -g -Wall -DHAVE_CONFIG_H -I./bluez-5.29/attrib -I./bluez-5.29 -I./bluez-5.29/lib -I./bluez-5.29/src -I./bluez-5.29/gdbus -I./bluez-5.29/btio -o bluepy-helper bluepy-helper.c ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c
bluepy-helper.c:33:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/att.c:33:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/gatt.c:32:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/gattrib.c:34:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/utils.c:30:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/btio/btio.c:37:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/log.c:32:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/shared/io-glib.c:30:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/shared/timeout-glib.c:22:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
Makefile:28: recipe for target 'bluepy-helper' failed
make: *** [bluepy-helper] Error 1
make: Leaving directory '/tmp/pip-build-uKLCqE/bluepy/bluepy'


----------------------------------------
Failed building wheel for bluepy
Running setup.py clean for bluepy
Failed to build bluepy
Installing collected packages: bluepy
Running setup.py install for bluepy ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-uKLCqE/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-NZut7Q-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
Working dir is /tmp/pip-build-uKLCqE/bluepy
execute make -C ./bluepy clean
execute make -C bluepy -j1
Failed to compile bluepy-helper. Exiting install.
Command was 'make -C bluepy -j1' in /tmp/pip-build-uKLCqE/bluepy
Return code was 2
Output was:
make: Entering directory '/tmp/pip-build-uKLCqE/bluepy/bluepy'
tar xzf bluez-src.tgz
touch ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
gcc -L. -Os -g -Wall -DHAVE_CONFIG_H -I./bluez-5.29/attrib -I./bluez-5.29 -I./bluez-5.29/lib -I./bluez-5.29/src -I./bluez-5.29/gdbus -I./bluez-5.29/btio -o bluepy-helper bluepy-helper.c ./bluez-5.29/lib/bluetooth.c ./bluez-5.29/lib/hci.c ./bluez-5.29/lib/sdp.c ./bluez-5.29/lib/uuid.c ./bluez-5.29/attrib/att.c ./bluez-5.29/attrib/gatt.c ./bluez-5.29/attrib/gattrib.c ./bluez-5.29/attrib/utils.c ./bluez-5.29/btio/btio.c ./bluez-5.29/src/log.c ./bluez-5.29/src/shared/mgmt.c ./bluez-5.29/src/shared/crypto.c ./bluez-5.29/src/shared/att.c ./bluez-5.29/src/shared/queue.c ./bluez-5.29/src/shared/util.c ./bluez-5.29/src/shared/io-glib.c ./bluez-5.29/src/shared/timeout-glib.c
bluepy-helper.c:33:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/att.c:33:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/gatt.c:32:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/gattrib.c:34:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/attrib/utils.c:30:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/btio/btio.c:37:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/log.c:32:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/shared/io-glib.c:30:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
./bluez-5.29/src/shared/timeout-glib.c:22:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
Makefile:28: recipe for target 'bluepy-helper' failed
make: *** [bluepy-helper] Error 1
make: Leaving directory '/tmp/pip-build-uKLCqE/bluepy/bluepy'


----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-uKLCqE/bluepy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-NZut7Q-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-uKLCqE/bluepy/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[email protected]:~ $

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 6:50 pm

Try running this first:

Code: Select all

sudo apt-get install build-essential libglib2.0-dev libdbus-1-dev

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 9:07 pm

Thanks, is this the line that told you I had to install that:
No package 'glib-2.0' found

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 9:11 pm

Yup. And a couple of minutes of Google search for the others. build-essential you may already have.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 9:52 pm

Thanks, so this is what ive done so far:

1. Ive installed bluepy
2. ran sudo bluetoothctl in order to scan on and connect MAC of the ble-relay board
3. Ran the python code but it just hangs:

Code: Select all

import bluepy.btle as btle

p = btle.Peripheral("00:0E:0B:0F:0F:B9")
s = p.getServiceByUUID("0000ffe0-0000-1000-8000-00805f9b34fb")
c = s.getCharacteristics()[0]

c.write(bytes("e\n", "utf-8"))
p.disconnect()
and i have to hit Ctrl X and get this (I actually put out the entire terminal from the time I connected to the ble-relay board:
[bluetooth]# connect 00:0E:0B:0F:0F:B9
Attempting to connect to 00:0E:0B:0F:0F:B9
[CHG] Device 00:0E:0B:0F:0F:B9 Connected: yes
Connection successful
[CHG] Device 00:0E:0B:0F:0F:B9 UUIDs:
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
0000ffe0-0000-1000-8000-00805f9b34fb
[CHG] Device 42:6A:9F:B6:72:CD RSSI: -46
[bluetooth]#
[1]+ Stopped sudo bluetoothctl
[email protected]:~ $ sudo nano rfcomm.py
[email protected]:~ $ python rfcomm.py
^X
^CTraceback (most recent call last):
File "rfcomm.py", line 3, in <module>
p = btle.Peripheral("00:0E:0B:0F:0F:B9")
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 353, in __init__
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 398, in _connect
rsp = self._getResp('stat')
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 369, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 312, in _waitResp
rv = self._helper.stdout.readline()
KeyboardInterrupt
Exception IOError: (32, 'Broken pipe') in <bound method Peripheral.__del__ of <bluepy.btle.Peripheral instance at 0x76a08760>> ignored
so does this mean it just waited for a response and didnt get one?

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:05 pm

Try it without connecting in bluetoothctl (do nothing in bluetoothctl.) It"s not necessary, and may be interfering. You might want to reboot first to clean things up.
Last edited by Douglas6 on Tue May 15, 2018 10:13 pm, edited 1 time in total.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:13 pm

Good point...Ok i just rebooted and ran the script again:

python rfcomm.py

but it just hangs again.

I decided to connect to the ble-relayboard from my phone using BLE Scanner app and it displays the 0xFFE0 as custom primary service, when i select it, i get the screen where i can Read, Notify, Write ... to FFE1, and if I write a value Text utf8 string value of e I get the relay on and 0 gives me relay off. So it works fine from my phone.

I just need it to work from the python script. Could it have something to do with my config? ive been messing with it because of my original GPIO setup objective to use the hm10 serially as I had with my rpi2.

These are the lines I added to config.txt:
#Added by me to enable touch
dtoverlay=ads7846,penirq=25,speed=10000,penirq_pull=2,xohms=150
#added by me to talk to hm10 via uart serial
enable_uart=1
and I uncommented these 2 here (also for the touch screen):
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
This is the line in my cmdline.txt:
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=25a6b5eb-02 rootfstype=ext4 elevator=deadline fsck.rep$
Also, I never understood what is meant by "console login"

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:23 pm

Make sure the phone is not connected while testing on the Pi. It appears to be hanging (or was) on the

Code: Select all

p = btle.Peripheral("00:0E:0B:0F:0F:B9")
line, which is odd that it doesn't report an error. I'm not sure why it would do that. That code was written for Python3, that could be a difference, tho I doubt it. I don't know what to say. Double check your Bluetooth device address. Reboot the relay board. Give it plenty of time to connect.

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:32 pm

Also, I don't have that enable_uart=1 flag. Never needed it and I'm not entirely sure what it does. Try without it.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:48 pm

1. UART Flag

Removed it, rebooted, still the same result.

2. I used to think the script hung forever so I ended up hitting ctrl x or z or something like that. I decided to let the script finish its thing and I got a new result, no keyboard interruption, same py script:
[email protected]:~ $ python rfcomm.py
Traceback (most recent call last):
File "rfcomm.py", line 3, in <module>
p = btle.Peripheral("00:0E:0B:0F:0F:B9")
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 353, in __init__
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 402, in _connect
"Failed to connect to peripheral %s, addr type: %s" % (addr, addrType))
bluepy.btle.BTLEException: Failed to connect to peripheral 00:0E:0B:0F:0F:B9, addr type: public

3. EDR vs BLE

As for the MAC address, the device address is taken from the bluetoothctl scan.

oh ok, i just noticed there are 2 similar devices:

[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:7D:77:30 Discovering: yes
[NEW] Device 00:0E:0B:0F:0F:B9 BT Bee-BLE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
[NEW] Device 42:6A:9F:B6:72:CD 42-6A-9F-B6-72-CD
[NEW] Device 00:0E:0E:0F:0F:B9 BT Bee-EDR <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

but the BLE is the one that works when i connect to it from bluetooth ctl using connect MAC from the python script.
the other EDR doesnt connect from the bluetooth ctl using connect MAC and gives the same result when replaced in the python script.

User avatar
Douglas6
Posts: 4759
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 10:55 pm

Try this. Replace the current line with:

Code: Select all

p = btle.Peripheral("00:0E:0B:0F:0F:B9", "random") 
Since the board appears to be BLE /classic, we may have to try the classic side if we can't figure this out.

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 11:06 pm

I also just tried l2ping 00:0E:0B:0F:0F:B9 but I get host is down...


oh! with that random bit you added I get this:
[email protected]:~ $ python rfcomm.py
Traceback (most recent call last):
File "rfcomm.py", line 7, in <module>
c.write(bytes("e\n", "utf-8"))
TypeError: str() takes at most 1 argument (2 given)

User avatar
marciokoko
Posts: 291
Joined: Sat Aug 27, 2016 4:33 pm

Re: Is bluetooth on rpi3 compatible with BLE hm10 modules?

Tue May 15, 2018 11:12 pm

I went ahead and tried this:

Code: Select all

import bluepy.btle as btle

p = btle.Peripheral("00:0E:0B:0F:0F:B9", "random")
s = p.getServiceByUUID("0000ffe0-0000-1000-8000-00805f9b34fb")
c = s.getCharacteristics()[0]

c.write("e\n", "utf-8") 
p.disconnect()

and the relay doesnt turn on, the bluetooth-conneced-LED on the relay-board blinks as always (when I connect to the relay-board from bluetoothctl or the phone that LED stays lit until I disconnect from it), but something else happens this time, there is a blue LED on the relay-board labeled COM which now starts blinking as well.

I rebooted the relay-board and ran the same file above and the second COM LED starts blinking again.

Return to “Beginners”