Skip to content

Commit 26f6826

Browse files
committed
add temperature sensor
1 parent 6ffc028 commit 26f6826

File tree

31 files changed

+3805
-340
lines changed

31 files changed

+3805
-340
lines changed

DotMatrixDisplay/DotMatrixDisplay.ino

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@
4242
#include <TimeLib.h>
4343
#include <NtpClientLib.h>
4444

45+
#include <OneWire.h>
46+
#include <DallasTemperature.h>
47+
4548
// DOT MATRIX PIN configuration
4649
#define MAX_DEVICES 4
4750
#define CLK_PIN D5 // or SCK
4851
#define DATA_PIN D7 // or MOSI
4952
#define CS_PIN D6 // or SS
5053

51-
54+
#define DS18B20BUS D1 // OneWire Dallas PIN
55+
OneWire oneWire(DS18B20BUS);
56+
DallasTemperature DS18B20(&oneWire);
57+
char temperatureCString[6];
58+
char temperatureFString[6];
5259

5360
#define TIMEOUT_PORTAL 10
5461
uint8_t messageType = 0;
@@ -64,7 +71,18 @@ ESP8266WebServer server (80);
6471
//MD_Parola Parola = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); // HARDWARE SPI for dot matrix display
6572
MD_Parola Parola = MD_Parola(CS_PIN, MAX_DEVICES); // HARDWARE SPI for dot matrix display
6673

67-
74+
void getTemperature() {
75+
float tempC;
76+
float tempF;
77+
do {
78+
DS18B20.requestTemperatures();
79+
tempC = DS18B20.getTempCByIndex(0);
80+
dtostrf(tempC,2,2,temperatureCString);
81+
tempF = DS18B20.getTempFByIndex(0);
82+
dtostrf(tempF,3,2,temperatureFString);
83+
delay(100);
84+
} while (tempC==85.0 || tempC==(-127.0));
85+
}
6886

6987
uint8_t utf8Ascii(uint8_t ascii)
7088
// Convert a single Character from UTF8 to Extended ASCII according to ISO 8859-1,
@@ -242,6 +260,9 @@ void setup() {
242260
#if USE_DEBUG
243261
Serial.begin(115200);
244262
#endif
263+
264+
// Start DS18B20 measurement
265+
DS18B20.begin();
245266

246267
//pinMode(LED_BUILTIN,OUTPUT); // configure the builtin led to OUTPUT mode
247268
//digitalWrite(LED_BUILTIN,!digitalRead(pin_led)); // switch the status (values can be LOW or HIGH)
@@ -363,7 +384,8 @@ void loop() {
363384
break;
364385
// Looping message
365386
case 10:
366-
Parola.displayScroll("voila un é et un à", PA_LEFT, PA_SCROLL_LEFT, frameDelay);
387+
getTemperature();
388+
Parola.displayText(temperatureCString, PA_CENTER, 20, 500, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
367389
messageType=0;
368390
break;
369391
}

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ I use it to print usefull messages from my home automation solution (jeedom).
77

88
* ESP8266 (mine is Wemos D1 NodeMcu ESP12F
99
* DOT Matrix based on MAX7219
10-
* OLED display (SSD1306 and SH1106 based 128x64 pixel) - not mandatory
10+
* OLED display (SSD1306 and SH1106 based 128x64 pixel) - optional
11+
* Temperature sensor DS18B20 - optional
12+
* Light sensor GL5516 - optional
1113

1214
### Features
1315
* Display message by using simple http remote command (GET URL)
14-
* Read a file to display text
16+
* NTP client for date and time
17+
* Temperature measurement
18+
* LED matrix dimming based on light sensor
19+
* Read a file to display text (TODO)
1520
* more to come
1621

1722
### Usage

demo_text/demo_text.ino

Lines changed: 0 additions & 222 deletions
This file was deleted.

0 commit comments

Comments
 (0)