Got bored of checking the mailbox everyday, so let´s IoT it.
Using ESP32CAM hardware and a reed sensor for the mailbox trap door, now I receive notifications in Telegram if I receive mail or if the mailbox trap door is blocked.
Table of Contents
I´m requested by CS50 to provide the final course project, hence was thinking during a couple of days and nothing was coming to my mind.
But one day, doing my daily housework, I went and check my empty mailbox, this brought to my mind the idea that if something would notify me when receiving mail, I would save some minutes/hours by the end of the year, so it seems like an interesting project to invest some time and present it as my CS50 final project.
Why should you create your own I-mail?
- It is a cool way to invest your time.
- You will hopefully increase your knowledge on C programming, ESP32, VS Code and so many other tools.
- You will save time receiving notifications from your mailbox directly on your phone.(that´s cool!)
- It´s cheap, and try to make it as easy as possible.
In order to upload I-mail the following files were generated for this project:
This is the software used to create this project:
- Visual Studio Core
- Platform.io(VS Code extension)
- Bot father(Telegram bot)
- Universal Telegram Bot(Telegram ESP32 bot API)
- ArduinoJson(ESP32 serialization)
You will need some basic electronic and programming knowledge, but I will try to keep it easy.
Hardware:
- ESP32CAM board (or any similar ESP32cam board)
- REED sensor (Installed on Mailbox trap door)
- Arduino UNO or any other serial interface to program the board.
See related link for serial programming with Arduino UNO.
Software:
I programmed ESP32CAM using VSCODE + PlatformIO extension but it is also possible to do it with Arduino IDE.
In VS Code it is necessary to install the Espressif 32 platform v 4.3.0(4.2.0 did not work).
Please note that the following libraries should be installed in the project:
It is also a requirement to create a Telegram Bot, see this link where the entire process is described with the aim of getting the bot TOKEN, which will be required later.
Prior to flash the board with the program it is necessary to adjust Imail-0.1.0-Alpha in src.
The required part to adjust is the following:
-
// Wifi network station credentials
#define WIFI_SSID "*****"
#define WIFI_PASSWORD "**********"
-
// Telegram BOT Token (Get from Botfather)
#define BOT_TOKEN "********"
-
// Use @myidbot (IDBot) to find out the chat ID of an individual or a group // Also note that you need to click "start" on a bot before it can // message you
#define CHAT_ID "*******"
With your own parameters, please note that Wifi credential must be filled with your WIFI data.
Bot token is obtained when creating the bot(mentioned before).
To get the Chat_ID, please follow the instructions mentioned here.
Please revise Platformio.ini and adjust your USB port if required:
- monitor_port = COM7
- upload_port = COM7
Once you have adapted the code and connected, click on ESP32CAM "rst" button which will put the board in upload mode.
Click on upload in platformio and once it is uploaded it is ready to go.
ESP32CAM will reboot when finished.
You can now make disconnect arduino if you don not need to serial monitor anymore and just connect as per connection diagram in hardware section.
Now I-mail is ready to work.
Once ESP32CAM is powered with 5 V, the program will automatically start.
The program works as follows:
Additionally, in all the steps, the following commands can we executed from Telegram:
/check : Check if Imail is online.
/getid : Check Telegram chat ID for configuration purpose.
/status : Check if mailbox trap door is open or closed.
/help : Shows available commands.
Please note that this commands are valid only if CHAT_ID configured, if not only /getid command will work for configuration purpose.
-
Create Imail-0.1.0-Alpha.cpp & Platformio.ini
-
Include all libraries dependencies
- Universal Telegram Bot
- Arduinojson
-
Design and build all hardware configuration.
-
Upload program to ESP32CAM.
-
Test
-
Create README.md
-
Upgrade with new features:
- Pictures when receiving mail & also when receiving /photo Telegram command implementation.
- Battery monitoring notifications and Telegram battery check command.
- Add a second reed sensor so when opening the mailbox to collect the mail sends a notification that the mail has been collected.
- Add WiFi manager function for initial configuration via an Access Point instead of hard coding.
- Introduce OTA features, so not necessary serial interface to program it.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU License. See LICENSE
for more information.
David García-Taheno Fernández - dgtaheno@hotmail.com
Project Link: https://github.com/dgtaheno/Imail
Resources I found helpful and would like to give credit to.