-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.ino
76 lines (60 loc) · 1.62 KB
/
code.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_FeatherOLED.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>
Adafruit_FeatherOLED oled = Adafruit_FeatherOLED();
#define DHTPIN 2
#define DHTTYPE DHT22
DHT_Unified dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
oled.init();
oled.setBatteryVisible(true);
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();
delay(1);
Serial.println("");
Serial.println("Temp and Humidity code, by Daniel Mruczynski 02/11/2018");
Serial.println("Pastebin link (if that still exists): pastebin.com/LCxzJyEZ");
}
void loop() {
Serial.println("");
oled.clearDisplay();
oled.setTextSize(1);
float battery = analogRead(A0);
// resistors are 220k and 940k
battery /= .1897;
battery /= 1024;
oled.setBattery(battery);
oled.renderBattery();
Serial.print(battery);
Serial.println(" V Battery Voltage");
oled.setTextSize(2);
oled.setCursor(0, 0);
sensors_event_t event;
dht.temperature().getEvent(&event);
Serial.print(event.temperature);
Serial.println(" Degrees C");
oled.print(event.temperature, 1);
oled.setTextSize(1);
oled.println("C");
oled.setCursor(0, 17);
oled.setTextSize(2);
dht.humidity().getEvent(&event);
Serial.print(event.relative_humidity);
Serial.println(" % Relative Humidity");
oled.print(event.relative_humidity, 1);
oled.setTextSize(1);
oled.println("%");
oled.setCursor(68, 23);
oled.print("BootyBotV2");
oled.display();
// ESP.deepSleep(1e6);
delay(1000);
}