質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

Q&A

解決済

1回答

4731閲覧

ESP32とAndroidのBlueTooth接続がすぐ切れてしまう

hama1185

総合スコア18

Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Arduino

Arduinoは、AVRマイコン、単純なI/O(入出力)ポートを備えた基板、C言語を元としたArduinoのプログラム言語と、それを実装した統合開発環境から構成されたシステムです。

0グッド

1クリップ

投稿2021/03/28 19:11

前提・実現したいこと

Androidのセンサーの値をESP32にBlueToothで送信したい

発生している問題・エラーメッセージ

ESP32がBlueToothの接続候補として出現してつなぐと5秒程度で接続が切れ,以前接続したデバイスという扱いになってしまう

該当のソースコード

C

1#include "BluetoothSerial.h" 2 3BluetoothSerial SerialBT; 4 5void setup() { 6 Serial.begin(115200); 7 SerialBT.begin("ESP32test"); 8} 9 10void loop() { 11 if (Serial.available()) { 12 String sendData = Serial.readStringUntil(';'); 13 SerialBT.print(sendData); 14 } 15 16 if (SerialBT.available()) { 17 String receiveData = SerialBT.readStringUntil(';'); 18 Serial.print(receiveData); 19 } 20}

試したこと

以下の記事を参考に電池の最適化を切ったが挙動は変わらなかった.
https://investinlife.tokyo/kaki/bluetoothmidiservice/

また,AndroidとESP32どちらに問題があるのか不明であったためそれぞれBlueToothでPCと接続してみたところ両者問題なく接続できることを確認しました.

補足情報(FW/ツールのバージョンなど)

Pixel4 Android11

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

回答というにはナンですが、別件でArduino ESP32の修正履歴を見ていたら、ボードパッケージ1.0.5と1.0.6の間でBluetoothまわりがちょこちょこといじられているようです。内容は見ていませんが、最新版で試す(あるいは逆に古いバージョンを試す)とどうなるでしょうか。

Text

1commit 9a0762ad2a3773ccf919631203aa24cd311109a0 2Author: Me No Dev <me-no-dev@users.noreply.github.com> 3Date: Wed Mar 17 18:46:55 2021 +0200 4 5 [BLE Client] Fix Deadlock when calling writeValue after registerForNotify 6 7 Fixes: https://github.com/espressif/arduino-esp32/issues/4952 8 9commit d362e1ee1adeb6c5e4980457de8c3612235feea4 10Author: Raúl C.G <raulcigil@gmail.com> 11Date: Tue Mar 16 10:56:23 2021 +0100 12 13 [BLE] Allows you to specify which channels are used to advertise. (#4954) 14 15 In some use cases getting rssi signal from one channel is more stable (less variance) than rssi from the three advertising channels. 16 17 This change allows you to specify which channels are used to advertise. 18 19commit 5b845272ed5357a3ef4ca0d118a21e995d69b047 20Author: me-no-dev <hristo@espressif.com> 21Date: Tue Mar 16 02:11:59 2021 +0200 22 23 Fix BluetoothSerial TX Stall 24 25 Fixes: https://github.com/espressif/arduino-esp32/issues/4949 26 27commit 4d95e3a7ea072ac61ff0eb24b3304db47de96712 28Author: me-no-dev <hristo@espressif.com> 29Date: Tue Mar 9 01:56:47 2021 +0200 30 31 Fix BT not starting correctly and SPP Coex not working 32 33 Fixes: https://github.com/espressif/arduino-esp32/issues/4912 34 35commit bd3addeb8e9b05766979caf32b74ee0a0e2ae4c8 36Author: Aron Rubin <aronrubin@gmail.com> 37Date: Mon Mar 1 16:55:04 2021 -0500 38 39 Fixed use of Bluedroid instead of BT in HAL. (#4879) 40 41 Fixed use of CONFIG_BLUEDROID_ENABLED instead of CONFIG_BT_ENABLED in HAL. This prevented compilation with Nimble-only configuration without apparent benefit. 42 43commit 44aaf13225e349f75f63fdcc059940f451844c02 44Author: Bascy <basschouten65@gmail.com> 45Date: Mon Feb 22 18:37:07 2021 +0100 46 47 Added BLEAddress operator overload methods (#4839) 48 49 Allows BLEAddress to be used as key in std::map etc 50 51commit 1ab550f6f27ac8245fc9f0ee2f076329ba9ad457 52Author: Michael <morsisko@gmail.com> 53Date: Tue Feb 16 21:10:04 2021 +0100 54 55 Changed BLE notify_callback from raw function pointer to std::function (#4737) 56 57commit 9be784f69b696d5bbb189a2fe5f1750ce2855426 (tag: 1.0.5-rc7) 58Author: Emanuel Posescu <emanuel.posescu@dacodasoft.ro> 59Date: Tue Feb 16 11:21:45 2021 +0200 60 61 Improve cleanup in BLEClient (#4742) 62 63 - Remove client from the list of devices in case registration fails 64 - Filter other events not related to registration during registration phase 65 - Cleanup if connect fails 66 - Reset if after disconnect 67 - Disconnect callback *after* cleanup is done so object can be deleted 68 69 This fixes some of the issues I had like: 70 - `BLEClient::connect` hangs up and never recovered because registration failed 71 - `BLEClient` could not be deleted after disconnect or deletion creating ghost events https://github.com/espressif/arduino-esp32/issues/4047 72 - `BLEClient` could not be properly reused after a connection was attempted (successful or not) 73 74 * Cleanup in case of registration and connect failure. 75 Cleanup before calling disconnect callback for safe delete. 76 Reject other events during registration. 77 Adresses #4047, #4055 78 79 * Clear if after unregister #4047 80 81commit 7cdfb8bc7cdcb9e47931e28a65b7a587a721047b 82Author: Markus Frey <mfrey@mailbox.org> 83Date: Tue Feb 16 10:02:58 2021 +0100 84 85 Refactor BLEAdvertisedDevice (#4739) 86 87 fixes #4596 88 89 * Prevent possible undefined behaviour by get methods not taking an index as parameter 90 * Add methods to get the count of service data UUIDs and service UUIDs 91 * Various code improvements 92 93commit e831680a41d4c96769cae7277501ce41abe69eee 94Author: ushiboy <ushikic@gmail.com> 95Date: Tue Feb 16 08:50:24 2021 +0900 96 97 Fixed a memory leak in BLE (issue #4753) (#4761) 98 99 * Fixed crash on delete after disconnect 100 101 * Fixed memory leak when getting characteristics 102 103 * Removed guard 104 105 Co-authored-by: ushiboy <ushiboy.dev@gmail.com> 106 107

投稿2021/04/01 23:45

thkana

総合スコア7610

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

thkana

2021/04/06 10:44

バージョン上げて解決したのかしら?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問