Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Problem Serial port connexion and save file voltage variable

    Scheduled Pinned Locked Moved Software Tools
    1 Posts 1 Posters 43 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      HAMMOUTI
      last edited by livius

      from machine import ADC
      import time
      import os
      import io
      adc = ADC()
      
      bat_voltage = adc.channel(attn=ADC.ATTN_11DB, pin='P16')
      
      vbat = bat_voltage.voltage()
       
      with open("vbatmv.txt", "a+") as f:
       while True :
          bat_voltage = adc.channel(attn=ADC.ATTN_11DB, 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
          
          time.sleep(30)
          
          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 .

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom