Конфиг для OpenHAB. Добавил дисплей с отображением текущих показателей

This commit is contained in:
ftc
2022-06-22 23:34:53 +03:00
parent 652b94d0c7
commit 859095319d
3 changed files with 46 additions and 0 deletions
+28
View File
@@ -2,6 +2,7 @@
#include <ESP8266WiFi.h>
#include <ModbusIP_ESP8266.h>
#include "config.h"
#include "rgb_lcd.h"
#define TCP_PORT 15000
@@ -23,6 +24,7 @@
ModbusIP mb;
DHT dht(DHTPIN, DHTTYPE);
rgb_lcd lcd;
char id[64];
@@ -41,6 +43,9 @@ void setup()
pinMode(D4, OUTPUT);
pinMode(DHTPIN, INPUT);
pinMode(A0, INPUT);
lcd.begin(16, 2);
lcd.setRGB(0, 255, 0);
Serial.begin(115200);
Serial.println("Initialized...");
@@ -93,6 +98,28 @@ void UpdateSensorData()
cur_p = (int)(((p_volt / 2.5f) * 10) * 100);
}
void UpdateDisplay()
{
lcd.setCursor(0, 0);
lcd.print("P: ");
lcd.print((cur_p / 100.0), 2);
lcd.print(" T: ");
lcd.print((cur_t / 100.0), 1);
lcd.setCursor(0, 1);
lcd.print("H: ");
lcd.print(cur_hum / 100);
// print current error
//
if (cur_state)
{
lcd.setRGB(0, 0, 255);
}
else
{
lcd.setRGB(0, 255, 0);
}
}
void loop()
{
unsigned long current = millis();
@@ -135,6 +162,7 @@ void loop()
mb.Hreg(REGISTER_CURRENT_TEMP, cur_t);
mb.Hreg(REGISTER_CURRENT_HUM, cur_hum);
mb.Hreg(REGISTER_CURRENT_PRESS, cur_p);
UpdateDisplay();
if (WiFi.status() != WL_CONNECTED)
{
// no wifi