Конфиг для OpenHAB. Добавил дисплей с отображением текущих показателей
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ModbusIP_ESP8266.h>
|
#include <ModbusIP_ESP8266.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "rgb_lcd.h"
|
||||||
|
|
||||||
#define TCP_PORT 15000
|
#define TCP_PORT 15000
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
|
|
||||||
ModbusIP mb;
|
ModbusIP mb;
|
||||||
DHT dht(DHTPIN, DHTTYPE);
|
DHT dht(DHTPIN, DHTTYPE);
|
||||||
|
rgb_lcd lcd;
|
||||||
|
|
||||||
char id[64];
|
char id[64];
|
||||||
|
|
||||||
@@ -41,6 +43,9 @@ void setup()
|
|||||||
pinMode(D4, OUTPUT);
|
pinMode(D4, OUTPUT);
|
||||||
pinMode(DHTPIN, INPUT);
|
pinMode(DHTPIN, INPUT);
|
||||||
pinMode(A0, INPUT);
|
pinMode(A0, INPUT);
|
||||||
|
|
||||||
|
lcd.begin(16, 2);
|
||||||
|
lcd.setRGB(0, 255, 0);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Initialized...");
|
Serial.println("Initialized...");
|
||||||
|
|
||||||
@@ -93,6 +98,28 @@ void UpdateSensorData()
|
|||||||
cur_p = (int)(((p_volt / 2.5f) * 10) * 100);
|
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()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long current = millis();
|
unsigned long current = millis();
|
||||||
@@ -135,6 +162,7 @@ void loop()
|
|||||||
mb.Hreg(REGISTER_CURRENT_TEMP, cur_t);
|
mb.Hreg(REGISTER_CURRENT_TEMP, cur_t);
|
||||||
mb.Hreg(REGISTER_CURRENT_HUM, cur_hum);
|
mb.Hreg(REGISTER_CURRENT_HUM, cur_hum);
|
||||||
mb.Hreg(REGISTER_CURRENT_PRESS, cur_p);
|
mb.Hreg(REGISTER_CURRENT_PRESS, cur_p);
|
||||||
|
UpdateDisplay();
|
||||||
if (WiFi.status() != WL_CONNECTED)
|
if (WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
// no wifi
|
// no wifi
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Number Well_P_on "Well turn on pressure [%.2f]" {channel="modbus:data:Well:W:Well_P_on:number"}
|
||||||
|
Number Well_P_off "Well turn off temperature [%.2f]" {channel="modbus:data:Well:W:Well_P_off:number"}
|
||||||
|
Number Well_P "Well current pressure [%.2f]" <temperature> {channel="modbus:data:Well:W:Well_P:number"}
|
||||||
|
Number Well_Temp "Well temperature [%.1f °C]" <temperature> {channel="modbus:data:Well:W:Well_Temp:number"}
|
||||||
|
Number Well_Hum "Well humidity [%.1f%%]" <humidity> {channel="modbus:data:Well:W:Well_Hum:number"}
|
||||||
|
Number Well_Mode "Well mode" <switch> {channel="modbus:data:Well:W:Well_Mode:number"}
|
||||||
|
Switch Well_State "Well state" <switch> {channel="modbus:data:Well:W:Well_State:switch"}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
Bridge modbus:tcp:Well [ host="192.168.0.24", port=15000, id=1 ] {
|
||||||
|
Bridge poller W[start = 0, length = 7, type = "holding", refresh = 500] {
|
||||||
|
Thing data Well_Temp[readStart = "0", readValueType = "int16", readTransform="JS(divide100.js)"]
|
||||||
|
Thing data Well_Hum[readStart = "1", readValueType = "int16", readTransform="JS(divide100.js)"]
|
||||||
|
Thing data Well_P[readStart = "2", readValueType = "int16", readTransform="JS(divide100.js)"]
|
||||||
|
Thing data Well_State[readStart = "3", readValueType = "int16", writeStart="3", writeValueType="int16", writeType="holding"]
|
||||||
|
Thing data Well_Mode[readStart = "4", readValueType = "int16", writeStart="4", writeValueType="int16", writeType="holding"]
|
||||||
|
Thing data Well_P_on[readStart = "5", readValueType = "int16", readTransform="JS(divide100.js)", writeStart="5", writeValueType="int16", writeTransform="JS(multiply100.js)", writeType="holding"]
|
||||||
|
Thing data Well_P_off[readStart = "6", readValueType = "int16", readTransform="JS(divide100.js)", writeStart="6", writeValueType="int16", writeTransform="JS(multiply100.js)", writeType="holding"]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user