WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: BLE bluetooth communication between ESP32 ---> piCore  (Read 261 times)

Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
BLE bluetooth communication between ESP32 ---> piCore
« on: November 19, 2020, 11:13:47 AM »
Hey here all; hope all are good  :)

I'am an diyaudio guy, and i have been using piCore as my main musicplayer (squeezelite) - Mostly the excellent pCP dist. for the last few years.
Recently i ran into the digital room correction / digital signal processing thing, using the camilladsp engine along with squeezelite.
This is all working very great now, and so i need something for a winterproject. -So i bougth an ESP32 devkit board which is capable of both wifi and classic/BLE bluetooth. https://www.ebay.de/itm/ESP32-Dev-Board-NodeMCU-WROOM32-WiFi-WLAN-Bluetooth-Development/254138283456?epid=8029668576&hash=item3b2bd275c0:g:RKcAAOSwsq1ccpwE

My plan is to battery power the ESP32, attach an rotary encoder to it and send data via bluetooth to my RaspberryPi running piCore and let the encoder adjust volume & maybe play/pause.

I've tried different and asked around, the BLE (Bluetooth low energy) is the way to go for me. Soo...

What kind of bluetooth should i use, there seems to be so many way's to use it that i cannot figure out where to start.
I'am pretty sure that piCore must be the server, and the ESP32 the client in this game.
I see some bluetooth related .tcz's in the 10x/armv7 repos but i need some guidance to a start  ::)
I also have to say, that i am not afraid building extensions or compiling stuff on the piCore, so i'am open for all suggestions.

Thank's in advance here guy's

Jesper.





Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 661
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #1 on: November 19, 2020, 05:00:00 PM »
Move up to piCore12.  Bluetooth stuff is built.  Bluez -> Bluealsa works fine as a transport, but codecs other than sbc are problematic.  There are also some transport delays, but that is getting better in recent versions.

Not sure how well BLE is supported in Bluez in combination with rpi chipsets.

Anyway start there, and see what where the rabbit hole leads.


Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #2 on: November 20, 2020, 09:53:56 AM »
I will try it out...  :)

Thank's Paul!


Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #3 on: November 24, 2020, 11:55:00 PM »
Hi again...

I decided to try if i could make some BLE work on the 10.x / armv7 (Aka' pCP 6.10 - This is another story and offtopic, so i leave it for now)

I took the last Bluez v. 5.54 and compiled it on my Pi3 B+ (for a start), i created an .tcz and a .tcz.dep for it to work.
The Makefile.in had to be patched for readline to work, but i succeded at last (take a look at my old thread where i also struggle this here http://forum.tinycorelinux.net/index.php?topic=18282.15

Most important is that i see other Bluez.tcz where the gatttool is not included, because it should be copyed from attrib directory on the build dir. into /usr/local/bin before the .tcz are squashed  :) ... So Gatttool is also working... great!

The Bluetooth BLE has for me an vertical learning curve, but i make some progress through.
I can build a "server" on the ESP32 devkit and actually read some with use of the Blues.tcz build... It's for a start but things are working.

Well i found another thing which i installed and it's the bluepy libary. I installed this through pip3 install, and it seems to be working.
-Later i could make a real compile and a .tcz.

I was hoping some here could help further from here? - I need help using the BluePY  :) and setting it all right up.
someone here want's to try to play with it  :)
I cannot attach or link to my build and .tcz's as i read somewhere it's not allowed here?

Should i finalize my Bluez.tcz and submit it ? 

Jesper.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 12629
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #4 on: November 25, 2020, 01:17:20 AM »
Thanks for the offer, but as we're on piCore-12.x, which has a bluez extension, I'm not sure there's much point submitting one for piCore-10.x.

Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #5 on: November 25, 2020, 01:33:45 AM »
Hey Juanito...

Maybe Bluez 12.x is working on the 10.x ? - Could be worth a try.
Do you know if the gatttool is included in this 12.x build?

