My-Code

J

W

Powered by: marsnet.co.uk

Home

My-Code.co.uk/Topic

Arduino - analog to digital converter & thermistors

By DarthVader

Date: 2022-06-13

Topic: 126 see comments

Post views: 988


analogRead() - Analog to digital converter - (thermistor)

Here is how a microcontroller converts electric signals from various hardware components into useable digital values i.e numbers:

 

analogRead() - Description

Reads the value from the specified analog pin. Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and the operating voltage(5V or 3.3V) into integer values between 0 and 1023. On an Arduino UNO, for example, this yields a resolution between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.

Note:

This means that you multiply the integer value returned in the serial or LCD display by 0.0049 in order to get the voltage across the component connected to the analog pin.

As the ADC (analog to digital converter has a range from 0 - 1024), 1024 × 0.0049 = 5 V, the max voltage output of the board.

analogRead(pin) = voltage / 0.0049

voltage = analogRead(pin) × 0.0049


Thermistor

Thermistors are a special type of resistor than changes its resistance based on its temperature in order of ohm's per degree. This can be a substancial change in ohm's per degree.

To get a usable temperature value from the thermistor, the voltage across it is converted to a temperature value.

This is done on the microcontroller via an analog to digital converter, and then a short calculation using a natural log and polynomial.

To set up the hardware you need a liquid crystal LCD display, a microcontroller and a thermistor:

#include <LiquidCrystal.h>
int tempPin = 0;
//                BS  E  D4 D5  D6 D7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
 lcd.begin(16, 2);
}
void loop()
{
 int tempReading = analogRead(tempPin);
 // This is OK
 double tempK = log(10000.0 * ((1024.0 / tempReading - 1)));
 tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK )) * tempK );       //  Temp Kelvin
 float tempC = tempK - 273.15;            // Convert Kelvin to Celcius
 float tempF = (tempC * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit

 // Display thermistor reading
 lcd.setCursor(0, 0);
 lcd.print(tempReading);
 delay(500);
}

[log] = natural log, not log base 10

[int tempReading = analogRead(tempPin)] = gets voltage reading from analog pin (thermistor)


Tags:

Thermistor, ADC, arduino, LCD,

Comments Creator Date ID
Recent Topics
James Webb Space Telescope
Inspiration 4
SpaceX starship SN-15 - launch nominal!

Integration Formulas

differentiation formulas (calculus)

Shapes

(SUVAT) Equations Of Motion

Linear Equations

Trigonometry

Logarithms

Electric Circuit Equations

Engineering/Physics Equations

The golden rules of op-amp behaviour

Fundamental frequency

Minimum sampling frequency - (Nyquist frequency)

RC Lowpass filter simple circuit

Calculating Decibels (dB)

Light controlled LED

Phase Shift

Anode and Cathode Overview

Voltage divider

Op Amps

Wheatstone bridge

Capacitors - Charging/Discharging

States Of Matter

Electric motor efficiency & Torque speed relationship for a D.C motor

Ferromagnetic materials

Generators & Motors

r.m.s current and voltage

Drift Velocity (Electric current)

Patents and Standards

Finite Geometric Series

4 Fundamental Principles Of A Professional Engineer

Matrix Algebra

Battery Cells

Combinations & Permutations

Ohm's Law For Alternating Currents

Current & Voltage In Complex Form

Complex Numbers #2

Integration Formulas

The Maclauren Series & Approximation

First-Order Approximation

The Newton-Raphson Method

Differential Equations #1

Torricelli's Theorum

Hooke's Law

Integration By Parts

Integrals #2

Identifying Sources Of Error In Experimental/Theoretical Data

Solving Free Body Diagrams (forces, vectors etc...)

Polar & Cartesian coordinates

sin( A + B ) Proof

Symbols

Radians

Vectors

Newtons Laws Of Motion

The Binomial Theorem + Binomial Expansion + Binomial Series

Summing Consecutive Numbers To Form A Series

Solving Higher Order Polynomial Equations (cubic, quartic, quintic)

Completing The Square For Quadratic Equations

Formulae For Straight Line Graphs

Mathematics Equations

Translating Graphs Of Functions Up/Down, Left/Right

Functions `1

Exponential Function: f(x) = ae^kx + b

Domain, Codomain, Range

Finding The Inverse Of A Function

Computer Simulations

Integration (calculus)

Hydrocarbons

Polyethene

Optimization

Stationary Points Of A Function (local max/min etc.) (Calculus)

Casting Solidification Rates

differentiation formulas (calculus)

Engineering Stress

Derivatives (Calculus)

Additive Manufacturing

Spectroscopy

Surface Engineering

Properties of Light

Standard Deviation

Cutting & Joining

Solving Trig Functions Using Graphing Method

Parabolas

Quadratic Equations

Forming

Homologous temperature

Heating, Cooling And Changes Of State

Casting

Shapes

Material Utilisation

Direct Material Costs

Surface Area to Volume Ratio

Manufacturing Methods - Creating Shapes

Sinusoidal Functions

Solar Panels

p-n junction

Resistance And Conductance

Arduino - analog to digital converter & thermistors

Solar Energy

Longitude/Latitude and Azimuth/Elevation

Electron Volt (eV)

Radioactive Decay

The Number e & Natural Logarithms

Nuclear Radiation

Exponentials

Power from Wind (wind turbine equation)

(SUVAT) Equations Of Motion

Properties of Waves

Balancing Chemical Equations

Chemical Formulas and Equations

Calculating Probability

Risk

Youngs Modulus

Accuracy Vs Precision

Inequalities

Arches

Moments

Circles

Combustion In Chemistry

Calculating The Mass Of A Mole

Atoms

My Playlist

Direct & Inverse Proportions

Fractional Exponents

Powers, Laws of exponents

Materials Engineering (terms)

Linear Equations

Trigonometry

Microscope Images - Metal + Paper

Logarithms

Kilowatt-hour (kWh)

Electric Circuit Equations

Temperature Scales

Calculating Resistance

Complex Numbers

Quadratic Formula

Algebraic equations involving variables raised to a power

Thermal Management

Units

Work

Powers, Exponents, Indices ( Index )

Useful Conversions

Materials

Notation

Percentages, Fractions, Decimals

Area & Volume (basic)

Engineering/Physics Equations

Mean, Median, Mode

Radicals

Strain

Pumpkin Spice 🎃 ✨

95TH

Egyptian pyramid

Word problems involving mixtures

S+B

Graphing Linear Equations

Terminology

2014 UN271 (Comet)

Algebra Basics

Where to start when learning HTML (Or coding as a beginner)

Elegoo Conquerer robot

New Website Feature Added.

Study Music Playlist.

First Music Post.