PySense library on Extension Board 3.1

  • I'm trying to read the battery voltage with the PySense/pycoproc library function read_battery_voltage(), however the board detection fails with the error message below. Is there no support for the Extension Board 3.1?

    rst:0x7 (TG0WDT_SYS_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    mode:DIO, clock div:1
    ho 0 tail 12 room 4
    entry 0x400a05bc
    Smart Provisioning started in the background
    See for details
    Traceback (most recent call last):
      File "", line 15, in <module>
      File "/flash/lib/", line 20, in __init__
      File "/flash/lib/", line 115, in __init__
      File "/flash/lib/", line 115, in __init__
    Exception: Board not detected: I2C bus error
    Pycom MicroPython 1.20.2.rc6 [v1.11-01f49f7] on 2020-02-28; LoPy4 with ESP32
    Pybytes Version: 1.3.1
    Type "help()" for more information.

  • @aparcar On expansion Boards you can determine the battery voltage with the internal ADC on Pin P16. There is a voltage divider between the battery an P16, which divides the battery voltage by 2 or by 3.05, depending on the board. So you can use the ADC class (see with 11dB attenuation to read the input voltage and scale that by the divider. E.g. if the ADC tells 1.9V, and the divider is 2, the the battery voltage is 3.8V. Since the ADC is noisy, you may have to calculate an average over say 100 values taken. If you have an voltage meter, you should take that to obtain the proper scaling value.

Log in to reply

Pycom on Twitter