Device to detect if person is wearing mask and having healthy heart rate using M5Stack Core2, ESP32CAM, AWS IoT and Edge Impulse After the pandemic most of the offices will start for on-site work and schools will start, during this time we also need to take care if any employee or student is having correct body temperature and is wearing mask. Instead of hiring someone and risk their life to check temperature and mask for so much employees and students is tough task. So to solve this problem we want to create a device which monitors their heart rate and checking are they wearing a mask using Edge Impulse model on AWS IoT Edukit and Embedded Camera.
Project Used Hardware
ESP32 CAM, M5Stack Core2, KY-039 Heart Rate Sensor, IR Distance Sensor, Perf Board and Wires
Project Used Software
Arduino IDE, Edge Impulse, AWS IoT
Project Hardware Software Selection
All the Computer Vision will be completely done over ESP32 Cam using Deep Learning model. The Mask Detection model is trained on Edge Impulse and the generated library is used in ESP32 CAM. The Data is sent to AWS IoT suing MQTT and major alerts like Person is Not Wearing Mask is sent as email to Admin using AWS SES Flow:
1. The IR Distance sensor will check when user is standing in front of Device and start camera and heart sensor
2. Read the Image and inference it on Mask Model.
3. Check whether Employee/Person is wearing Mask using Mask Classification Model trained on Edge Impulse
4. Send Predictions to M5Core2 using UART communication.
5. Then Check the Pulse Rate using Pulse Sensor and send to M5Core2 to display on screen.
6. If results are showing that Person is not healthy then that case will be reported to admin using AWS IoT and SMTP via SES.
AWS IoT and SES:
Whenever the user is detected the predictions are sent to AWS via MQTT to AWS IoT Cloud and when there are any people who are not wearing mask then it will also send via eMAIL using SMTP of AWS SES service.
AWS IoT:
1. Initially Create Thing in AWS IoT and set up the certificate and MQTT URL.
2. It will generate unique URL for host url and also give a topic in form of "$aws/things/NAME/FUNCTION"
3. Set Up the Credentials in code as: int PORT = 8883; char MQTT_SUB[] = "$aws/things/NAME/shadow/update"; char MQTT_PUB[] = "$aws/things/NAME/shadow/update"; Also set up the credentials of certificates of CA Certificates, Client Certificate and private Key downloaded earlier.
4. Using the Pubsubclient library the M5Stack spublishes data to IoT Cloud.
AWS SES:
1. Verify your email and set up HTTPS API of AWS SES.
2. The request url is of form : https://EMAIL.us-east-1.amazonaws.com?Action=SendEmail&Source=DESTINATIONEMAIL
3. Sent the request with other parameters like the subject of mail and body of mail.
Circuit Diagram
First the OV2640 Camera on ESP32Cam read the image of user's face and stores it in a buffer. That buffer is then transferred to neural network and processed. The Predictions are sent to M5COre2 via UART ( 13, 14 Pins on M5COre2). The Heart Rate sensor Data pin is connected to pin 36 of M5Stack Core2 and power is 5V and Ground The IR Distance sensor Data pin is connected to pin 35 of M5Stack Core2 and power is 5V and Ground.
DEMO
Here is a demo: