Skip to content

Smart alarm clock with facial recognition, ambient climate sensing, and dynamic data querying.

Notifications You must be signed in to change notification settings

osayamenja/Sparky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SParky

Overview

A smart alarm clock supporting configurable timed facial recognition, ambient climate sensing and data querying. Skip to Run to see how to run the application.

Architecture

The architecture of Sparky uses multithreading for concurrent execution of MQTT requests, alarm time checking and ambient climate data upload.

Architecture

Register/Delete User

Sparky captures multiple facial images and trains a local OpenCV model with those images. The resultant encodings file is stored in the database.

Register/Delete User

Deleting a user is a simple database call. See register_user and delete_user for its request schema.

Set Alarm

Setting an alarm entails:

  • Verifying the user.
  • Retrieving their facial encodings from the database.
  • Persisting the returned file locally.
  • Updating local state to configure the alarm time.

Set_Alarm

See set alarm for its request schema.

Ring Alarm

Ring_Alarm

Query Data

Retrieve_Data

Specifications

  • Facial Recognition: OpenCV
  • Database: Azure MySQL
  • Message Queue: EMQ MQTT

Requirements

Hardware

  • Raspberry Pi (guaranteed to work on a 4)
  • Audio output compatible with a Pi.
  • Camera compatible with a Pi.
  • DHT 11 temperature sensor

Software

Environment Variable file

By design, connecting to a MySQL database or MQTT broker requires a configured .env file. To that end, please follow the steps below:

  • Populate the fields without values in template.txt.
  • Rename from template.txt to .env.

NB: EMQ provides a free broker. See here for more details.

SQL Tables

schema

The SQL code for generating the data model above is available in tables.sql.

Run

  • Install all external dependencies on the import listing.
  • If you do not have DHT11 connected, then comment out t_and_h_upload_worker.start() in the main function.
  • Execute the main.py file
  • Verify database connection was successful through stdout output: Connection established Successfully!
  • Go to MQTT X Web and set up a connection to your broker or the free broker.
  • Subscribe to output_topic defined in main.py
  • Input requests to a topic in input_topics defined in main.py

Requests Schema

Register/Delete User

    username   
  • username is an alphanumeric string.

Set Alarm

    username, alarmTime, facialRecognitionDuration    
  • username is a registered username.
  • alarmTime is a 12-hour format string following HH:MM (A|P)M
  • facialRecognitionDuration is the number of seconds the system will maintain continuous facial recognition. The system restarts the timer whenever the recognition fails. Note this value must be lesser than max_facial_recognition_duration which the system uses for timing out the recognition.

Retrieve Data

Temperature & Humidity

    t&h, param   
  • param can be either a positive integer specifying number of days before current date or a specific date formatted as mm/dd/yyyy

Alarm data

    username, (columns), param   
  • username is a registered username

  • param as defined here

  • columns is a subset of [wake_up_duration, completed_face_recognition] delimited by a semicolon. If empty, the request becomes username, param

  • Example queries:

    username, (wake_up_duration; completed_face_recognition), param   
    
    username, (wake_up_duration), param   
    
    username, (completed_face_recognition), param   
    

About

Smart alarm clock with facial recognition, ambient climate sensing, and dynamic data querying.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages