Characteristics lesen und schreiben
Tauschen Sie Werte über BLE-Attribute aus.
Characteristics lesen und schreiben ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Where the Data Lives
A service is a folder, but the real values live inside characteristics. These are the slots a phone actually reads and writes. 📦
Characteristics Have UUIDs Too
Like services, every characteristic carries its own UUID. The phone uses it to target one exact value, such as temperature.
Create One
You build a characteristic on a service and declare what it allows: reading, writing, or both. Properties decide who can do what.
auto c = svc->createCharacteristic(uuid,
BLECharacteristic::PROPERTY_READ);Properties Set Permissions
Use PROPERTY_READ for values the phone fetches, and PROPERTY_WRITE for ones it sends back. Combine them when both directions matter.
Set a Value to Read
Your sketch stores the current data with setValue. When the phone reads, it gets exactly whatever you placed there last.
c->setValue("23.5");The Phone Writes Back
For a writable characteristic, the phone can push a value to your board. Your code reads it with getValue to learn what arrived.
std::string in = c->getValue();React with a Callback
To respond the instant a write happens, attach a callback. Its onWrite method fires automatically whenever the phone sends data.
Notify Instead of Polling
With notify, your board pushes new values the moment they change. The phone gets fresh data without asking again and again.
c->setValue(temp);
c->notify();Values Are Just Bytes
BLE sends raw bytes, not numbers. Send text like 23.5 or pack the number yourself, then unpack it on the phone side.
Keep Packets Small
A default BLE write fits about twenty bytes. Keep each characteristic focused on one small value rather than a giant blob.
Read, Write, Notify
Those three jobs cover almost every project. Read shares state, write accepts commands, and notify streams live updates.
Quick Check
You want the phone to get new readings the instant they change.
Recap
Characteristics hold the data: set properties for read, write, or notify, store values, and let callbacks react to incoming writes. 🚀
Häufig gestellte Fragen
Ist die Lektion „Characteristics lesen und schreiben“ kostenlos?
Ja — der vollständige Text von „Characteristics lesen und schreiben“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Characteristics lesen und schreiben“?
Tauschen Sie Werte über BLE-Attribute aus. Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?
Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „Characteristics lesen und schreiben“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?
Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Klassisches Bluetooth vs. BLE
- Einen BLE-Dienst bekanntgeben
- Characteristics lesen und schreiben
- Eine LED über eine Smartphone-App steuern