#include <ESP8266WiFi.h>
#include <UniversalTelegramBot.h>
// WiFi settings
const char* ssid = "Dua Cakra";
const char* password = "corazon777";
// Telegram settings
const char* telegramToken = "5992106882:AAFONXAkytzl5uF8-FDEai47tpvhV5M7g5Y";
int telegramChatId = 1858267482;
// Initialize WiFi and Telegram objects
WiFiClientSecure client;
UniversalTelegramBot bot(telegramToken, client);
void setup() {
// Connect to WiFi
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting...");
}
Serial.println("WiFi connected");
// Print local IP address
Serial.println(WiFi.localIP());
}
// Print local IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check for incoming messages
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
// Process each incoming message
for (int i = 0; i < numNewMessages; i++) {
String chat_id = String(bot.messages[i].chat_id);
String text = bot.messages[i].text;
// Send a reply to the message
bot.sendMessage(chat_id, "Received your message: " + text);
}
// Send a message to the chat
bot.sendMessage(telegramChatId, "Hello from Arduino!");
// Wait for 5 seconds before sending another message
delay(5000);
}
Loading
esp32-c3-rust-1
esp32-c3-rust-1