Badayayash
Published © GPL3+

Automated Fever Detection and Alerting System

Detects if the person has fever or not with the help of LM35 Sensor and BoltIOT Module and Alerts the home user about the guest.

BeginnerProtip2 hours812
Automated Fever Detection and Alerting System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Buzzer
Buzzer
×1
Breadboard (generic)
Breadboard (generic)
×1
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT iOS App
Bolt IoT iOS App
Windows 10
Microsoft Windows 10

Story

Read more

Schematics

Circuit Diagram

Telegram Alert

Alert Received on Telegram App.

Code

Conf.py

Python
Configuration file
api_key = ">>>>>>>>>>>>>>>>>>>>>"
device_id = ">>>>>>>>>>"
telegram_chat_id = "@>>>>>>>>>>>>>>"         
telegram_bot_id = "XXXXXXXXXXXXXXXXXXXXXXXX"  
threshold = 390                    

Fever Alert.py

Python
Main file with Infinite loop
#Import the Required Libraries


from boltiot import Bolt
import requests 
import json
import time

api_key = "12333333333333344444455556666"
device_id = "BOLt!@#$%^&"
telegram_chat_id = "@@@@@@@@@@@@"         
telegram_bot_id = "######################################"  
threshold = 390                    


mybolt = Bolt(conf.api_key, conf.device_id)


def get_sensor_value_from_pin(pin):
    """Returns the sensor value. Returns -999 if request fails"""
    try:
        response = mybolt.analogRead(pin)
        data = json.loads(response)
        if data["success"] != 1:
            print("Request not successfull")
            print("This is the response->", data)
            return -999
        sensor_value = int(data["value"])
        return sensor_value
    except Exception as e:
        print("Something went wrong when returning the sensor value")
        print(e)
        return -999
    
def send_telegram_message(message):
    """Sends message via Telegram"""
    url = "https://api.telegram.org/" + conf.telegram_bot_id + "/sendMessage"
    data = {
        "chat_id": conf.telegram_chat_id,
        "text": message
    }
    try:
        response = requests.request(
            "POST",
            url,
            params=data
        )
        telegram_data = json.loads(response.text)
        return telegram_data["ok"]
    except Exception as e:
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False    


while True:
    print("*******************************")
    print("Loop Starting")
    mybolt.digitalWrite("2","HIGH")
    mybolt.digitalWrite("1","HIGH")
    time.sleep(0.5)
    mybolt.digitalWrite("1","LOW")
    mybolt.digitalWrite("2","LOW")
    print("Reading time 15 secs")
    time.sleep(15)
    sensor_value = get_sensor_value_from_pin("A0")
    print(sensor_value)
    if(sensor_value > conf.threshold):
        message = "Alert! Person at the door has fever, Dont LET HIM IN!!!. \nThe current value of his fever is " + str(sensor_value*100/1024)
        telegram_status = send_telegram_message(message)
        print("person at the door is not safe do not let him enter")
        mybolt.digitalWrite("2","HIGH")
        time.sleep(4)
        mybolt.digitalWrite("2","LOW")
    else:
        message = "Alert! Person at the door is healthy, LET HIM IN!" + str(sensor_value*100/1024)
        telegram_status = send_telegram_message(message)
        print("Person at the door is safe, we can let him enter")
        mybolt.digitalWrite("1","HIGH")
        time.sleep(0.1)
        mybolt.digitalWrite("1","LOW")
        
        for _ in range(5):
            mybolt.digitalWrite("2","HIGH")
            time.sleep(0.5)
            mybolt.digitalWrite("2","LOW")
    print("next cycle will start in 5 secs")
    print("*******************************")
    time.sleep(5)

Credits

Badayayash

Badayayash

1 project • 0 followers

Comments