-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.ino
57 lines (47 loc) · 1.23 KB
/
temp.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
char auth[] = "SNIP";
const int ledPin = BUILTIN_LED; // the onboard LED
//Simple Uptime Monitor on V5
SimpleTimer timer;
void sendUptime()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
// End of Uptime
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "SNIP", "SNIP");
pinMode(ledPin, OUTPUT); // initialize onboard LED as output
// Setup a function to be called every second
timer.setInterval(1000L, sendUptime);
// TEMP TEST
dht.begin();
float h = dht.readHumidity();
float t = dht.readTemperature();
Blynk.virtualWrite(1, t); // virtual pin temperature app Value
Blynk.virtualWrite(2, h); // virtual pin humidity app Value
Serial.print(t);
Serial.print(h);
}
BLYNK_WRITE(V10)
{
Serial.print("Got a value: ");
Serial.println(param.asStr());
int brightness = param.asInt();
analogWrite(ledPin, brightness);
}
void loop()
{
Blynk.run();
timer.run();
}