XMas Party Fever Control
2021-12-24 | By M5Stack
License: General Public License
* Thanks for the source code and project information provided by @gperrella
It's time for parties with friends, but, in our pandemic era (with new #omicron covid-19 variant), we need to remember to stay healthy and safe!
Xmas Party Fever Control is a proposal to help people to stay away from other people with a fever, blocking them at entrance in public places or houses.
This project is mainly based on an Esp32 device such as the M5Stack Core Grey (or similar) and an IR contactless body sensor, the infrared sensor MLX90614 (M5Stack NCIR Unit), connected to Grove PORT A.
I found thess devices very easy to integrate; like "Lego" blocks.
For the coding I am using UiFlow for some graphics framework (also to load background image) and coding the rest in micropython using the Thonny IDE.
Product Features
- Operating voltage: 4.5 to 5.5V
- Measuring object temperature range: -70°C ~ 380°C
- Measuring ambient temperature range: -40 to 125 ˚C
- Measurement accuracy at room temperature: ±0.5°C
- Field of view: 90°
- Software Development Platform: Arduino, UIFlow (Blockly, Python)
- Two Lego-compatible holes
Features
So, to prevent access to a person (hopefully not needed!) in potentially Covid-19 (now Omicron) positive state (with a suspected fever above 37.5 degrees) we can use the contactless IR body sensor to verify one's body temperature at the wrist.
Describing the use cases, other that showing body temperature, we show on display following messages:
IF (NCIR >= 34.50 OR <=37.5) --> Grant access to the person, (message "Grant access")
IF (NCIR >=37.6) --> Deny access to the person, (message "Grant Denied")
IF (NCIR < 34.50) --> (message "BODY TEMP TOO LOW")
To make the application more flexible and usable for centralizing control, we are using MQTT protocol to simply publish the "topic" temperature value (m5s/fever) on a remote server, in this case I'm using http://www.hivemq.com/demos/websocket-client/ but any MQTT broker can work; in my case I have this application integrated on OpenHab for domestic IOT control.
The code
As you can see, the code is quite simple and, hopefully self-explanatory.
At beginning there is the import section of the M5stack modules, then the MQTT and WIFI settings.
All the main code is in the While loop
All the code and the image xmas_party.jpg courtesy of https://www.freeimageslive.co.uk/free_stock_image/xmas-decorations-jpg are available on my github repository
Enjoy it and Happy XMAS 2021!
# Xmas Party Fever control
# ver 1.0
#by gian luigi perrella
from m5stack import *
from m5ui import *
from uiflow import *
from m5mqtt import M5mqtt
import wifiCfg
import time
import unit
#initialize string to publish body temp
a = None
# Using HIVEMQ mqtt broker, point your browser at http://www.hivemq.com/demos/websocket-client/
# and fill the field ADD NEW TOPIC SUBSCRIPTION with the topic m5s/fever
m5mqtt = M5mqtt('m5Fever', 'broker.mqttdashboard.com', 1883, '', '', 300)
lcd.clear()
setScreenColor(0x111111)
image1 = M5Img(0, 0, "res/xmas_party.jpg", True)
label6 = M5TextBox(30, 10, "XMas Fever control", lcd.FONT_DejaVu24,0xFFFFFF, rotate=0)
wait_ms(10000)
label6 = M5TextBox(30, 10, "XMas Fever control", lcd.FONT_DejaVu24,0xFFFFFF, rotate=0)
label4 = M5TextBox(60, 60, "", lcd.FONT_DejaVu24,0x00FF00, rotate=0)
#initialize M5Stack NCIR sensor unit
ncir0 = unit.get(unit.NCIR, unit.PORTA)
#initialize wifi connection
wifiCfg.doConnect('your_SSID', 'your_Password')
m5mqtt.start()
temptext = M5TextBox(40, 180, "BODY TEMP:", lcd.FONT_DejaVu18,0xFFFFFF, rotate=0)
tempval = M5TextBox(210, 180, "0", lcd.FONT_DejaVu18,0xFFFFFF, rotate=0)
label5 = M5TextBox(40, 208, "", lcd.FONT_DejaVu18,0xFFFFFF, rotate=0)
while True:
wait_ms(1000)
temperatura = (str(ncir0.temperature +4)) # sensor NCIR not so precise, add some value to correct
a = temperatura
m5mqtt.publish(str('m5s/fever'),str(a))
tempval.setText(temperatura)
label4.setColor(0x00FF00)
if (str(temperatura) >= '34.50' and str(temperatura) < '37.50'):
label4.setText("GRANT ACCESS")
label5.setText("CHECK BODY TEMP OK")
wait_ms(5000)
elif str(temperatura) >= '37.60': #need correction to body temp
tempval.setColor(0xFF0000)
label5.setText("CHECK BODY TEMP KO")
label4.setColor(0xFF0000)
label4.setText("GRANT DENIED")
speaker.tone(freq=800, duration=1)
wait_ms(5000)
tempval.setColor(0xffffff)
elif str(temperatura) <= '34.50':
label5.setText("BODY TEMP TOO LOW")
label4.setText("")
wait_ms(10000)
XMAS Party Fever Control
GitHub
https://github.com/Telegiangi61/M5Covid-Bastion/tree/master/Xmas_Fever_Control
Software apps and online services