element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
The Learning Circuit
  • Challenges & Projects
  • element14 presents
  • The Learning Circuit
  • More
  • Cancel
The Learning Circuit
Documents Make Your Own Thermometer! -- The Learning Circuit 15
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join The Learning Circuit to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 2 Jul 2018 9:20 PM Date Created
  • Last Updated Last Updated: 4 Jul 2018 7:24 AM
  • Views 3100 views
  • Likes 16 likes
  • Comments 7 comments
Related
Recommended

Make Your Own Thermometer! -- The Learning Circuit 15

image

element14's The Ben Heck Show

Join Karen as she shares her enthusiasm for teaching STEM subjects, gives you what you need to know to get started on electronics projects, and more.

Back to The Ben Heck Show homepage image

The Learning Circuit
Featured Bonus Content
See All Episodes

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

DaftMike builds a thermometer using an Arduino and a thermistor.  He’ll write some Arduino code, build a circuit, and then convert the values into a temperature reading.  He’ll use an NTC thermistor as a sensor. This is a special type of resistor whose resistance changes with temperature. In order to read it with an Arduino he’s going to build a circuit on a breadboard.  This will require some wire and a 100K resistor.



Make Your Own!

Parts & Products:

Product Name

UK Part No

US Part No

Part Link

Arduino Micro228519463W3544Buy NowBuy Now
Thermistor211293510M5320Buy NowBuy Now

 

 

image

image


For this project, DaftMike will use an Arduino MicroArduino Micro because it plugs directly into the breadboard but you can use any Arduino you like. He uses wire to connect 5 volts to the top power rail and ground to the bottom power rail. There are usually multiple ground pins (marked ‘GND’).  You can connect to any of these.  He connects the thermistorthermistor to 5V and in the same column he connects the resistor to ground.  It doesn’t matter which way around these components go, they work either way.  Finally, you connect midpoint to analog pin p0.   You can now write some code:

 

********************************************* 
    element14.com/thelearningcircuit
    Episode 15: Make Your Own Thermometer
 *********************************************/


// Parameters for the voltage divider equation
const int Vin = 1023;
const long R2 = 100000;                         // measure this resistor and update this value for better accuracy


// Parameters for the Steinhart?Hart equation
const float T0 = 298.15;
const int B = 3974;
const long R0 = 100000;


const int thermistorPin = A0;


const int numReadings = 10;                     // number of readings to average
int readings[numReadings];                      // array to store thermistor readings




void setup() {
  Serial.begin(9600);                           // setup serial monitor
}




void loop() {


  float Vout;
  for (int i = 0; i < numReadings; i++) {
    readings[i] = analogRead(thermistorPin);    // read from the thermistorPin into the array
    Vout += readings[i];                        // sum the readings so far
    delay(10);                                  // allow the ADC to settle between loops
  }

  Vout /= numReadings;        // divide the running total by the number of readings to get an average




// Voltage Divider equation to calculate R1
  float R1;
  R1 = (R2 * (Vin - Vout)) / Vout;




// ? parameter equation: https://en.wikipedia.org/wiki/Thermistor#B_or_%CE%B2_parameter_equation
  float T;
  T = (1.0 / ((1.0 / T0) + (log((R1 / R0)) / B))) - 273.15;     // T is in Celcius




// Celcius to Farenheit conversion
  float Tf;
  Tf = (T * 9.0) / 5.0 + 32;




// Print the temperature in Celcius and Farenheit to the serial monitor
  Serial.print(T); Serial.print("C | ");   Serial.print(Tf); Serial.println("F");
  
  delay(10);


}

 

He names the thermistor pin and sets up an array to store a bunch of readings so that you can take an average to sort out the data.  He uses a line to set up the serial monitor.  In the main code he declares the output as a float and then uses a for loop to calculate the average.  A thermistor reading is stored in the array, added to a running total, and then delayed for a while to give the ADC a chance to settle before it runs through the loop again.  ADC stands for analog to digital convertor.  It converts voltage on the analog pin into a discrete signal.  Outside that loop, the code divides the running total by the number of readings to get an average.  You can then print it to the terminal.

 

DaftMike gives a diagram of the circuit. It’s a voltage divider where R1 is the thermistor and R2 is 100K. The equation for voltage dividers is Vout = Vin *R2/(R1+R2).  Vout is what we measured in the code, Vin is 5 volts, R2 is 100K, and R1 is what we are solving for.

  • analog pin
  • temperature reading
  • ardbeginner
  • stem_projects
  • tlc
  • ground pins
  • voltage divider
  • arduino_vcp
  • arduino micro
  • arduino ide
  • power rail
  • arduino_tutorials
  • breadboard
  • thermistor
  • analog to digital converter
  • 100k resistor
  • gnd
  • adc
  • thelearningcircuit
  • e14presents_daftmike
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • DAB
    DAB over 7 years ago +4
    Nice episode. FYI, if you average four samples, you bring the noise down by 75%. The ten sample average on takes it down to 90%, which is only a little better. So from a processor loading and signal processing…
  • davedarko
    davedarko over 7 years ago +3
    the only valuable comment from youtube I saw: please change the resolution on your screen for code stuff. You can also just change the font inside the Arduino IDE.
  • daftmike
    daftmike over 7 years ago in reply to DAB +3
    Thanks DAB, that's a good point.
  • ralgat
    ralgat over 5 years ago in reply to davedarko

    I agree here with the size or clarity of the video.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • cstanton
    cstanton over 7 years ago

    This's really good! Thanks daftmike

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 7 years ago

    Well done! Clear and neat image

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • daftmike
    daftmike over 7 years ago in reply to davedarko

    Thanks Dave, I'll keep that in mind for future.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • daftmike
    daftmike over 7 years ago in reply to DAB

    Thanks DAB, that's a good point.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • davedarko
    davedarko over 7 years ago

    the only valuable comment from youtube I saw: please change the resolution on your screen for code stuff. You can also just change the font inside the Arduino IDE.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 7 years ago

    Nice episode.

     

    FYI, if you average four samples, you bring the noise down by 75%.

    The ten sample average on takes it down to 90%, which is only a little better.

     

    So from a processor loading and signal processing efficiency standpoint, the four sample average is usually sufficient, even in noisy environments.

     

    DAB

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube