ESP32 BLE support
ESP32 BLE support
Hi All,
This is my first ever post in this forum. Thanks to all for the work to have python available on the ESP32.
I have a BLE uart implemented on the SparkFun Thing using the Arduino environment but am struggling to get the same working with python. At this stage all I am doing is echoing chars set from putty on a win10 laptop to the ESP32. This means that my PC end and the ESP32 hw are all good.
I have seen some older comments saying that BLE is not supported on ESP32 python.... but then some discussions that seem to say the opposite.
Could someone please confirm that BLE is available on the ESP32 micro python build?
and... is there an example script that someone could point me to? I see many for the Arduino environment but not for the microPython env.
Thanks very much.
Regards
This is my first ever post in this forum. Thanks to all for the work to have python available on the ESP32.
I have a BLE uart implemented on the SparkFun Thing using the Arduino environment but am struggling to get the same working with python. At this stage all I am doing is echoing chars set from putty on a win10 laptop to the ESP32. This means that my PC end and the ESP32 hw are all good.
I have seen some older comments saying that BLE is not supported on ESP32 python.... but then some discussions that seem to say the opposite.
Could someone please confirm that BLE is available on the ESP32 micro python build?
and... is there an example script that someone could point me to? I see many for the Arduino environment but not for the microPython env.
Thanks very much.
Regards
Re: ESP32 BLE support
If you're not already aware of http://docs.micropython.org/en/latest/r ... rd.py.html then that's a very handy tool for getting started with copying files etc. Also worth checking out rshell.gregd99 wrote: ↑Mon Feb 22, 2021 1:34 amI have a BLE uart implemented on the SparkFun Thing using the Arduino environment but am struggling to get the same working with python. At this stage all I am doing is echoing chars set from putty on a win10 laptop to the ESP32. This means that my PC end and the ESP32 hw are all good.
Yes, it's been supported for a little while now, although I recommend using the v1.14 release. Please see https://docs.micropython.org/en/latest/ ... tooth.html
The ESP32 support is not _quite_ as full-featured as other ports (it's missing pairing & bonding and l2cap channels) but it supports scanning, advertising, central and peripheral, as well as gatt client and server.
Examples here: https://github.com/micropython/micropyt ... /bluetooth
The BLE API is extremely low-level, and not particularly friendly -- I designed it to be the minimum thing to make the required functionality available. I've been working on a high-level wrapper based on asyncio for it. See https://github.com/jimmo/micropython-li ... ble/aioble
Re: ESP32 BLE support
Thanks very much. I have progress!
The ble advertise script works... at least runs to completion.
When trying to run the uart script I get the error above. The offending line is
In a normal python world, I would look to install the module ble_uart_peripheral. In the microPython world, is that possible? or all libraries are included in the fw downloaded to the ESP, and nothign can be added/removed outside of a rebuild?
Thanks very much for any assistance.
Code: Select all
MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
Type "help()" for more information.
>>> %Run -c $EDITOR_CONTENT
bytearray(b'\x02\x01\x06\x0c\tmicropython\x03\x03\x1a\x18\x11\x07\x9e\xca\xdc$\x0e\xe5\xa9\xe0\x93\xf3\xa3\xb5\x01\x00@n')
micropython
[UUID(0x181a), UUID('6e400001-b5a3-f393-e0a9-e50e24dcca9e')]
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 12, in <module>
ImportError: no module named 'ble_uart_peripheral'
>>>
When trying to run the uart script I get the error above. The offending line is
Code: Select all
from ble_uart_peripheral import BLEUART
Thanks very much for any assistance.
Re: ESP32 BLE support
OK.... that is a little embarrassing...
I just needed to copy the other files to the uc. I am not quite used to an embedded controller having a file system!
Is the idea that I should just run the uart_reply script? This runs and does not return (tick).
I am assuming that it rx'es a char from a remote device and echos it, while printing info on the console.
From my pc I can pair with the device (mpy_uart), but this does not create a COM port.
In the Arduino environment, I did not pair but created an explicit outgoing Bluetooth COM port. Should the procedure be the same? When I try it, I do not see the ESP in the COM port create dialogue.
Is there a blog, or a few instructions on how to establish the connection?
Thanks very much.
I just needed to copy the other files to the uc. I am not quite used to an embedded controller having a file system!
Is the idea that I should just run the uart_reply script? This runs and does not return (tick).
I am assuming that it rx'es a char from a remote device and echos it, while printing info on the console.
From my pc I can pair with the device (mpy_uart), but this does not create a COM port.
In the Arduino environment, I did not pair but created an explicit outgoing Bluetooth COM port. Should the procedure be the same? When I try it, I do not see the ESP in the COM port create dialogue.
Is there a blog, or a few instructions on how to establish the connection?
Thanks very much.
Re: ESP32 BLE support
If you haven't seen it, take a look at pyboard.py or rshell for working with files.
Do you know if the Arduino example was doing Bluetooth Classic (RFCOMM) or BLE Nordic Uart Service. The MicroPython example is the latter, which I don't know if Windows supports turning into a COM port.
Re: ESP32 BLE support
Thanks very much for your help.
...and google tells me that the Nordic Uart Service is not supported by win10. It happens that I received a bag of Nordic bluetooth dongles today, but I was hoping not to need them for this purpose.
Do you know if the RFCOMM protocol is supported in uPython at all?
Thanks
"This example creates a bridge between Serial and Classical Bluetooth (SPP)"Do you know if the Arduino example was doing Bluetooth Classic (RFCOMM) or BLE Nordic Uart Service.
...and google tells me that the Nordic Uart Service is not supported by win10. It happens that I received a bag of Nordic bluetooth dongles today, but I was hoping not to need them for this purpose.
Do you know if the RFCOMM protocol is supported in uPython at all?
Thanks
Re: ESP32 BLE support
I'm trying to setup a BLE_REPL on ESP32 board and get the same error when running the REPL over BLE UART example. What am I missing and where do I find it? Much appreciated....thank you.gregd99 wrote: ↑Mon Feb 22, 2021 10:37 amThanks very much. I have progress!
The ble advertise script works... at least runs to completion.Code: Select all
MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32 Type "help()" for more information. >>> %Run -c $EDITOR_CONTENT bytearray(b'\x02\x01\x06\x0c\tmicropython\x03\x03\x1a\x18\x11\x07\x9e\xca\xdc$\x0e\xe5\xa9\xe0\x93\xf3\xa3\xb5\x01\x00@n') micropython [UUID(0x181a), UUID('6e400001-b5a3-f393-e0a9-e50e24dcca9e')] >>> %Run -c $EDITOR_CONTENT Traceback (most recent call last): File "<stdin>", line 12, in <module> ImportError: no module named 'ble_uart_peripheral' >>>
When trying to run the uart script I get the error above. The offending line isIn a normal python world, I would look to install the module ble_uart_peripheral. In the microPython world, is that possible? or all libraries are included in the fw downloaded to the ESP, and nothign can be added/removed outside of a rebuild?Code: Select all
from ble_uart_peripheral import BLEUART
Thanks very much for any assistance.
Re: ESP32 BLE support
You need to copy ble_uart_peripheral.py (and ble_advertising.py) to the board. Here are two good starting points for accessing the filesystem on the device:
http://docs.micropython.org/en/latest/r ... rd.py.html
https://github.com/dhylands/rshell
Re: ESP32 BLE support
Thank you, I will try this.jimmo wrote: ↑Thu Feb 25, 2021 12:05 amYou need to copy ble_uart_peripheral.py (and ble_advertising.py) to the board. Here are two good starting points for accessing the filesystem on the device:
http://docs.micropython.org/en/latest/r ... rd.py.html
https://github.com/dhylands/rshell