#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int potPin = A0; // Pin analog untuk potensiometer
const int lcdAddress = 0x27; // I2C address for the LCD module
const int lcdCols = 16; // Number of columns on the LCD
LiquidCrystal_I2C lcd(lcdAddress, lcdCols, 2); // Initialize the LCD
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const char* botToken = "6407333264:AAE4kwJgA2hlV2BJjna_3pEX7uFNDbAJfLE";
const int chatId = "1394940319";
// Simulated UniversalTelegramBot
class UniversalTelegramBot {
public:
UniversalTelegramBot(const char* token) {}
bool sendMessage(int chatId, const String& text, const String& options) {
Serial.print("Simulated Telegram Message: ");
Serial.println(text);
return true; // Simulated success
}
};
UniversalTelegramBot bot(botToken);
void setup() {
Serial.begin(9600);
lcd.begin(lcdCols, 2); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
// Simulated Wi-Fi connection
Serial.println("Connecting to Wi-Fi (simulated)");
delay(2000);
Serial.println("Connected to Wi-Fi (simulated)");
}
void loop() {
int sensorValue = analogRead(potPin);
// Ubah nilai analog menjadi rentang kecepatan angin yang diinginkan
int windSpeed = map(sensorValue, 0, 1023, 0, 100);
// Tampilkan nilai kecepatan angin pada Serial Monitor
Serial.print("Wind Speed: ");
Serial.print(windSpeed);
Serial.println(" mph");
// Tampilkan nilai kecepatan angin pada LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Wind Speed:");
lcd.setCursor(0, 1);
lcd.print(windSpeed);
lcd.print(" mph");
// Kirim nilai kecepatan angin ke Telegram
sendToTelegram(windSpeed);
delay(1000); // Tunggu satu detik
}
void sendToTelegram(int windSpeed) {
String message = "Wind Speed: " + String(windSpeed) + " mph";
bot.sendMessage(chatId, message, "");
}