7
7
*******************************************************************/
8
8
#include < ESP8266WiFi.h>
9
9
#include < WiFiClientSecure.h>
10
- #include < TimeLib.h>
11
- #include < WiFiUdp.h>
12
- #include < ArduinoJson.h>
13
- #include " FS.h"
14
- #include < AccelStepper.h>
15
- #include " DHT.h"
16
- #include < ArduinoOTA.h>
17
10
#include < UniversalTelegramBot.h>
18
11
19
12
// Initialize Wifi connection to the router
20
- char ssid[] = " 1a3496 " ; // your network SSID (name)
21
- char password[] = " 278833924 " ; // your network key
13
+ char ssid[] = " XXXXXX " ; // your network SSID (name)
14
+ char password[] = " YYYYYY " ; // your network key
22
15
23
16
// Initialize Telegram BOT
24
- #define BOTtoken " 326858637:AAGDZGkaKP_Vrhzs8mkd--0BnGQQ6AioF4M " // your Bot Token (Get off Botfather)
17
+ #define BOTtoken " XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " // your Bot Token (Get from Botfather)
25
18
26
19
WiFiClientSecure client;
27
20
UniversalTelegramBot bot (BOTtoken, client);
@@ -33,78 +26,6 @@ bool Start = false;
33
26
const int ledPin = 13 ;
34
27
int ledStatus = 0 ;
35
28
36
-
37
-
38
-
39
- // PINS SETUP
40
- #define REED_WINDOW_CLOSED D1
41
- #define REED_WINDOW_MAX_OPEN D2
42
- #define STEPPER_DRIVER_ON_OFF D3
43
- #define DHTPIN D7
44
- #define RESET_CONFIG_BUTTON D8
45
-
46
- // TEMP SETUP
47
- #define DHTTYPE DHT22
48
-
49
- String apiKey = " xxxxxxxxxxxxx" ;
50
- const char * statistic_server = " api.thingspeak.com" ;
51
-
52
- int wifi_connect_tries = 0 ;
53
-
54
- const int is_in_office = 0 ;
55
- const int is_in_dev_room = 0 ;
56
-
57
- // sleep for this many seconds
58
- const int sleepSeconds = 10 ;
59
-
60
- AccelStepper Stepper1 (1 ,D5,D6);
61
- WiFiServer server (80 );
62
-
63
- String setup_log = " " ;
64
- String loop_log = " " ;
65
-
66
- // NTP Servers:
67
- static const char ntpServerName[] = " us.pool.ntp.org" ;
68
- // static const char ntpServerName[] = "time.nist.gov";
69
- // static const char ntpServerName[] = "time-a.timefreq.bldrdoc.gov";
70
- // static const char ntpServerName[] = "time-b.timefreq.bldrdoc.gov";
71
- // static const char ntpServerName[] = "time-c.timefreq.bldrdoc.gov";
72
-
73
- const int timeZone = 2 ; // Central European Time
74
-
75
- WiFiUDP Udp;
76
- unsigned int localPort = 8888 ; // local port to listen for UDP packets
77
-
78
- time_t getNtpTime ();
79
- void digitalClockDisplay ();
80
- void printDigits (int digits);
81
- void sendNTPpacket (IPAddress &address);
82
-
83
- DHT dht (DHTPIN, DHTTYPE);
84
-
85
- int automatic_mode = 1 ;
86
- float current_window_degree = 0 ;
87
- int automatic_window_step = 2 ; // degrees
88
- int dir_open = -1 ;
89
- int dir_close = 1 ;
90
-
91
- int keep_temp_cold_room = 23 ; // (+-1)
92
- time_t last_motor_action;
93
-
94
- bool motor_working = false ;
95
- String current_motor_action = " " ;
96
- bool debug = false ;
97
- bool config_found = true ;
98
- bool closing_window_config_not_found = false ;
99
- bool need_redirect_to_main_page = false ;
100
-
101
- String s = " LOG" ;
102
-
103
- bool sketch_updating = false ;
104
-
105
-
106
-
107
-
108
29
void handleNewMessages (int numNewMessages) {
109
30
Serial.println (" handleNewMessages" );
110
31
Serial.println (String (numNewMessages));
@@ -129,33 +50,11 @@ void handleNewMessages(int numNewMessages) {
129
50
}
130
51
131
52
if (text == " /status" ) {
132
- String file_content = " Ninja\n\n " ;
133
-
134
- file_content += " mode - Change mode (automatic or manual)\n " ;
135
-
136
- file_content += " open_window_1 - Open window by 1 degrees\n " ;
137
- file_content += " open_window_3 - Open window by 3 degrees\n " ;
138
- file_content += " open_window_5 - Open window by 5 degrees\n " ;
139
- file_content += " open_window_10 - Open window by 10 degrees\n\n " ;
140
-
141
- file_content += " close_window_1 - Close window by 1 degrees\n " ;
142
- file_content += " close_window_3 - Close window by 3 degrees\n " ;
143
- file_content += " close_window_5 - Close window by 5 degrees\n " ;
144
- file_content += " close_window_10 - Close window by 10 degrees\n\n " ;
145
-
146
- file_content += " mode - Change mode (automatic or manual)\n\n " ;
147
-
148
- file_content += " open_window_1 - Open window by 1 degrees\n " ;
149
- file_content += " open_window_3 - Open window by 3 degrees\n " ;
150
- file_content += " open_window_5 - Open window by 5 degrees\n " ;
151
- file_content += " open_window_10 - Open window by 10 degrees\n\n " ;
152
-
153
- file_content += " close_window_1 - Close window by 1 degrees\n " ;
154
- file_content += " close_window_3 - Close window by 3 degrees\n " ;
155
- file_content += " close_window_5 - Close window by 5 degrees\n " ;
156
- file_content += " close_window_10 - Close window by 10 degrees" ;
157
-
158
- bot.sendMessage (chat_id, file_content);
53
+ if (ledStatus){
54
+ bot.sendMessage (chat_id, " Led is ON" , " " );
55
+ } else {
56
+ bot.sendMessage (chat_id, " Led is OFF" , " " );
57
+ }
159
58
}
160
59
161
60
if (text == " /start" ) {
0 commit comments