我已验证DHT传感器的代码以发布数据,而我正在刷新该代码,但服务器仍无法处理请求重新尝试时间的消息底部。
我尝试了一些在粒子论坛中提供的方法,但无法解决我的问题。谢谢。
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"
// DHT parameters
#define DHTPIN 5
#define DHTTYPE DHT11
// Variables
int temperature;
int humidity;
//int light;
// Pins// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>
//int light_sensor_pin = A0;
// DHT sensor
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// Start DHT sensor
dht.begin();
}
void loop() {
// Humidity measurement
temperature = dht.getTempCelcius();
// Humidity measurement
humidity = dht.getHumidity();
// Light level measurement
//float light_measurement = analogRead(light_sensor_pin);
//light = (int)(light_measurement/4096*100);
// Publish data
Spark.publish("temperature", String(temperature) + " °C");
delay(2000);
Spark.publish("humidity", String(humidity) + "%");
delay(2000);
//Spark.publish("light", String(light) + "%");
//delay(2000);
}
``` This is my code..