|
#define BLINKER_WIFI
#define BLINKER_ESP_SMARTCONFIG
#include <Blinker.h> //官方库
#include "MQ135.h"
char auth[] = "********";
int motor = D2;
int ANALOGPIN = A0;
MQ135 gasSensor = MQ135(ANALOGPIN);
void setup() {
Serial.begin(250000); // sets the serial port to 115200
BLINKER_DEBUG.stream(Serial);
Blinker.begin(auth);
pinMode(motor, OUTPUT); //设置IO脚模式,OUTPUT为输出
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
Blinker.attachAQI(aqiData);
}
void loop()
{
float ppm = gasSensor.getPPM();
Serial.println(ppm);
if (ppm > 50)
digitalWrite(motor, HIGH); //发声音
else
digitalWrite(motor, LOW); //关闭声音
delay(1000);
}
|
|