Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Jack Siviana
Created July 28, 2024

Colorful bandages for people with mobility impairments

Color-changing bandages using structural colors ensure safe and accurate pressure for people with mobility impairments.

33

Things used in this project

Hardware components

Seeed Studio XIAO ESP32S3 Sense
Seeed Studio XIAO ESP32S3 Sense
×1
Grove Shield for Seeeduino XIAO - with embedded battery management chip
Seeed Studio Grove Shield for Seeeduino XIAO - with embedded battery management chip
×1
nRF52840 Development Kit
Nordic Semiconductor nRF52840 Development Kit
×1
Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1

Hand tools and fabrication machines

Optical microscope
X-ray Diffraction
Tensile testor
Heat mapper

Story

Read more

Code

Code

Python
import cv2
import requests
import time
from machine import Pin, ADC  
from umqtt.simple import MQTTClient  # Example MQTT client for IoT connectivity

# Constants
NORDIC_API_URL = "https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.2.0%2Fmodules.html"  # API of Nordic Semiconductor
BLUES_API_URL = "https://dev.blues.io/api-reference/notecard-api/introduction/" # API of Blues
THRESHOLD_PRESSURE = 1000  # threshold value for pressure
HELP_CONTACT_PHONE = HERE PUT THE PHONE NUMBER OF CONTEST MASTER CAREGIVER

# Initialize ADC for pressure sensor
adc = ADC(Pin(32))

# Initialize MQTT client for IoT connectivity
client = MQTTClient("unique_client_id", "broker.hivemq.com")

# Function to detect color (simplified)
def detect_color(image):
    hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
    # Define range for detecting red color
    lower_red = (0, 120, 70)
    upper_red = (10, 255, 255)
    mask = cv2.inRange(hsv, lower_red, upper_red)
    return cv2.countNonZero(mask) > 0

# Function to read pressure sensor
def read_pressure():
    return adc.read()

# Function to send data over cellular network
def send_data_blues(data):
    response = requests.post(BLUES_API_URL, json=data)
    return response.status_code == 200

# Function to send data over bluetooth network
def send_data_wifi(data):
    response = requests.post(NORDIC_API_URL, json=data)
    return response.status_code == 200

# Main loop
def main():
    cap = cv2.VideoCapture(0)  # Capture from default camera
    while True:
        ret, frame = cap.read()
        if not ret:
            continue
        
        if detect_color(frame):
            pressure = read_pressure()
            data = {"pressure": pressure}
            if pressure > THRESHOLD_PRESSURE:
                send_data_cellular(data)
                send_data_wifi(data)
                notify_help()
        
        time.sleep(1)  # Adjust as needed

# Function to notify help
def notify_help():
    requests.post(HELP_CONTACT_PHONE, json={"message": "Need assistance with bandage"})

if __name__ == "__main__":
    main()

Credits

Jack Siviana

Jack Siviana

1 project β€’ 1 follower

Comments