This project is based on Raspberry Pi and Python programming, and sends real time sensor data via Gmail. Raspberry Pi is a single-board computer with several features. Connection details of the ultrasonic sensor with Raspberry Pi are shown in Fig. 1.
Hardware includes Raspberry Pi 3, ultrasonic sensor HC-SR04, Internet connection and some hookup wires. The author’s prototype is shown in Fig. 2.
Software required is Python Interpreter. Code is written in Python programming language. Make sure you have an updated version of Python in Raspbian operating system (Jessie) of Raspberry Pi. If not, update it by typing the following commands on the terminal:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python3
In case you are using an older version of Python, you may need SMTP library. Type the command given below on the terminal to install the library.
$pip install smtplib
Now, write mailer.py code in Python Editor, or open the code (mailer.py) either via the terminal or Python Editor.
After opening the code, make the following changes:
1. In sender field, type your e-mail address.
2. In senpass field, type the password associated with the e-mail ID.
3. In receiver field, type the e-mail ID where you want to receive the email regarding the status of the sensor.
Then, save the changes and run the code. Whenever the sensor detects an object from a distance of 50 cm—you can change this from the code—a message will be sent to the configured e-Mail ID from the sender, Raspberry Pi. This action will be shown on the terminal, as shown in Fig. 3.
The e-Mail received on the receiver e-Mail ID is shown in Fig. 4.
Select Less Secure Apps option under Gmail settings to access the alerts.
Thus, following the above method, we have successfully created a system which can send real time sensor data via e-Mail.
Download source folder here: Click here
Abuthahir Tajudeen is founder and chief executive officer, LEPoCUBE AssisTech, Tamil Nadu