Andrei Petcu
Published © GPL3+

Anti-COVID thermometer with Email-based notifications

This project aims to improve the basic infrared thermometer with Email functionalities by sending a notification through an IFTTT webhook.

IntermediateFull instructions provided2 hours465
Anti-COVID thermometer with Email-based notifications

Things used in this project

Hardware components

Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
MLX90614 Infrared Temperature Sensor
×1
KY-008 Laser Module
×1
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Red
5 mm LED: Red
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×11
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
Maker service
IFTTT Maker service

Story

Read more

Schematics

Pinout

This is the pinout diagram for the modules to connect to the Rasbperry Pi board.

Code

main.py

Python
The following code is the base for the thermometer program. Make sure to follow the instructions described above in order for the program to work correctly.
#mandatory libraries
import board
import busio as io #pip install busio in terminal
import RPi.GPIO as GPIO
import requests
import adafruit_mlx90614 #pip install adafruit-circuitpython-mlx90614 in terminal
from time import sleep

#setting up the targeting laser and the LEDs with GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT) #red LED, indicates that a person is suspected of COVID
GPIO.setup(18, GPIO.OUT) #targeting laser
GPIO.setup(27, GPIO.OUT) #green LED, indicates that a person is safe and good to go

#setting up the IR temp sensor
i2c = io.I2C(board.SCL, board.SDA, frequency=100000)
mlx = adafruit_mlx90614.MLX90614(i2c)

#targetTemp is the measured temperature, covidFlag is used for the email trigger
targetTemp = 0.0
covidFlag = False

#measure_temp is used for measuring the body temperature, with a delay of 2 seconds before printing the measured value
def measure_temp():
  global targetTemp
  targetTemp = "{:.2f}".format(mlx.object_temperature)
  GPIO.output(17, GPIO.HIGH)
  sleep(2)
  GPIO.output(17, GPIO.LOW)
  print("Temperature of target:", targetTemp, "°C")

#email_alert is used to send an email notification whenever the temperature threshold is higher than 37.3 degrees Celsius (as recognized by WHO)   
def email_alert():
  global targetTemp, covidFlag
  covidThreshold = float(targetTemp)
  if covidThreshold > 37.3:
    covidFlag = True
  if covidFlag == True:
    print("Possible detection of COVID-19")
    GPIO.output(18, GPIO.HIGH)
    sleep(0.75)
    GPIO.output(18, GPIO.LOW)
    sleep(0.75)
    GPIO.output(18, GPIO.HIGH)
    sleep(0.75)
    GPIO.output(18, GPIO.LOW)
    requests.post('https://maker.ifttt.com/trigger/{YOUR_EVENT}/with/key/YOUR_MAKER_KEY?value1='+str(covidThreshold)+'')
  else:
    print("Safe temperature, access allowed")
    GPIO.output(27, GPIO.HIGH)
    sleep(0.75)
    GPIO.output(27, GPIO.LOW)
    sleep(0.75)
    GPIO.output(27, GPIO.HIGH)
    sleep(0.75)
    GPIO.output(27, GPIO.LOW)
  
  covidFlag = False
  
if __name__ == "__main__":
  try:
    #this while statement makes the program run infinitely in a loop
    while True:
      print("Measuring temperature...")
      sleep(2)
      measure_temp()
      email_alert()
      sleep(5) #allows the thermometer to reset itself
  finally:
    GPIO.cleanup() #cleans the GPIO values of the laser and LEDs in order to not conflict with other programs
    #for testing purposes, the program can be manually interrupted by using CTRL+C in a terminal or pressing the Stop button in a Python IDE
      

Credits

Andrei Petcu
2 projects • 6 followers
Contact

Comments

Please log in or sign up to comment.