forked from bartwo/esp32_p1meter
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate.settings.h
95 lines (76 loc) · 2.83 KB
/
template.settings.h
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
// Top controlling defines
// Uncomment for debugging
//#define DEBUG
// Uncomment for debug messages sent to mqtt
//#define MQTT_DEBUGGING
// Uncomment for testing
//#define TEST
// Main settings
#define HOSTNAME "p1_meter"
#define OTA_PASSWORD_HASH "MD5 hash of my password"
// WiFi settings
#define WIFI_SSID "MyWifi"
#define WIFI_PASS "MyWifiPassword"
// Comment out below define if you think WiFi connection is stable with any other power saving settings
#define TURN_OFF_WIFI_PS
#define WIFI_MAX_RECONNECT_TRIES 5
#define BAUD_RATE 115200
#define RXD2 16
#define TXD2 17
// Change LED_PIN definition to actual setup
//#define LED_PIN LED_BUILTIN
#define LED_PIN 32
// MQTT related settings
#define MQTT_HOST "homeassistant.local"
#define MQTT_PORT "1883"
#define MQTT_USER "mqtt"
#define MQTT_PASS "mqttpass"
#define MQTT_MAX_RECONNECT_TRIES 10
#define MQTT_ROOT_TOPIC "p1_meter/sensor"
#define MQTT_STATUS_TOPIC "p1_meter/status"
// Uncomment to restart ESP on MQTT errors.
// Be mindfull because this can make device unreachable if settings are wrong - restarting might cause infinite loop
// Uncomment only when MQTT settings are correct and server is reachable.
//#define MQTT_RESTART_ON_ERROR
#ifdef MQTT_DEBUGGING
#define MQTT_DEBUG_TOPIC "p1_meter/debug"
#endif
// Schedule of reading telegrams
// Update treshold in milliseconds, messages will only be sent on this interval
//#define UPDATE_INTERVAL 1000 // 1 second
//#define UPDATE_INTERVAL 30000 // 30 seconds
#define UPDATE_INTERVAL 60000 // 1 minute
//#define UPDATE_INTERVAL 300000 // 5 minutes
// Schedule of forced full telegram readout
// Update treshold in milliseconds,
// this will also send values that are more than the tresholds time the same
#define UPDATE_FULL_INTERVAL 600000 // 10 minutes
// #define UPDATE_FULL_INTERVAL 1800000 // 30 minutes
// #define UPDATE_FULL_INTERVAL 3600000 // 1 Hour
// Specify CPU frequenxy in MHz to reduce power usage
// 0, if frequency should be handled automatically using ArduinoIDE and board settings
// CAUTION: please make sure your CPU can handle frequency!
#define CPU_FREQ 80
// if your P1 values with units need to be multiplied by any multiplier, specify it here
#define VALUE_NUMERIC_MULTIPLIER 1
// Decimal places for float values, by default it's 2
// Integers are handled automatically and no decimals are used
#define VALUE_FLOAT_DECIMAL_PLACES 3
#define VALUE_START_CHAR '('
#define VALUE_END_CHAR '*'
#define VALUE_NO_UNITS_END_CHAR ')'
#define NA "N/A"
#define P1_MAXLINELENGTH 1100
// Nothing to change below - globals to make it all work as simple as possible
char telegram[P1_MAXLINELENGTH];
long LAST_UPDATE_SENT = 0;
long LAST_FULL_UPDATE_SENT = 0;
struct TelegramDecodedObject
{
String name;
String value;
char code[16];
bool sendData = true;
};
tc::vector<struct TelegramDecodedObject> telegramObjects;
unsigned int currentCRC = 0;