Poul also suggested me to try out th 12.x, but i need it working on the 10.x, but anyway the main issue is now howto use the whole setup Bluez + bluepy  :) :)

Jesper.

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 12629
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #6 on: November 25, 2020, 02:09:30 AM »
I doubt the piCore-12.x bluez would work in piCore-10.x as it has been compiled against a more recent glibc.

As per http://tinycorelinux.net/12.x/armv6/tcz/bluez.tcz.list there's no gattool...

Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #7 on: November 25, 2020, 02:14:16 AM »
Quote
As per http://tinycorelinux.net/12.x/armv6/tcz/bluez.tcz.list there's no gattool...

Okay... too bad  :)

I will continue my setup on the 10.x for now, don't think it would be a problem making a new Bluez including gatttool when i move on to that dist.  :D

Jesper.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 661
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #8 on: November 25, 2020, 05:49:30 AM »
I’ll be upgrading to bluez 5.55 soon, I’ll include gattool. 


Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #9 on: November 25, 2020, 06:59:34 AM »
Poul... great news.

Btw. : Do you preserve the config files during boot?

I notet in my tce.installed script thoose lines :
Code: [Select]
#!/bin/sh

# NEED to preserve these files during boot!

#/usr/local/etc/bluetooth
#/usr/local/etc/bluetooth/main.conf
#/usr/local/etc/bluetooth/input.conf
#/usr/local/etc/bluetooth/network.conf

# This one is not in source dir... Maybee leave it out
#/usr/local/etc/bluetooth/proximity.conf

exit

And when we look at the directory it shows :
Code: [Select]
tc@piCorePlayer:~/package/usr/local/tce.installed$ ls -all /usr/local/etc/bluetooth
total 0
drwxr-xr-x    2 tc       staff          100 Jan  1  1970 ./
drwxr-xr-x    8 tc       staff          220 Jan  1  1970 ../
lrwxrwxrwx    1 root     root            57 Nov 25 15:53 input.conf -> /tmp/tcloop/bluez-5.54/usr/local/etc/bluetooth/input.conf
lrwxrwxrwx    1 root     root            56 Nov 25 15:53 main.conf -> /tmp/tcloop/bluez-5.54/usr/local/etc/bluetooth/main.conf
lrwxrwxrwx    1 root     root            59 Nov 25 15:53 network.conf -> /tmp/tcloop/bluez-5.54/usr/local/etc/bluetooth/network.conf

Jesper.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 661
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #10 on: November 25, 2020, 07:22:54 AM »
Somehow those files got left in the arm version.  aarch64 is good.   I'll fix when I update.

« Last Edit: November 25, 2020, 07:43:29 AM by Paul_123 »

Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #11 on: November 25, 2020, 07:46:24 AM »
Quote
If there are reasons to change the conf files.....I can certainly adjust the scripts to do that.

I donno how "you" do it, but i would preserve the in /opt/.filetool.lst and make the tce.installed script "look" for the files, and then if not overwrite them.
You proberly have a better way i quess?  :)

Anyway Poul, do you by any chance have an working bluepy or other script example howto read some say BLE characteristics from a unit (mine is ESP32) ? - It's soo hard to get going and understand howto do it!

Jesper.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 661
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #12 on: November 25, 2020, 08:57:39 AM »
I’ve only done audio stuff with Bluetooth.  And only glanced at the ESP32 based products.  Are you getting a connection.   I know there is some BLE issues with the rpi3/4, not sure if the zero is impacted.

I realize your tinkering, but why not attach your encoder to the rpi directly.

Offline lykkedk

  • Full Member
  • ***
  • Posts: 174
Re: BLE bluetooth communication between ESP32 ---> piCore
« Reply #13 on: November 25, 2020, 10:29:20 AM »
Quote
I realize your tinkering, but why not attach your encoder to the rpi directly.

Alpha_prototype for remote volume / play / pause wheel wireless with Bluetooth LE... ESP32 shall be battery powered  8)

Jesper.