Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 2.95 KB

README.md

File metadata and controls

65 lines (43 loc) · 2.95 KB

CoreSensors Library Version analytics

CoreSensors is an Arduino library that supports measuring the AVR's internal temperature and supply voltage.

What

The CoreSensors library allows arduino programs to determine the actual MCU temperature and supply voltage without external components.

Why

Your arduino might run on battery power. In that case CoreSensors helps to supervise the voltage without having to rely on external components.

Or your project might get hot (or cold). CoreSensors can tell you how hot the Arduino MCU chip gets, independent of sensors in other parts of your project.

Example

#include "Arduino.h"
#include "CoreSensors.h"    // https://github.com/sekdiy/CoreSensors

void setup() 
{ 
  Serial.begin(115200);
}

void loop() 
{ 
  // update sensor measurements
  CoreSensor.update();

  // output results
  Serial.print(CoreSensor.getTemperature()); Serial.print(" degC, ");
  Serial.print(CoreSensor.getTemperature(true)); Serial.print(" degF, ");
  Serial.print(CoreSensor.getVoltage()); Serial.println(" V");

  // wait a second
  delay(1000);
}

This example takes a measurement, displays the core temperature (both in °C and in °F) as well as the core voltage and then repeats.

A more complex example is also provided with the library. It demonstrates scheduling and processing the two sensors independently.

How

CoreSensors employs two properties that are built into the Arduino:

  • an internal substrate diode that can measure temperature,
  • an internal bandgap reference that works independent of the supply voltage.

The library is aware of different Arduino types, clock speeds and supply voltages. It also features a noise reduction mode and averaging, which improves speed and repeatability.

Calibration

Since the sensors aren't comparable with high precision external sensors, they can use some individual calibration in order to improve precision.

The CoreSensors library provides you with a way to calibrate each individual Arduino (by taking two reference measurements and applying a simple formula, see Albert van Dalen and Oregon Embedded for an introduction).

Note

This library defines a dummy ADC_vect interrupt service handler routine. In case your code requires its own ADC_vect routine, you can simply replace the one in this library without any negative impact. But please keep in mind that the order of include statements in your code might influence which ADC_vect routine will actually be applied.