Code Monkey home page Code Monkey logo

vcc's Introduction

Vcc

This is a very small and basic library that contains only two (static) methods, which return the voltage of an AVR MCU supply in millivolts. The method switches the ADC on (and off again), if necessary, and it works for most of the chips of the AVR family that are supported by the Arduino IDE.

The method comes in two flavors. It can be called with two parameters, a repetition counter and a calibration value. The repetition counter specifies how often the measurement should be done in order to enhance accuracy. The calibration value specifies the accurate value of the internal voltage reference in millivolts. Nominally it is 1100 millivolts. However, this can change from chip to chip. If you want a truely accurate measurement, then you should determine this value for each chip, using, for example, the intrefTune sketch. This sketch works even if you have only access to the three ICSP pins. A simplified version of this sketch using the ordinary Serial interface can be found in the example folder.

The other flavor of the method uses a calibration value that is stored in EEPROM. It is called with only one (optional) argument, the repetition counter. So the usage of the method could look like as follows:

#include<Vcc.h>
...
int milliVolts;
...
milliVolts = Vcc::measure(); // uses calibration value from EEPROM, 10 repetitions
...
milliVolts = Vcc::measure(100, 1100); // 100 repetitions, 1100 as calibration value

The library should work with ATmega8, ATmegaX8, ATmega32u4, ATmegaX4, ATmegaX0, ATtiny43U, ATtinyX4(A), ATtinyX5, ATtinyX61(A), ATtinyX7, ATtinyX8, ATtiny828, and ATtiny1634. It will not work with ATtinyX13 because of the lack of an ADC. Concerning ATmega8, one should be aware that the bandgap voltage is 1.3 volts instead of 1.1 volts. But who uses an ATmega8 these days?

The library is licensed under the MIT license.

vcc's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.