Untitled
unknown
plain_text
a year ago
1.5 kB
18
Indexable
#include <WiFi.h> #include <WiFiClientSecure.h> #include <UniversalTelegramBot.h> #define SOUND_SENSOR_PIN 32 #define BUZZER_PIN 26 #define POWER_PIN 35 #define AO_PIN 36 #define BOTtoken "7132242773:AAG0qpH93vDeoVJ7pCVuBq6TzqN5O8f_XRA" #define CHAT_ID "5909482186" const char* ssid = "deedoodaabrr"; const char* password = "divya_123"; int lastState = HIGH; int currentState; int count = 0; WiFiClientSecure client; UniversalTelegramBot bot(BOTtoken, client); void setup() { Serial.begin(9600); pinMode(SOUND_SENSOR_PIN, INPUT); pinMode(BUZZER_PIN, OUTPUT); pinMode(POWER_PIN, OUTPUT); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); client.setCACert(TELEGRAM_CERTIFICATE_ROOT); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { currentState = digitalRead(SOUND_SENSOR_PIN); if (lastState == HIGH && currentState == LOW) bot.sendMessage(CHAT_ID, "Noise detected from the cradle. Is the baby crying?"); lastState = currentState; digitalWrite(POWER_PIN, HIGH); delay(10); int rain_value = analogRead(AO_PIN); digitalWrite(POWER_PIN, LOW); if(rain_value < 80){ for (int i = 0; i < 3; i++) { digitalWrite(BUZZER_PIN, HIGH); delay(100); digitalWrite(BUZZER_PIN, LOW); delay(100); } bot.sendMessage(CHAT_ID, "Wetness detected in the cradle."); } }
Editor is loading...
Leave a Comment