Hi Pros! 8)
I would like to ask for your help.
I created a monitoring system for my boiler.
One ESP8266, 5 sensors (DS18B20) and one display (SSD1283A).
Only display values if the PRI sensor detects movement so that the characters do not burn into it.
There’s something wrong here, because there are times when it works well for a day, but there are times when, even an hour later, when it turns on, I only see a blank white image. :o
I tried the mylcd.Init_LCD() function every time it detects a movement, but it didn't help either.
Could there be some buffer that overflows?
Or is it necessary to delete and redisplay the data differently?
Does anyone have an idea?
The source code is a bit long (1500 lines) so I just copy the display part here (without WiFi, MQTT, Thingspeak).
Thanks for your help.
/* ESP8266 - DS18B20 - MQTT - ThingSpeak
SSD1283A display
CS A0 RST SDA MISO SCK LED
CD MOSI CLK
ESP8266 NodeMCU D8 D2 D6 D7 NONE D5 GPIO3 (RX, from A0)
PIR
ESP8266 5V pow.suppl.
GND GND GND
OUT A0
VCC +5V
DS18B20
ESP8266 5V pow.suppl.
GND GND
VCC +5V
DATA D4 (+3.3V 4.7 kOhm)
*/
#include "ThingSpeak.h"
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_SPI.h> //Hardware-specific library
#include <MQTTClient.h>
#include <NTPClient.h> // Include NTPClient library
#include <OneWire.h>
#include <SPI.h>
#include <TimeLib.h> // Include Arduino time library
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <Wire.h>
#define MODEL SSD1283A
#define CS D8
#define CD D2
#define RST D6
#define LED 3
// hardware SPI
LCDWIKI_SPI mylcd(MODEL, CS, CD, RST, LED); // hardware spi,cs,cd,reset,LED
// colors
#define BLACK 0x0000
#define WHITE 0xFFFF
#define RED 0xF800
// Data wire is plugged into port D4 on the Arduino ESP8266
#define ONE_WIRE_BUS D4
unsigned long lastMillis = 0;
unsigned long nextMillis = 10000; // check sensor time
byte OLED_BackLight = 3; // RX pin for backlight
byte PIR = A0;
unsigned int A0_value = 0;
bool movement = false;
int temp_hotwater = 0;
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress Sensor_hotwater = {0x28, 0x4E, 0xCB, 0x83, 0x33, 0x20, 0x01, 0xDE};
byte screen_rotate = 0; // Display orientation
void checkSensor() {
sensors.requestTemperatures(); // Send the command to get temperatures
temp_hotwater = sensors.getTempC(Sensor_hotwater);
A0_value = analogRead(PIR); // movement?
if (A0_value > 300) {
if (!movement) {
mylcd.Init_LCD();
digitalWrite(OLED_BackLight, HIGH); // backlight ON
}
mylcd.Set_Text_Size(1);
mylcd.Set_Text_colour(WHITE);
mylcd.Print_String("Hot water", 5, 25);
mylcd.Set_Text_Size(3);
mylcd.Set_Text_colour(RED);
mylcd.Print_Number_Int(temp_hotwater, 30, 35, 0, ' ', 10);
movement = true;
} else {
movement = false;
mylcd.Fill_Screen(BLACK);
digitalWrite(OLED_BackLight, LOW); // backlight OFF
}
Serial.print("Hot water °C: ");
Serial.println(temp_hotwater);
}
void setup() {
Serial.begin(115200);
while (!Serial) {
}
// Start up the sensor DS18B20library
sensors.begin();
pinMode(PIR, INPUT); // A0 - PIR
pinMode(OLED_BackLight, OUTPUT); // OLED backlight pin RX
digitalWrite(OLED_BackLight, HIGH); // backlight ON
mylcd.Init_LCD();
}
void loop() {
if (millis() - lastMillis > nextMillis) {
lastMillis = millis();
checkSensor();
}
}