Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 10-18-2019, 09:13 AM   #1
LQ Newbie
Registered: Oct 2019
Posts: 2

Rep: Reputation: Disabled
Need help for bluetooth low energy (on Raspberry and ESP32)

Hi, I've got a Raspberry Pi 3 with Buster and I was trying to keep a BLE connection with my ESP32 (with the script I had before it connected just for the reading and then it disconnected) when I found this thread:

So I ran this script:

tmux new-session -d -s ServerFault 'sudo bluetoothctl -a |& tee /run/shm/BLUETOOTH_OUTPUT'
tmux send-keys -t ServerFault -l 'pair MAC_OF_MY_ESP32'
tmux send-keys -t ServerFault Enter
but after doing so, my ESP32's BLE characteristic for getting the data I need is now empty. I can't connect to the ESP32 neither by my phone (I used Serial Bluetooth Terminal, but now it shows "write descriptor failed" error when trying to connect) and I don't know how to come back to when it worked.

I tried to do
tmux kill-server
tmux kill-session
tmux kill-session -t ServerFault
pkill -f tmux
but it seems that no tmux session is open.
(the output is "no server running on /tmp/tmux-1000/default")

I don't know how could that command change something on ESP32, but the only commands I remember I ran other than that one are just those:

sudo hciconfig hci0 reset
sudo invoke-rc.d bluetooth restart
hcitool scan
Can you please help me?

Last edited by jhel; 10-18-2019 at 09:19 AM.
Old 10-18-2019, 11:26 AM   #2
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,436

Rep: Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161
Bluetooth is a pain. It was an IBM ultra-secure (= nobody can connect with you except by Divine Intervention or immense setup pain on your part).
That said, if you're using a Pi and turning bluetooth off to save current, that may not be wise. Everyone writes their own bluetooth stack and they're nearly all crap. To transfer, bluetooth needs
  • Tou be turned on
  • … At BOTH ends
  • The devices need to see each other
  • They need to be paired
  • They need to trust each other.
  • The default download locations (if applicable) need to be writable.

I would get out your mobile phone and check. You should be able to see and transfer to both devices, There's bluetoothctl on my system which is less crap than anything else I've tried. I needed bluetoothctl to set up and something else to transfer files. bluetoothctl is console mode, and of course you need root for this stuff.

Last edited by business_kid; 10-18-2019 at 11:29 AM.
Old 10-18-2019, 01:23 PM   #3
LQ Newbie
Registered: Oct 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
I don't know if I have written the right code for the ESP32, but it worked for like 2 months. But in a few days I have a test at the university on it and I wanted to edit the raspberry script to add this thing.
I mean, the script worked(ED...). The thing that the ESP32 sent was a detection of temperature and humidity. And using gatttool in a non-interactive mode from the raspberry Pi I could read them in every cycle the script did. But it connected to the device just for the moment of the reading and I thought "if someone that is not my Raspberry connects to my ESP32, the raspberry would stop to receive data!", so I wanted to ensure that there would be a fixed connection between the two devices.
But, as I told, after trying that commands I found in that thread I can't access the data anymore. So I messed up with the bluetooth configuration of the ESP32 in some way from the raspberry. I don't have anymore the module to reprogram the ESP32, so I wanted to undo whatever I did from the raspberry.
I tried to connect the devices by bluetoothctl and it works with connect, trust and pair but I can't access uuid that the raspberry needs to read (it shows "UUIDs has unsupported type"). And since neither the phone can read it I think it's something I changed on ESP.

Sorry if I bothered you, but I don't know what to try. Thank you for the reply anyway!
Old 10-19-2019, 05:29 AM   #4
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 15,436

Rep: Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161
I've been through College. Fancy me trying to get through hardware engineering with my design: The input HEMTs on my two prototypes blew because I didn't hadn't any anti-static storage space; The pcbs couldn't be prototyped because the 74HCAUC devices were too $%Ł&@! small to be hand soldered, so I had one device working between the two. I designed the pcb with a lot of earth as shielding and capacitance which was supposed to be a component in the circuit, but the pcb manufacturer took it out. I got spare input devices but the techie was afraid to try soldering them on, etc. etc. I couldn't complain because the report went to external examiners!

You can be amazing with that kind of a torch under your backside. The thing about bluetooth is, Nobody, but nobody can connect to it as it should operate. It requires input on both ends. Don't lose your cool; I would purge everything you messed with and set it up as it worked. If that fails, point out that it did work, although it doesn't now, and you know why, but ran out of time to fix it. It won't cost you muchin marks. Highlight the unreliability of bluetooth, and it's unsuitability to the uses it's being put to. Highlight also that you broke the first rule of maintenance "If it ain't broke, don't fix it!" but that was done in the interests of developing a better product and these events are not unusual. Waffle about security and show you understand the principles. You'll be fine. 50% they won't even turn it on. They'll buzz through it during the Christmas hangover period. You have to be straight up for summer papers, but you can be frank & funny in the mid terms. I included this bit in the final mid-term

Last edited by business_kid; 10-19-2019 at 05:39 AM.
Old 10-19-2019, 08:35 AM   #5
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,897
Blog Entries: 43

Rep: Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137Reputation: 3137
Moderator Response

Moved: This thread is more suitable in <Linux - Embedded & Single-board computer > and has been moved accordingly to help your thread/question get the exposure it deserves.
Old 10-19-2019, 02:37 PM   #6
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
# bluetoothctl

That's the tools to setup connections. You can set some connections as trusted, thus making them persistent -ish. As long as scanning is enabled, the agent is on, and other quirks.

the > command line has a help command to list options. It's not too complex outside of having to type MAC addresses of the device over and over. List it, connect to it, trust it, ... ... ... Kind of annoying, but it works. Just notice-ing that your orignal command did use bluetoothctl. And probably recorded a script of what was done using it. Which would be erased the next time you ran that command. Option 2, use a gui environment with a bluetooth agent (gui) to make it simple. A couple clicks and done.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Raspberry Pi health monitoring HAT adds ESP32 and battery for wearables mode LXer Syndicated Linux News 0 09-26-2019 11:42 AM
LXer: A new Steam Client Beta adds Bluetooth Low Energy (BLE) support to the Steam Controller LXer Syndicated Linux News 0 05-13-2018 08:33 AM
LXer: Raspberry Pi CM3 based automation controller adds ESP32 LXer Syndicated Linux News 0 12-22-2017 05:21 PM
LXer: Linux-based home energy gateway supports ZigBee Smart Energy 2.0 LXer Syndicated Linux News 0 01-31-2012 07:00 PM
LXer: Solutions for the Energy Crises -- Part 1: Alternate Energy and Conservation LXer Syndicated Linux News 0 02-03-2006 10:16 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 03:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration