Read & Write Characteristics
Exchange values through BLE attributes.
Read & Write Characteristics is a free Arduino & IoT Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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. 🚀
Frequently asked questions
Is the “Read & Write Characteristics” lesson free?
Yes — the full text of “Read & Write Characteristics” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.
What will I learn in “Read & Write Characteristics”?
Exchange values through BLE attributes. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Arduino & IoT Academy?
No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Read & Write Characteristics” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Arduino & IoT Academy lesson?
Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Classic Bluetooth vs BLE
- Advertise a BLE Service
- Read & Write Characteristics
- Control an LED from a Phone App