@@ -26,19 +26,20 @@ Once you've got the modules installed, have a look at the code sample in [main.p
2626
2727Building your own sensor beacon boils down to this...
28281 . Import the bthome module
29- 2 . Set the device name you want
30- 3 . Write the sensor readings to the bthome variables you're using
31- 4 . Call bthome. pack_advertisement() with parameters to indicate which data to broadcast
29+ 2 . Create a new instance of the BTHome class, passing in the device name you want
30+ 3 . Write the sensor readings to the BTHome properties you're using
31+ 4 . Call the ` pack_advertisement() ` method with parameters to indicate what data to broadcast
32325 . Send that advertising data to ` aioble.advertise() `
3333
34- As MicroPython statements, those steps are :
34+ As MicroPython statements, those steps would be something like this :
3535
3636```
37- import bthome
38- bthome.device_name = "myBeacon"
39- bthome.temperature = dht.temperature()
40- bthome.humidity = dht.humidity()
41- adv_data = bthome.pack_advertisement(bthome.TEMPERATURE_SINT16, bthome.HUMIDITY_UINT16)
37+ from bthome import BTHome
38+ beacon = BTHome("myBeacon")
39+ beacon.temperature = dht.temperature()
40+ beacon.humidity = dht.humidity()
41+ advert = beacon.pack_advertisement(bthome.TEMPERATURE_SINT16, bthome.HUMIDITY_UINT16)
42+ await aioble.advertise(BLE_ADV_INTERVAL_uS, adv_data=advert, connectable=False)
4243```
4344
4445See [ main.py] ( main.py ) for a more robust example.
0 commit comments