battery-level in pybytes (#465)

* chore: change documentation battery-level

* docs: fix typo expansion board

* docs: update api battery section

* docs: udpate pybytes link

Co-authored-by: Ahmad EL Masri <ahmad@pycom.io>
This commit is contained in:
Quentin Clément
2021-12-02 11:09:26 +01:00
committed by GitHub
parent a22e7322c9
commit 1fc167b287

View File

@@ -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)
```