Bluetooth Scanning.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Stubbs
Posts: 3
Joined: Thu Jul 30, 2020 9:12 pm

Bluetooth Scanning.

Post by Stubbs » Fri Jul 31, 2020 9:13 am

Hi,

I'm trying to connect my ESP32 (Lolin Lite) to a bluetooth heart monitor, a Polar H7 and I'm having trouble getting the example code to scan for anything.

I'm using the ble_temperature_central.py from the version of the code tagged "1.12" on Github as suggested on another thread, I've not changed anything yet apart from adding "window" & "interval" as parameters to the "scan" method. I have "MicroPython v1.12-652-gcaaaa2b1f on 2020-07-22; ESP32 module with ESP32" loaded on the ESP32.

I am getting scan results, it's just that the event that being passed to "_irq" doesn't match any of the constants defined. Here's a few lines of debug I've added to _irq, the number on it's own is "event" and the array under that is "data". The "master" version of the examples has 5 defined as SCAN_RESULT which would make sense. I've also tried the master version of the example central & while it did detect the incoming events properly, it could never decode any of the data (the line "if payload[i + 1] == adv_type:" never matched.


Here's an example of the debug I get dumping "event" and "data" from "_irq"

Code: Select all

5
(0, b'\xbe\x89@\x00\x85\xc1', 0, -84, b'\x02\x01\x06\x03\x02\x12\x18\x0e\tELK-BLEDOM   ')
5
(1, b'm=&e\x98\xa8', 0, -39, b'\x02\x01\x06\n\xffL\x00\x10\x05A\x1cy\xa6\xe7')
5
(1, b'd\xa7U\xa3}\xbb', 0, -39, b'\x02\x01\x06\n\xffL\x00\x10\x05A\x1cy\xa6\xe7')
5
(0, b'\xbe\x89@\x00\x85\xc1', 0, -83, b'\x02\x01\x06\x03\x02\x12\x18\x0e\tELK-BLEDOM   ')
5
(1, b'm=&e\x98\xa8', 0, -39, b'\x02\x01\x06\n\xffL\x00\x10\x05A\x1cy\xa6\xe7')
5
(1, b'd\xa7U\xa3}\xbb', 0, -39, b'\x02\x01\x06\n\xffL\x00\x10\x05A\x1cy\xa6\xe7')
5
(1, b'e\x8b\xac\x0c)M', 0, -79, b'\x02\x01\x1a\x02\n\x0c\n\xffL\x00\x10\x05\x06\x18$\xee\x94')
5
(0, b'\xbe\x89@\x00\x85\xc1', 0, -86, b'\x02\x01\x06\x03\x02\x12\x18\x0e\tELK-BLEDOM   ')
5
(0, b'\xbe\x89@\x00\x85\xc1', 0, -82, b'\x02\x01\x06\x03\x02\x12\x18\x0e\tELK-BLEDOM   ')

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Bluetooth Scanning.

Post by jimmo » Thu Sep 03, 2020 6:19 am

Stubbs wrote:
Fri Jul 31, 2020 9:13 am
I'm using the ble_temperature_central.py from the version of the code tagged "1.12" on Github as suggested on another thread, I've not changed anything yet apart from adding "window" & "interval" as parameters to the "scan" method. I have "MicroPython v1.12-652-gcaaaa2b1f on 2020-07-22; ESP32 module with ESP32" loaded on the ESP32.
Hi,

It sounds like you have the unstable firmware (i.e. v1.13 development) but are referring to the v1.12 docs.

v1.13 was just released yesterday. So you should be able to use the up-to-date released firmware with the current docs.

Can you provide an example of how you're using the ble_advertising module to decode the payloads? I'm not quite sure what you mean by "the line "if payload[i + 1] == adv_type:" never matched". Thanks

Post Reply