arduino-esp32-c3对MF53-103F-3950-800L温度传感器的温度读取代码参考
时间: 2023-09-30 18:10:55 浏览: 126
您可以参考以下代码进行温度读取:
```
// include the required libraries
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_AM2320.h>
// create an instance of the sensor
Adafruit_AM2320 am2320 = Adafruit_AM2320();
void setup() {
Serial.begin(9600);
// initialize the sensor
if (!am2320.begin()) {
Serial.println("Error initializing AM2320 sensor!");
while (1);
}
}
void loop() {
// read the temperature and humidity
float temperature = am2320.readTemperature();
float humidity = am2320.readHumidity();
// print the temperature and humidity to the serial monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println(" %");
delay(5000); // wait for 5 seconds before taking another reading
}
```
这是基于 Adafruit_AM2320 库的代码。在此例中,它用于读取 AM2320 温湿度传感器的温度值和相对湿度值。如果您的传感器型号是MF53-103F-3950-800L,则根据您的传感器规格可能需要进行一些适当的修改。
阅读全文