Skip to content

Commit f047037

Browse files
Update README.md
1 parent 608ccd6 commit f047037

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ You could, but do you really want a device containing your WiFi credentials in a
1515
## How can I use it?
1616
Currently, you'll need to copy bthome.py to your microcontroller's /lib directory. (In the future I will create an mpy bytecode module capable of MIP installation.) Once you have bthome.py in /lib, use MIP to install aioble. Then have a look at the code sample in main.py here in this repository.
1717

18+
It boils down to this...
19+
1. Import the bthome module
20+
2. Set the device name you want
21+
3. Write the sensor readings to the bthome variables
22+
4. Call bthome.pack_advertisement() with parameters to indicate which data to broadcast
23+
5. Send that advertising data to `aioble.advertise()`
24+
25+
```
26+
import bthome
27+
bthome.device_name = "myBeacon"
28+
bthome.temperature = dht.temperature()
29+
bthome.humidity = dht.humidity()
30+
adv_data = bthome.pack_advertisement(bthome.TEMPERATURE_SINT16, bthome.HUMIDITY_UINT16)
31+
```
32+
33+
See [main.py](main.py) for a more robust example.
34+
1835
## Will it run on Microcontroller X?
1936
If the device has Bluetooth and can run recent versions of MicroPython, it should work. You may need to adjust a few things in the example main.py. It uses some ESP32 specific stuff in parts of the debugging output.
2037

0 commit comments

Comments
 (0)