This project aims to develop a Raspberry Pi-based application that continuously monitors temperature.
The main components include:
🧩 Thermopile Sensor (H09R9): This sensor allows for accurate ambient temperature measurements. H09R9x is a thermopile sensor module based on STM32G0 MCU and TSD305 digital temperature sensor.
🧩 Hexabitz Single-Lead, EXG Monitor Module (H2BR0): Is one of a kind module that can record publication-grade biopotential signals from your body be it from the heart (ECG), brain (EEG), eyes (EOG), and muscles (EMG).
🧩 Raspberry Pi Interface (HF1R0x): HF1R0x is Hexabitz Raspberry Pi interface module. It interfaces seamlessly to Raspberry Pi 3B/4B single-board computers and enables you to connect and control your favorite Hexabitz modules from the Raspberry Pi operating system and build your own Raspberry Pi Hat. This is the world’s first build-your-own-Pi-Hat system!
🖥️ AI Chatbot: The conversational agent engages users when the temperature exceeds specified thresholds, prompting them with questions and providing insights.
Setup and Wiring:
- Connect the modules to HF1R0 module.
- Make sure to connect your Hexabitz module at the wright spot or left spot then put the HF1R0 Jumper JP1 and JP2 at right position.
- Be sure to download the firmware on the module before soldering.
https://hexabitz.com/docs/how-to/update-module-firmware/
HexabitzMessaging Protocol:
Messaging in the array is carried out via short unacknowledged packets in the following format (each field is a single byte):
|| H | Z | Length | Destination | Source | Options | Code | Par. 1 | Par. 2 | ------- | CRC8 ||
- ‘H’=72 and ‘Z’=90 are message start delimiters. They mark the beginning of a valid Hexabitz message.
- The Length byte is message length not including H & Z delimiters, the length byte itself and the CRC byte.
- Maximum message length is 56, i.e., the maximum number of parameters per message is 47 or 48 bytes.
Source and destination are IDs of source and destination modules.
- If the destination is 255 = 0xFF, the message is a broadcast.
- If destination is 254 = 0xFE, the message is a multi-cast (going to a group).
- If destination is 0, the message is sent to an adjacent neighbor only.
- Source and destination are IDs of source and destination modules.If the destination is 255 = 0xFF, the message is a broadcast.If destination is 254 = 0xFE, the message is a multi-cast (going to a group).If destination is 0, the message is sent to an adjacent neighbor only.
- CODE is a 16-bit variable representing Message Codes. If message code is ≤ 255, then only one byte is used. If message code is > 255, then two bytes are used and the Extended Code flag in the Options Byte is set.
Options: is a byte that contains some option bits and flags. It can be extended using the Extended Options Flag:
- 8th bit (MSB): Long messages flag. If set, then message parameters continue in the next message.
6-7th bits: Message response options:
- 00: Send back no response
- 01: Send responses only to Messages.
- 10: Send responses only to CLI Commands.
- 11: Send responses to everything.
- 6-7th bits: Message response options:00: Send back no response01: Send responses only to Messages.10: Send responses only to CLI Commands.11: Send responses to everything.
- 5th bit: reserved.
3rd-4th bits: Message Trace options:
- 00: Show no trace.
- 01: Show Message trace.
- 10: Show Message Response trace.
- 11: Show trace for both messages and their responses.
- 3rd-4th bits: Message Trace options:00: Show no trace.01: Show Message trace.10: Show Message Response trace.11: Show trace for both messages and their responses.
- 2nd bit: Extended Message Code flag. If set, then message codes are 16 bits.
- 1st bit (LSB): Extended Options flag. If set, then the next byte is an Options byte as well.
- Options: is a byte that contains some option bits and flags. It can be extended using the Extended Options Flag:8th bit (MSB): Long messages flag. If set, then message parameters continue in the next message.6-7th bits: Message response options:00: Send back no response01: Send responses only to Messages.10: Send responses only to CLI Commands.11: Send responses to everything.5th bit: reserved.3rd-4th bits: Message Trace options:00: Show no trace.01: Show Message trace.10: Show Message Response trace.11: Show trace for both messages and their responses.2nd bit: Extended Message Code flag. If set, then message codes are 16 bits.1st bit (LSB): Extended Options flag. If set, then the next byte is an Options byte as well.
- Long messages can be broken down into maximum of 20 messages, i.e., ~940-960 bytes of parameters. Any payload larger than 960 bytes will have to set up a DMA stream.
- The CRC byte is a CRC8 of the entire message starting from the delimiters (except the CRC byte itself).
⚙️ H2BR0 Message:
⚙️H09R9Message:
1. The Raspberry Pi reads data from the temperature sensor at regular intervals.
2. If the temperature exceeds a user-defined limit (e.g., 30°C), the system triggers an interaction.
3. The AI chatbot asks if the user would like to answer some questions. If they agree, they can input questions, and the chatbot responds with answers generated from the model, engaging the user in a valuable conversation about health and well-being.
4. Simultaneously, the EXG Hexabitz module measures heart rate, providing additional insights into the user's health status during high-temperature events.
Code Explanation
The code is a Flask web application designed as an health monitoring tool. It has two main routes:
1. Homepage (`/`):
- Displays a form for the user to enter a message.
- Styled with CSS to create a visually appealing, interactive user interface.
2. Chat Route (`/chat`):
- Processes the user's message and provides health advice based on simulated temperature and heart rate readings.
- Reads sensor data from a function (currently simulated with random values but can be replaced with real Hexabitz sensor data).
- Uses logic to detect abnormalities (e.g., high temperature or irregular heart rate) and generates appropriate advice.
- Displays the advice dynamically on the webpage along with the sensor data.
The application continuously interacts with users and updates responses directly in the browser, making it user-friendly and engaging.
How to Run
- Save the code in a file.
- Run the application:
python3 Hexabitz-chatbot.py
- Open your browser and navigate to:
http://127.0.0.1:5000/
Suggestions for Further Enhancements
- Add animations or transitions with JavaScript for an even more dynamic user experience.
- Implement database integration to save user interactions or health logs.
- Create a mobile-friendly version using frameworks like Bootstrap for responsive design.
This smart temperature monitoring system can be applied in various settings, such as:
- Home Health Monitoring: Continuous tracking for families to ensure safe environments.
- Healthcare Facilities: Enhancing patient engagement by encouraging them to participate in monitoring their conditions.
This project exemplifies how the integration of health monitoring technologies and artificial intelligence can lead to innovative solutions that enhance individual awareness and promote better health practices. By leveraging accessible hardware components and advanced AI capabilities, we can create an engaging and informative tool that addresses health concerns in real-time.
Comments
Please log in or sign up to comment.