diff --git a/content/pybytes/api/_index.md b/content/pybytes/api/_index.md index 62f088a..8943490 100644 --- a/content/pybytes/api/_index.md +++ b/content/pybytes/api/_index.md @@ -4,7 +4,7 @@ aliases: --- -The Pybytes library is positioned in the [frozen](/advance/frozen/) section of the firmware. +The Pybytes library is positioned in the [frozen](/advance/frozen/) section of the firmware. It can be imported like regular modules: ```python @@ -63,7 +63,7 @@ Connect the device to Pybytes following the loaded configuration file. You will ### pybytes.start([autoconnect=True]) -Same as `pybytes.connect()`, with the option to set `autoconnect`. Setting `autoconnect` to `False` will not start the connection immediately. +Same as `pybytes.connect()`, with the option to set `autoconnect`. Setting `autoconnect` to `False` will not start the connection immediately. ### pybytes.enable_lte(carrier=None, cid=None, band=None, apn=None, type=None, reset=None, fallback=False) @@ -127,7 +127,7 @@ Send a signal to Pybytes. Arguments are: ### pybytes.send_ping_message() -Sends a ping (is-alive) message to Pybytes. +Sends a ping (is-alive) message to Pybytes. ### pybytes.send_info_message() @@ -135,7 +135,22 @@ Send an info message to Pybytes containing the device type and firmware version. ### pybytes.send_battery_level(battery_level) -Sends the battery level to Pybytes. The argument `battery_level` can be any integer. +Sends the battery level to **[Pybytes](https://pybytes.pycom.io/)**. The argument `battery_level` can be any integer. + +You can define `battery_level` with a function depending on your shield. Check example code by visiting [Reading Battery Voltage page](/tutorials/expansionboards/vbat). + +For example, using an Expansion Board 3.1, you can send battery level to **[Pybytes](https://pybytes.pycom.io/)** using the below code: + +```python +from machine import ADC +def battery_level(): + adc = ADC() + bat_voltage = adc.channel(attn=ADC.ATTN_11DB, pin='P16') + vbat = bat_voltage.voltage() + print('battery voltage:', vbat*2, 'mV') + return vbat*2 +pybytes.send_battery_level(battery_level()) +``` ## Miscellaneous @@ -164,4 +179,3 @@ There are multiple debug levels, the lowest is 0 which is for warnings only and >> import pycom; >> pycom.nvs_set('pybytes_debug', 99) ``` -