Skip to content

Instantly share code, notes, and snippets.

@topshed
Last active April 20, 2018 13:10
Show Gist options
  • Save topshed/3a0ea474b0f5555241e6551d3a2903ec to your computer and use it in GitHub Desktop.
Save topshed/3a0ea474b0f5555241e6551d3a2903ec to your computer and use it in GitHub Desktop.

Analog temperature sensor

This circuit demonstrates how to read the analog input from a TMP36 temperature sensor. This corresponds to the temperature measured by the sensor.

Imgur

The Arduino will give you a reading that you need to convert into temperature value. Because the TMP36 is connected to 5v we need to multiply the reading from the analog pin by 5. Then divide by 1024 (the Arduino uses a 10-bit analog to digital converter - this means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023).

Once you have a voltage reading, convert that to temperature: for the TMP36 there are 10 mv per degree, with a 500 mV offset

It may sound complicated but the code makes the mathematics easy!

Imgur

Can you add an LED or buzzer to warn of temperature changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment