📜  带温度传感器的 nodemcu - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:02.732000             🧑  作者: Mango

代码示例1
// initializes or defines the output pin of the LM35 temperature sensorint outputpin= A0;
//this sets the ground pin to LOW and the input voltage pin to high
void setup() {
Serial.begin(9600); 
}void loop()       //main loop{
int analogValue = analogRead(outputpin);
float millivolts = (analogValue/1024.0) * 3300; //3300 is the voltage provided by NodeMCU
float celsius = millivolts/10;
Serial.print("in DegreeC=   ");
Serial.println(celsius);//---------- Here is the calculation for Fahrenheit ----------//float fahrenheit = ((celsius * 9)/5 + 32);
Serial.print(" in Farenheit=   ");
Serial.println(fahrenheit);
delay(1000);
}