0Pricing
Arduino & IoT Academy · レッスン

BLEサービスをアドバタイズする

スマートフォンから見つけられるようESP32を公開します。

「BLEサービスをアドバタイズする」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Make Your Board Findable

Before a phone can connect, your ESP32 must announce itself. This shouting into the air is called advertising. 📣

What Advertising Sends

Advertising broadcasts tiny packets with your device name and what it offers, so nearby phones can list it without connecting yet.

Start with the Library

The Arduino core gives you a BLE library. Include it once, then everything for advertising and connecting becomes a few clean calls.

#include <BLEDevice.h>
#include <BLEServer.h>

Name Your Device

First you initialize BLE and give your board a friendly name. That name is what users will tap in their phone's Bluetooth list.

BLEDevice::init("Smart-Sensor");

Create a Server

Your board acts as a BLE server: it holds the data, and the phone is the client that asks for it. Create the server next.

BLEServer *server = BLEDevice::createServer();

What a Service Is

A service is a labeled group of related data, like all the values for one sensor. A device can offer several services at once.

Services Need a UUID

Each service is identified by a UUID, a long unique code. The phone uses this exact id to find the right service among many.

BLEService *svc = server->createService("180F");

Standard vs Custom UUIDs

Short UUIDs like 180F are official standard ones. For your own data, generate a long custom UUID so it never clashes with others.

Start the Service

Once the service is defined, you must start it. Until you do, the phone cannot actually use any of its data.

svc->start();

Begin Advertising

Finally, tell the radio to advertise. Now the board broadcasts its name and service so phones nearby can discover it.

server->getAdvertising()->start();

Find It on Your Phone

Open a scanner app like nRF Connect and you should see Smart-Sensor appear. Seeing your name means advertising works.

Quick Check

You wrote a service but the phone shows no data inside it.

Recap

Init BLE, name the board, make a server, add a service with a UUID, start it, then advertise. Now your device is discoverable. ✨

よくある質問

「BLEサービスをアドバタイズする」レッスンは無料ですか?

はい。「BLEサービスをアドバタイズする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。

「BLEサービスをアドバタイズする」で何を学びますか?

スマートフォンから見つけられるようESP32を公開します。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Arduino & IoT Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「BLEサービスをアドバタイズする」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このArduino & IoT Academyレッスンでコードを書いて実行できますか?

はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Classic BluetoothとBLEの違い
  2. BLEサービスをアドバタイズする
  3. Characteristicを読み書きする
  4. スマートフォンアプリからLEDを制御する
← Arduino & IoT Academyに戻る