-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeLED.ino
More file actions
50 lines (39 loc) · 1.08 KB
/
CodeLED.ino
File metadata and controls
50 lines (39 loc) · 1.08 KB
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
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>
const char* ssid = "KDH-Oben";
const char* password = "37069675001749482983543253248675239560236747302934";
#define BOTtoken "5579709306:AAE8lXyiQSURHyJf_u1rIXGxlBmQQwJowpEBBUEMDOSBBD"
#define CHAT_ID "813019446"
X509List cert(TELEGRAM_CERTIFICATE_ROOT);
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);
int licht = 0;
int LED = 2;
void setup() {
Serial.begin(9600);
configTime(0, 0, "pool.ntp.org");
client.setTrustAnchors(&cert);
pinMode(LED,OUTPUT);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
digitalWrite(LED,HIGH);
delay(1000);
digitalWrite(LED,LOW);
bot.sendMessage(CHAT_ID, "Briefsensor aktiv", "");
}
void loop() {
licht = analogRead(A0);
Serial.print ("Lichtwert: ");
Serial.println(licht);
delay(1000);
if(licht > 100){
bot.sendMessage(CHAT_ID, "Es wurde ein Brief eingeworfen", "");
delay(60000);
}
}