Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Bug Reports
  3. hwCPUVoltage() on AVR screws up analogRead() readings

hwCPUVoltage() on AVR screws up analogRead() readings

Scheduled Pinned Locked Moved Bug Reports
2 Posts 2 Posters 1.1k Views 2 Watching
  • 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.
  • R Offline
    R Offline
    robosensor
    wrote on last edited by
    #1

    Can I use hwCPUVoltage() function to read cpu power supply voltage in my sketch? As far as I understand this function is not documented.

    I'm asking because this function affects analogReference(INTERNAL) with further analogRead(pin) call. According to source code it seems for me that hwCPUVoltage() isn't restoring ADC settings before return.

    Simple code to test is looking something like this:

    void setup()
    {
        analogReference(INTERNAL);
    }
    
    void loop()
    {
        analogRead(pin_number); // good value
        hwCPUVoltage();
        analogRead(pin_number); // bad value
    }
    
    1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #2

      There is a vcc voltage library if you want to read voltage supplied but I heard it isn't very accurate

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      18

      Online

      11.7k

      Users

      11.2k

      Topics

      113.1k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular