#include <Wire.h>
#include <LiquidCrystal.h>
#include <WiFi.h>
#include <UniversalTelegramBot.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* telegramToken = "your-TELEGRAM-BOT-TOKEN";
const int proximitySensorPin = 5; // Replace with your actual pin
const int lcdRs = 14; // Replace with your actual pin
const int lcdEn = 12; // Replace with your actual pin
const int lcdD4 = 27; // Replace with your actual pin
const int lcdD5 = 26; // Replace with your actual pin
const int lcdD6 = 25; // Replace with your actual pin
const int lcdD7 = 33; // Replace with your actual pin
const int lcdCols = 16;
const int lcdRows = 2;
const unsigned long regularityCheckInterval = 120000; // 2 minutes in milliseconds
const unsigned long breakdownCheckInterval = 300000; // 5 minutes in milliseconds
LiquidCrystal lcd(lcdRs, lcdEn, lcdD4, lcdD5, lcdD6, lcdD7);
WiFiClient client; // Change to WiFiClient for ESP32
UniversalTelegramBot bot(telegramToken, client);
unsigned long lastRegularityCheckTime = 0;
unsigned long lastBreakdownCheckTime = 0;
unsigned long strokeCount = 0;
void setup() {
Serial.begin(115200);
lcd.begin(lcdCols, lcdRows);
connectToWiFi();
}
void loop() {
handleStrokes();
checkRegularity();
checkBreakdown();
}
void connectToWiFi() {
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}
void handleStrokes() {
// Code to read from proximity sensor and increment strokeCount
// Update the LCD display with strokeCount
}
void checkRegularity() {
unsigned long currentTime = millis();
if (currentTime - lastRegularityCheckTime >= regularityCheckInterval) {
// Check regularity and send data to Telegram
// Reset the timer
lastRegularityCheckTime = currentTime;
}
}
void checkBreakdown() {
unsigned long currentTime = millis();
if (currentTime - lastBreakdownCheckTime >= breakdownCheckInterval) {
// Check breakdown and send data to Telegram
// Reset the timer
lastBreakdownCheckTime = currentTime;
}
}