Trying to use BLE Central on a Titano

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Trying to use BLE Central on a Titano

Post by jasonthenderson »

I am trying to use BLE central on a Titano - unfortunately I cannot get my .ino to compile under Arduino IDE - it complains that it can't find sdkconfig.h which is automatically included by BLEDevice.h. It seems like maybe something is wrong with the Titano/SAMD package that is installed in terms of the ESP32 tools install?

I then did some research to see if CircuitPython was an option for the Titano, but according to this page only BLE Peripheral is supported, and Central is still under development for the Titano - https://learn.adafruit.com/adafruit-pyp ... python-ble

Error in Arduino IDE below:
ESP32_BLE_Arduino\src/BLEDevice.h:10:10: fatal error: sdkconfig.h: No such file or directory
10 | #include "sdkconfig.h"
| ^~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit PyPortal M4 Titano (SAMD51).


Help would be greatly appreciated, I have been pulling my hair out over this!

User avatar
adafruit_support_mike
 
Posts: 65032
Joined: Thu Feb 11, 2010 2:51 pm

Re: Trying to use BLE Central on a Titano

Post by adafruit_support_mike »

[moved to the CircuitPython forum]

User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Re: Trying to use BLE Central on a Titano

Post by jasonthenderson »

Any thoughts on this? Super bummed that there doesn’t seem to be any supported way to use Central BLE on Titano…was hoping to control several BLE devices via the Touchscreen.

User avatar
adafruit_support_mike
 
Posts: 65032
Joined: Thu Feb 11, 2010 2:51 pm

Re: Trying to use BLE Central on a Titano

Post by adafruit_support_mike »

The Titano uses a SAMD51 microcontroller, which doesn't have built-in BLE. You need a device like the nRF52840 which has a built-in BLE radio and enough RAM to run the central code to operate as a central device.

User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Re: Trying to use BLE Central on a Titano

Post by jasonthenderson »

Hi Mike, but shouldn’t the Esp32 on the Titano be able to do Ble?

The guide here implies that pyportal devices can do Ble… https://learn.adafruit.com/adafruit-pyp ... python-ble

User avatar
adafruit_support_mike
 
Posts: 65032
Joined: Thu Feb 11, 2010 2:51 pm

Re: Trying to use BLE Central on a Titano

Post by adafruit_support_mike »

The ESP32 is programmed as a Wifi coprocessor. It can do BLE, but you'd have to reprogram it to provide a useful interface to the SAMD51 while operating as a BLE central.

In practice, it doesn't make much sense to use a BLE central coprocessor unless you've constrained every other part of the system heavily. Otherwise you have to micro-manage almost everything.. deciding when to look for peripherals, choosing the ones to connect, determining the characteristics they use and managing data transfer, etc.

User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Re: Trying to use BLE Central on a Titano

Post by jasonthenderson »

The scenario I’m trying to enable is creating a display for a pair of 320AH lithium batteries and the solar charger. In this case the peripherals are highly constrained - Ie they are all known to me and they all broadcast Ble, and I’ve used the BLE sniffer to reverse engineer the GATT info I need for the three devices.

I think this is a generally interesting scenario for central - especially in the case of an RV where you want to create a display for your electrical system composed of known BLE capable devices (many are now Ble peripherals)

Do you have any pointers on how to switch the esp32 into the Ble mode?

User avatar
danhalbert
 
Posts: 3354
Joined: Tue Aug 08, 2017 12:37 pm

Re: Trying to use BLE Central on a Titano

Post by danhalbert »

Here is CircuitPython code to switch the AirLift ESP32 into BLE mode: https://github.com/adafruit/Adafruit_Ci ... t/esp32.py
You hold the chip-select pin a certain way while resetting the AirLift. One way is WiFI; the other way is BLE. Then the HCI BLE interface will become available.

I'm not sure if there is a viable Arduino library for doing BLE in this situation. See https://forum.arduino.cc/t/ble-arduino- ... e/893303/3 and probably some other search results about this.

An alternative to this would be not to use a Titano but instead something like a Feather nRF52840 and a large-display TFT FeatherWing, such as https://www.adafruit.com/product/3651. Sadly the TFT display FeatherWing is out of stock, though a display breakout is available: https://www.adafruit.com/product/2050

User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Re: Trying to use BLE Central on a Titano

Post by jasonthenderson »

Thanks a lot for the pointers Dan! I will see if I can get either of these paths to work.

User avatar
jasonthenderson
 
Posts: 23
Joined: Sat Jul 20, 2019 1:12 pm

Re: Trying to use BLE Central on a Titano

Post by jasonthenderson »

Actually one question - I assume if using ESP32.py I should do something like:

ESP32.reset(2,false)
ESP32.startbluetooth()
//code to run

Is that right?

User avatar
danhalbert
 
Posts: 3354
Joined: Tue Aug 08, 2017 12:37 pm

Re: Trying to use BLE Central on a Titano

Post by danhalbert »

Code: Select all

ESP32.reset(2,false)
ESP32.startbluetooth()
//code to run
You do not need to call `ESP32.reset()` yourself. `ESP32.start_bluetooth()` does that for you.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”