In this tutorial, we’ll learn how to build a device that works as a virtual doctor. The device inputs patient data, which can then be emailed remotely to a registered physician using the simple mail transfer protocol (SMTP) — the internet standard communication protocol for electronic transmissions.
The purpose of this device is to support physicians who are unable to visit patients in person. This could be because of distance, location (such as for those in remote areas), patent immobility (due to illness or access to transportation), and/or costs. A virtual doctor’s visit can also sometimes be more cost-effective, allowing healthcare access to more people.
For this project, we’ll use Raspberry Pi (RPi), Picamera (a portable camera that supports RPi), and an ultrasonic sensor. These devices will be processed using Raspbian OS and Python. Overall, the cost of this project is fairly affordable and can be implemented in rural areas with Internet access.
Tools & libraries required:
- Python interpreter
- Python Libraries: picamera – can be installed by the following commands in the terminal…
$ sudo apt-get install python-picamera python3-picamera
- Putty Terminal for accessing the terminal for input
When the device detects the patient’s presence, it asks for the required information and documents it. Upon completion, this data is then emailed to the registered physician.
This project works on SMTP. The system script runs on Python 2.7.
The device receives input from the camera module, which includes a keyboard. The data is saved using RPi and emailed to the physician using SMTP.
To properly take the reading, we’ll use a voltage divider because RPi GPIO is unable to directly support 5V.
Detecting the patient
An ultrasonic sensor is used to detect the presence of a patient. The sensor sends ultrasonic waves for about 20 milliseconds. When those waves are reflected back to the sensor, it detects the distance by calculating the time the wave was sent and then returned.
How the system works
- The system only works when a person is in front of the device. The ultrasonic distance-measurement sensor (HC SR-04) senses the change in the distance around the device (because of the patient in front of it).
- The device then asks for the details programmed on the screen. For example, it asks the patient to open their mouth and their eyes, and takes photos using the camera module, saving the images locally.
- The device also requests the patient’s ID.
- After all of the data is documented, it emails the registered doctor with the attached images, using the “multipart content type.” This is a type of data that specifies that the email contains media content.
- This email is sent using the SMTP protocol. The physician downloads the email using the standard, Internet message access protocol (IMAP).
- The physician examines the information and images and contacts the patient.
Understanding the source code
The code can be understood from its functions. For example, there is a calling of one of the functions in the main one that’s an “intrusion()”. This function then calls two others, the “Capture_image” and the “SendEmail”.
The functions are as follows…
1. Def Intrusion(): This function ensures the HC SR-04 sensor continually sends out an ultrasonic wave and then calculates the distance.
This function also has a range. So, if the distance in front of the sensor is less than that set range, it triggers another function to take a photo: “capture_image(name)”. It also takes an input parameter for the image name.
if(object_stay > 1 and object_present_again == False):
object_present_again = True
name = raw_input(“Ente your visting number:”)
print “Open Your mouth in front of the camera!”
print “Taking Picture…”
The function also provides instructions on the screen that asks for the name of the patient. Afterward, it triggers the camera to shoot the photo(s).
2. Def capture_image(name_,part): This function inputs the patient’s name and the body part (the eyes or mouth) in the photo.
After taking the photo(s), this function calls on another one that emails the physician with the attached images.
download(name_ + part,filepath)
sendEmail(self.jobid, self.jobid, [self.filepath])
3. Class sendEmail(threading.Thread): This function writes the email and identifies whether any media content is attached. It then sends it using the SMTP to the proper physician.
mailServer.sendmail(gmail_user, gmail_user, msg.as_string())
This project is one example of how it’s possible to implement a simple SMTP protocol in applications that can solve important problems, such as access to a family doctor.
You may also like:
Filed Under: Electronic Projects, More Editor's Picks