This project has primarily three functionalities i.e to collect the temperature of the person, to compute if the person has fever or not and to notify the user about the health of the person and notify the person standing at doorstep if he is allowed inside the house or not.
2) DemonstrationIn this section we study the fever detection and alert functionality of the project.
(a) Fever detectionGiven Below are the circuit connections of LM35 temperature sensor, LEDs, Buzzer and bolt module.
The input from the LM35 temperature sensor is taken at analog pin A0 and the output to the LEDs and buzzer is written at digital pin 1 and 2. The power supply to the LM35 temperature sensor is given using 5V pin of the bolt module.
Initially buzzer and lights are blinked to notify the user to put the temperature sensor under his arm for 15 seconds, after 15 secs the buzzer will buzz for once and the value received by the sensor is computed and compared with the threshold value(390 = 38 degrees Celsius and conversion formula = sensor value *100 / 1024)
if the value is below 390 then the person is safe to enter the house and the house owner is informed with the help of telegram messaging service and at door the person is notified by blinking the blue light and buzzing the buzzer five times.
Else, if the value is equal or greater then 390 then the person is not safe to enter the house (He might have COVID19) and the house owner is informed using telegram messaging service and a red light is on at the door and buzzer is buzzing continuously for 5 seconds.
(b) Configuration FileThe python coding for this project has been done in Spyder (windows). Before we start coding of the automated fever detection and alert in python, we need to make a configuration file which will have the specific keys for each user/device. We will import this file in our main code and use the various attributes. The advantage of this is that each user will only have to change the contents the configuration file to use the product.
The following is the configuration file (named as conf.py):
API_KEY = "XXXX" //Bolt Cloud API Key
DEVICE_ID = "BOLTXXXX" //Device ID of the Bolt Module
TELEGRAM_CHAT_ID = "-XXXX" //Chat ID of the created Telegram Channel
TELEGRAM_BOT_ID = "botXXXX" //Bot ID of the created Telegram Bot
Threshold = "XXX" //Threshold value for fever
The API key and Device ID of the Bolt module can be determined as follows:
Connect your Bolt Device to the Bolt Cloud as per instructions given at https://cloud.boltiot.com/. The following screen will appear after that. The Bolt Device ID is crossed Black.
Go to the API section to know the API Key
Install the Telegram App and sign in using your mobile number. Then create a channel and a bot.
(d) Complete Code for ‘Fever Detection and Alert’#Import the Required Libraries
from boltiot import Bolt import requests import json import time import conf
#To identify your bolt device
mybolt = Bolt(conf.api_key, conf.device_id)
#To get data from sensor
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
#To send notifying messages to the owner
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
#Main Loop is started
while True:
print("*******************************")
print("Loop Starting")
#initial Notification to person about the starting process
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 required to stabilize the environment and accurate reading
time.sleep(15)
sensor_value = get_sensor_value_from_pin("A0")
print(sensor_value)
#if the person has fever
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")
#if person doesn’t have fever
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("*******************************")
#wait for 5 seconds before next cycle
time.sleep(5)
(e) Output Screenshot of Python Code(i) Go to https://cloud.boltiot.com/ and then follow the steps below:
(ii) Create product https://docs.boltiot.com/docs/adding-aproduct.
(iii) Writing code for controlling device https://docs.boltiot.com/docs/using-custom-files-in-yourproduct.
(iv) Link device to product https://docs.boltiot.com/docs/linkdevice-to-a-product.
Comments
Please log in or sign up to comment.