Problem Serial port connexion and save file voltage variable

  • from machine import ADC
    import time
    import os
    import io
    adc = ADC()
    bat_voltage =, pin='P16')
    vbat = bat_voltage.voltage()
    with open("vbatmv.txt", "a+") as f:
     while True :
        bat_voltage =, pin='P16')
        vbat = bat_voltage.voltage()
        # note that the expansionboard 3 has a voltage divider of 1M / 1M to account for
        # 1M / 1M, ratio = 1:2
        vbat = vbat*2
        print('battery voltage:', vbat, 'mV')
        print(vbat, file=f)

    Hi, I can you help me to solve this problem , I try to save voltage value in file with print command some time work other not , and i have problem to connect tool upycraft to my pycom board 3.1 serial port in execution of this programme .

Log in to reply

Pycom on Twitter