为什么图表一直处于零,帮帮忙改一下吗
#define DHT11_Pin 0//D3#define RS 16 //D6
#define EN 5 //D5
#define LCD_D4 4 //D4
#define LCD_D5 14 //D7
#define LCD_D6 12 //D8
#define LCD_D7 13 //D9
#define Motor_Pin 15 //D10
#define BLINKER_WIFI
#define DHTTYPE DHT11
#include <Blinker.h>
#include <EduIntro.h>
#include <LiquidCrystal.h>
int Temp = 0;
int Humi = 0;
unsigned long times = 0;
float humi = 0, temp = 0;
char auth[] = ""; //设备安全密钥
char ssid[] = "";
char pswd[] = "";
DHT11 dht11(DHT11_Pin);
LiquidCrystal lcd(RS, EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
BlinkerButton Button1("motor");
BlinkerNumber Number1("temp");
BlinkerNumber Number2("humi");
void button1_callback(const String &state)
{
Number1.print(Temp);
Number2.print(Humi);
BLINKER_LOG("get button state: ", state);
if (state == BLINKER_CMD_ON)
{
BLINKER_LOG("Toggle on!");
Button1.color("#FF0000");
Button1.print("on");
digitalWrite(Motor_Pin, HIGH);
}
else if (state == BLINKER_CMD_OFF)
{
BLINKER_LOG("Toggle off!");
Button1.color("#000000");
Button1.print("off");
digitalWrite(Motor_Pin, LOW);
}
}
void heartbeat()
{
Number1.print(Temp);
Number2.print(Humi);
}
void dataStorage()
{
Blinker.dataStorage("temp", temp);
Blinker.dataStorage("humi", humi);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(Motor_Pin, OUTPUT);
digitalWrite(Motor_Pin, LOW);
lcd.begin(16,2);
Button1.print("off");
Button1.color("#000000");
Blinker.begin(auth, ssid, pswd);
Button1.attach(button1_callback);
Blinker.attachHeartbeat(heartbeat);
Blinker.attachDataStorage(dataStorage);
}
void loop()
{
Blinker.run();
if (millis() - times >= 2000)
{
dht11.update();
Temp = dht11.readCelsius();
Humi = dht11.readHumidity();
Serial.print("H: ");
Serial.print(Humi);
Serial.print("\tC: ");
Serial.println(Temp);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp:");
lcd.print(Temp);
lcd.setCursor(0,1);
lcd.print("Huim:");
lcd.print(Humi);
if(Temp>26)
{
digitalWrite(Motor_Pin,HIGH);
}
else
{
digitalWrite(Motor_Pin,LOW);
}
}
}
int Temp = 0;
int Humi = 0;
unsigned long times = 0;
float humi = 0, temp = 0;
你上传的是小写的变量,确实就是0,所以显示也是0 本帖最后由 sbt147 于 2019-12-3 15:43 编辑
coloz 发表于 2019-12-3 13:14
int Temp = 0;
int Humi = 0;
unsigned long times = 0;
好了,改成功了
页:
[1]