-
Notifications
You must be signed in to change notification settings - Fork 1
/
ESP32Pro_SHT30_ePaper.ino
204 lines (186 loc) · 11.5 KB
/
ESP32Pro_SHT30_ePaper.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Programm to measure the Temperature (Temp) and Humidity (Humi) with
* LOLIN WEMOS SHT30 and display the values on a
* LOLIN WEMOS 2.13 Inch e-Paper display.
* Uses a LOLIN D32 Pro Board.
*
* Features & Notes:
* 1) Digits are predefined by unsigned char-arrays like I_zero[128] for the use
* of (LOLIN_EPD)-partDisplay as a 32x32 bitmap.
* By using the new partDisplay and partUpdate funktion there is no flashing!
* 2) All digits (graficbitmaps) are in another array Number[]
* 3) The measured values are updated digitwise.
*/
#include <LOLIN_EPD.h>
#include <Adafruit_GFX.h>
#include <Wire.h> // SHTSensor
#include "SHTSensor.h" // SHT Sensor
const unsigned char I_Zero[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfc, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0xff, 0xff, 0x87, 0xe1, 0xff, 0xff, 0x83,
0xe1, 0xff, 0xff, 0x83, 0xe1, 0xff, 0xff, 0x87, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x0f, 0xfc, 0x00, 0x00, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_One[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff,
0xfe, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Two[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x0f, 0xff, 0x87, 0xf8, 0x0f, 0xfc, 0x07, 0xf0, 0x0f, 0xf8, 0x07, 0xe0, 0x0f, 0xe0, 0x07,
0xe0, 0x0f, 0xc0, 0x07, 0xe0, 0x1f, 0x80, 0x07, 0xe0, 0xff, 0x00, 0x07, 0xe1, 0xfe, 0x01, 0x07,
0xe1, 0xfc, 0x03, 0x07, 0xe1, 0xf8, 0x07, 0x07, 0xe0, 0x00, 0x0f, 0x07, 0xe0, 0x00, 0x1f, 0x07,
0xe0, 0x00, 0x3f, 0x07, 0xf0, 0x00, 0x7f, 0x07, 0xf0, 0x00, 0xff, 0x07, 0xfc, 0x03, 0xff, 0x07,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Tree[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfc, 0x1f, 0xf0, 0x3f, 0xf8, 0x1f, 0xf0, 0x1f, 0xf0, 0x1f, 0xf0, 0x0f, 0xe0, 0x1f, 0xf0, 0x07,
0xe0, 0x1f, 0xf0, 0x07, 0xe0, 0x7c, 0x3e, 0x07, 0xe1, 0xf8, 0x3f, 0x87, 0xe1, 0xf8, 0x3f, 0x87,
0xe1, 0xf8, 0x3f, 0x87, 0xe0, 0xf0, 0x1f, 0x87, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xf0, 0x03, 0x00, 0x0f, 0xf8, 0x07, 0x80, 0x1f, 0xfe, 0x1f, 0xc0, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Four[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0x80, 0xff, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xf8, 0x00, 0xff, 0xff, 0xe0, 0x00, 0xff,
0xff, 0xc0, 0x20, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xfc, 0x03, 0xe0, 0xff, 0xf0, 0x07, 0xe0, 0xff,
0xe0, 0x1f, 0xe0, 0xff, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0xff,
0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Five[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xe0, 0x78, 0x7f, 0xe0, 0x00, 0x38, 0x1f, 0xe0, 0x00, 0x38, 0x0f, 0xe0, 0x00, 0x38, 0x07,
0xe0, 0x00, 0x38, 0x07, 0xe0, 0xf0, 0x78, 0x07, 0xe0, 0xf0, 0xff, 0x07, 0xe0, 0xf1, 0xff, 0x87,
0xe0, 0xe1, 0xff, 0x87, 0xe0, 0xe0, 0xff, 0x87, 0xe0, 0xe0, 0x3c, 0x07, 0xe0, 0xe0, 0x00, 0x07,
0xe0, 0xf0, 0x00, 0x07, 0xe0, 0xf0, 0x00, 0x0f, 0xe0, 0xf8, 0x00, 0x1f, 0xff, 0xfc, 0x00, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Six[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x00, 0x1f, 0xf0, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0xf8, 0x7f, 0x07, 0xe1, 0xf8, 0xff, 0x87,
0xe1, 0xf0, 0xff, 0x87, 0xe1, 0xf0, 0x7f, 0x87, 0xe0, 0x70, 0x3e, 0x07, 0xe0, 0x70, 0x00, 0x07,
0xe0, 0x70, 0x00, 0x07, 0xf0, 0x78, 0x00, 0x0f, 0xf0, 0x78, 0x00, 0x1f, 0xfc, 0x7e, 0x00, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Seven[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xe0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0x87,
0xe0, 0xff, 0xfc, 0x07, 0xe0, 0xff, 0xc0, 0x07, 0xe0, 0xfe, 0x00, 0x07, 0xe0, 0xf8, 0x00, 0x07,
0xe0, 0xe0, 0x00, 0x07, 0xe0, 0x80, 0x00, 0x0f, 0xe0, 0x00, 0x03, 0xff, 0xe0, 0x00, 0x7f, 0xff,
0xe0, 0x03, 0xff, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Eight[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfc, 0x0f, 0x80, 0x3f, 0xf8, 0x03, 0x00, 0x1f, 0xf0, 0x02, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xe0, 0x60, 0x1e, 0x07, 0xe1, 0xf8, 0x3f, 0x87, 0xe1, 0xf8, 0x7f, 0x87,
0xe1, 0xf8, 0x7f, 0x87, 0xe0, 0xf0, 0x3f, 0x87, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xf0, 0x03, 0x00, 0x0f, 0xf8, 0x07, 0x80, 0x1f, 0xfe, 0x0f, 0xc0, 0x7f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char I_Nine[128] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x00, 0xfe, 0xff, 0xf8, 0x00, 0x3e, 0x1f, 0xf0, 0x00, 0x1e, 0x0f, 0xe0, 0x00, 0x1e, 0x07,
0xe0, 0x00, 0x0e, 0x07, 0xe0, 0x00, 0x0e, 0x07, 0xe0, 0xfe, 0x0f, 0x07, 0xe1, 0xff, 0x0f, 0x87,
0xe1, 0xff, 0x0f, 0x87, 0xe1, 0xfe, 0x1f, 0x87, 0xe0, 0x7c, 0x0e, 0x07, 0xe0, 0x00, 0x00, 0x07,
0xe0, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
const unsigned char *Number[]={I_Zero, I_One, I_Two, I_Tree, I_Four, I_Five, I_Six, I_Seven, I_Eight, I_Nine};
/*D32 Pro*/
#define EPD_CS 14
#define EPD_DC 27
#define EPD_RST 33 // can set to -1 and share with microcontroller Reset!
#define EPD_BUSY -1 // can set to -1 to not use a pin (will wait a fixed delay)
LOLIN_IL3897 EPD(250, 122, EPD_DC, EPD_RST, EPD_CS, EPD_BUSY); //hardware SPI
// int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY
SHTSensor sht; // Temperatursensor or sht(SHTSensor::SHT3X);
void setup()
{
Serial.begin(115200);
Wire.begin();
if (sht.init()) {
Serial.println("Sensor initialized");
} else {
Serial.println("Sensor initialization failed");
}
sht.setAccuracy(SHTSensor::SHT_ACCURACY_MEDIUM); // only supported by SHT3x
delay(200);
EPD.begin();
EPD.clearBuffer();
// EPD.setTextWrap(true);
EPD.setTextSize(3);
EPD.setTextColor(EPD_BLACK);
EPD.setCursor(10, 18); // 10 to the right and 18 down
EPD.print("Temp:");
EPD.setCursor(177, 18); // 177 to the right and 18 down
EPD.print(". C");
EPD.setCursor(10, 58); // 10 to the right and 58 down
EPD.print("Humi:");
EPD.setCursor(177, 58); // 177 to the right and 58 down
EPD.print(". %");
EPD.partInit();
delay(100);
}
void loop()
{
if (sht.readSample()) {
EPD.clearBuffer();
float temp = sht.getTemperature();
Serial.print(" T: ");
Serial.println(temp, 2);
int temp_zehner = static_cast<int>(temp/10);
int temp_einer = static_cast<int>(temp - temp_zehner*10);
int temp_zehntel = static_cast<int>((temp - static_cast<int>(temp)) * 10);
EPD.partDisplay(10, 125, Number[temp_zehner], 32, 32); // 10 down & 125 right
// EPD.partUpdate();
EPD.partDisplay(10, 100, Number[temp_einer], 32, 32);
EPD.partUpdate();
EPD.partDisplay(10, 60, Number[temp_zehntel], 32, 32);
EPD.partUpdate();
float humi = sht.getHumidity();
Serial.print(" H: ");
Serial.println(humi, 2);
int humi_zehner = static_cast<int>(humi/10);
int humi_einer = static_cast<int>(humi - humi_zehner*10);
int humi_zehntel = static_cast<int>((humi - static_cast<int>(humi)) * 10);
EPD.partDisplay(50, 125, Number[humi_zehner], 32, 32);
EPD.partUpdate();
EPD.partDisplay(50, 100, Number[humi_einer], 32, 32);
EPD.partUpdate();
EPD.partDisplay(50, 60, Number[humi_zehntel], 32, 32);
EPD.partUpdate();
} else {
Serial.println("Error in Measurement");
}
delay(1000);
}