Parcel Delivery Detection
Parcel Delivery Detection
Hardware Requirements:
1. NodeMCU ESP8266
2. Infrared sensor module (like IR proximity sensor)
3. Breadboard and jumper wires
4. 5V power supply (from NodeMCU or external source)
Hardware Connections:
void setup() {
Serial.begin(115200);
pinMode(irSensorPin, INPUT);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi...");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("\nWiFi connected!");
}
void loop() {
if (digitalRead(irSensorPin) == LOW) { // Assuming LOW is when an object is detected
sendTelegramMessage("Parcel detected in your post box!");
delay(5000); // Wait for 5 seconds to avoid multiple notifications for the same detection
}
}
HTTPClient https;
String url = "https://api.telegram.org/bot" + String(telegramBotToken) + "/sendMessage?
chat_id=" + String(chatID) + "&text=" + message;
if (https.begin(client, url)) {
int httpCode = https.GET();
if (httpCode > 0) {
Serial.printf("Telegram message sent, response code: %d\n", httpCode);
} else {
Serial.printf("Error sending message: %s\n", https.errorToString(httpCode).c_str());
}
https.end();
}
} else {
Serial.println("WiFi Disconnected");
}
}
Explanation:
1. WiFi Setup:
o Replace "YOUR_SSID" and "YOUR_PASSWORD" with your WiFi credentials.
2. Telegram Setup:
o Replace "YOUR_BOT_TOKEN" and "YOUR_CHAT_ID" with your bot token and
chat ID from Telegram.
3. IR Sensor Logic:
o The code checks the status of the IR sensor. If a parcel is detected (LOW
signal), it sends a notification through Telegram.
o delay(5000) is used to prevent multiple messages from being sent for the
same parcel.