Exterior
Temperature measurement principle
Determining a gate period with a high temperature coefficient of the oscillator, the oscillator internal counter a low temperature coefficient of pulses is counted during this period to obtain a temperature value gate. The counter is preset to a value corresponding to -55 degrees Celsius. If the added value of the counter reaches zero, the temperature register before the end of cycle gate (also initialized to -55 ° C), indicating that the measured temperature is greater than -55 degrees Celsius.
1. Refers to a temperature coefficient of the oscillator is an oscillator, there is a specific relationship between the oscillation frequency and its temperature, i.e. different temperatures corresponding to different oscillation frequencies. Conversely, to measure the output frequency of the oscillator, the temperature can be measured.
2. High temperature coefficient of the oscillator: its oscillation frequency is greatly affected by temperature, a slight change in temperature, the frequency will change a lot, i.e. sensitive to temperature used for the temperature sensor.
3. Low temperature coefficient of the oscillator: its oscillation frequency is affected by temperature is small, even if the temperature changes greatly, its frequency is also substantially constant.
At the same time, the counter is reset to a value that is determined by the ramp accumulator circuit, ramp accumulator circuit parabolic characteristic compensator for temperature-sensing oscillator. Then start counting until the counter 0, the cycle if the door has not ended, the process is repeated. The nonlinear compensating accumulator to ramp the temperature sensitive oscillator, in order to obtain a relatively high temperature at the time of resolution. This is achieved by changing the value of the counter once for each of the required increase in temperature counted. Thus, in order to obtain the desired resolution, you must know the value of the counter and the count value of the temperature of each of a given.
Circuit diagram
Data end --D4 (GPIO ports can be, here is the code which is written D4)
negative terminal --GND
positive terminal --3V (with 5V should have been, but I bought nodeMCU (Lynx eixpsy) even before then 5V it has not read parameters, display -127, check a lot of information, and finally you have found, then there is signal output interface of 3V)
must remember pull-up resistor 10K
You need to download two libraries
OneWire
DallasTemperature
Code
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup(void)
{
Serial.begin(115200);
Serial.println("Dallas Temperature IC Control Library Demo");
sensors.begin();
}
void loop(void)
{
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures();
Serial.println("DONE");
Serial.print("Temperature for Device 1 is: ");
Serial.print(sensors.getTempCByIndex(0));
delay(1500);
}