“Lesson 14--Microduino "A simple thermometer"”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
(Created page with "{| style="width: 800px;" |- | ==Objective== This lesson will introduce the temperature sensor, combined with Microduino to be a simple thermometer. Digital temperature sensors...")
 
第16行: 第16行:
 
This sensor can measure of 0-100 degrees Celsius temperature, and output the value of voltage. Starting from 0 degrees temperature rise per 1 degree output voltage will increase 10 mv, so that we can use the analog port to detection sensor voltage, after simple to calculate the measured temperature value.
 
This sensor can measure of 0-100 degrees Celsius temperature, and output the value of voltage. Starting from 0 degrees temperature rise per 1 degree output voltage will increase 10 mv, so that we can use the analog port to detection sensor voltage, after simple to calculate the measured temperature value.
 
===LM35 connection===
 
===LM35 connection===
[[File:第十三课-LM35.jpg|600px|center|thumb]]
+
[[File:Lesson14-LM35.jpg|600px|center|thumb]]
  
 
==Experimental schematic==
 
==Experimental schematic==
 
The connection is very easy,just pay attention to the positive and negative。
 
The connection is very easy,just pay attention to the positive and negative。
[[File:第十三课-原理图.jpg|600px|center|thumb]]
+
[[File:Lesson14-schematic.jpg|600px|center|thumb]]
  
 
==Program==
 
==Program==

2014年2月16日 (日) 08:39的版本

Objective

This lesson will introduce the temperature sensor, combined with Microduino to be a simple thermometer. Digital temperature sensors have a common DS18b20, DHT11, SHT10 and so one. Analog temperature sensor has thermistor, AD590, LM35D so on.

Equipment

LM35 temperature sensor

This sensor can measure of 0-100 degrees Celsius temperature, and output the value of voltage. Starting from 0 degrees temperature rise per 1 degree output voltage will increase 10 mv, so that we can use the analog port to detection sensor voltage, after simple to calculate the measured temperature value.

LM35 connection

Experimental schematic

The connection is very easy,just pay attention to the positive and negative。

Program

void setup() {
 
  Serial.begin(115200);       //Set teh baud rate to 115200
}

void loop() {

  int n = analogRead(A0);    //Read the voltage from A0

  float vol = n * (5.0 / 1023.0*100);   //Use a float variable to save temperature value which was calculated from voltage.

  Serial.println(vol);                   //Output the temperature from serial

  delay(1000);                           //Wait for 1s for refresh
}

Result

After download, you can see the temperature data from serial monitor, refreshed every 1s.

Video