GithubHelp home page GithubHelp logo

jamestiotio / delight Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 135.19 MB

SUTD 2019 03.007 Introduction to Design Project

License: MIT License

C++ 11.18% Python 88.82%
safety design play sutd renewable-energy m5stack m5stickc micropython-esp32 fingerprint fingerprint-authentication fingerprint-sensor wifi game lighter iot embedded microcontroller esp32 micropython ble

delight's Introduction

SUTD 2019 03.007 Introduction to Design Project

Theme: At Play 2.0

19F07 Group 1 Team Members:

Since GitHub limits single file size to 100 MB, the project video could not be uploaded/committed to GitHub. Instead, it is available on YouTube here.

Problem Statement

Unsupervised children playing with lighters leads to grave consequences (supported by statistics of burns and deaths worldwide). Additionally, lighters which have run out of fuel are rendered useless in situations whereby lighter refills and charging points are unavailable. Our solution prevents children from activating the lighter when they come into contact with it as it has a fingerprint lock that only registered fingerprints are able to unlock. Also, when our lighter has run out of fuel, there is an option to recharge it by winding it. At the same time, our lighter allows children to have fun by playing video games on it or winding it.

Product Description

The key highlighted features of our product are:

  1. Fingerprint Sensor

This capacitive sensor allows us to capture, collect, store and sense fingerprint patterns. This feature is used to restrict access to the lighter.

  1. M5Stick-C

This is the big boi that does most of the work. This mini IoT core device is based on the ESP32 chip and is equipped with common features, such as Wi-Fi, Bluetooth, LCD Display, LED, Button, Buzzer, IR Transmitter, Battery and Six-Axis MPU. This allows us to do some cool, unconventional integrations of certain systems that only involve light processing power to the lighter. Such an example would be the simple Game Feature that would run when an unauthorised fingerprint is detected. Note that the fingerprint detection callback still runs asynchronously while the game is running. The game that we currently implement is a simple low-level adaptation of Flappy Bird with balloons as obstacles. Of course, given more time and effort, more intricate games could potentially be written (although care needs to be taken regarding memory usage and the fact that it is very troublesome to write the graphics and physics drivers from scratch). This module also handles the Wi-Fi Feature connectivity and processing.

  1. Plasma Lighter

Instead of using gas fuel, we utilise a more sustainable, reusable and rechargeable energy source such as a battery. A possible case illustration of its sustainability is that this would reduce the amount of plastic unintentionally consumed by animals like birds. The battery could be charged either through the USB port or by using the hand crank.

  1. Speaker

Our product is also equipped with a piezoelectric speaker that provides auditory feedback to convey messages or to reinforce certain actions that the user had done.

  1. Hand Crank

The lighter is equipped with a detachable hand crank that could be wound to provide more energy through its charging circuit.

Design Requirements & Choices

  1. Our product needs to be tightly linked to a specific object taken from a preselected list of suggested, well-designed objects. Our object of focus was the Zippo lighter.

  2. We only had a budget of SGD$500 and thus, we sourced for cheap PLA material to construct the lighter's casing and we also sourced for relatively cheaper alternatives of fingerprint sensors and IoT processors.

  3. We chose a winding method instead of a shaking mechanism since, by performing some rough preliminary estimations and calculations, we found that winding would provide more energy to the battery (or the device) than shaking.

  4. Limitations of our product are mainly centered around energy efficiency, ease of use and ergonomics:

    • The concern over the energy efficiency of the hand crank is relevant to our project. Conversion from mechanical to electrical energy is usually not very efficient since a lot of energy is wasted as heat and sound.

    • Another plausible and reasonable concern is that users would find it a hassle to have to unlock a mere lighter with their fingerprint every time they want to use it. Thus, we tried to implement the Wi-Fi verification method as well as a proof of concept in order to make it slightly easier for users to use the lighter.

    • Finally, the overall size of the lighter is larger than the usual lighter. This is due to the slightly bulky structure of the M5Stick-C. On the other hand, the M5Stick-C is jam-packed with plenty of features in such a tight space that the temptation to include everything in such an Apple-like compact design is quite high.

  5. Our design focus is on rapid prototyping, as well as iterative development and feature testing. Therefore, our code currently should only be used during development and not in a production-level environment.

Future Work

Several improvements (and new ideas) that could be implemented include:

  1. Better reliability/control/safety in terms of precision and accuracy of the magnitude of the electrical current discharge (so as to not overload any components), as well as the overall reliability of the whole electrical circuit. Short-circuits and accidental contacts with live wires/batteries were encountered quite often during testing, which should not be the case.

  2. Integration with Siri. M5Stick-C has a microphone that could support this integration. Apple's HAP might be needed for this.

  3. An additional security feature in terms of Morse code tapping password detection (?).

  4. (Old Idea) 3D Capacitor Pattern Lock (setup of three perpendicular plates).

Acknowledgements

Credits to Prof. Arlindo Silva and Prof. Daniel Joseph Whittaker as our cohort instructors who guided us through every single step of this journey!

delight's People

Contributors

jamestiotio avatar ragulbalaji avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

delight's Issues

peripheral.py returns errors when commanding

Dear James
using esp32 with your "peripheral.py" returns a message as in the pictures, while the "basic_ble.py" activates the advertising, connects and communicates with "serial bluetooth terminal" app on the phone.

I am searching for "notify a close-by ble device" which means using the esp32 periodically on scan/advertise mode without connection , preferably with rssi signal level upon detection.

could you help me , please, understand what is the nature of the error, so I can switch between the 2 modes with time sharing?
``
the esp32 dev board is a basic board, nothing fancy, "Lolin D32"

error message 1

error message 2

---code---- basic_ble.py

boot section

import esp
import esp32
import micropython
from micropython import const
import machine
from machine import Pin,I2C,SoftI2C,ADC,Timer
import utime
import time
from time import sleep_ms
import struct
import random
import network
import ubluetooth
from ubluetooth import BLE
adcamp1=ADC(Pin(32))
adcamp2=ADC(Pin(33))
adcamp3=ADC(Pin(34))
adcbat=ADC(Pin(35))
led=Pin(2,Pin.OUT) # pin 2 in devkit1
machine.freq(240000000)

#------------------------------------------

class BLE(): # BLE class
def init(self, name):
self.name = name
self.ble = ubluetooth.BLE()
self.ble.active(True)

    self.led=led
    self.timer1 = Timer(0)
    self.timer2 = Timer(1)
            
    self.disconnected()
    self.ble.irq(self.ble_irq)
    self.register()
    self.advertiser()

def connected(self):        
    self.timer1.deinit()
    self.timer2.deinit()

def disconnected(self):        
    self.timer1.init(period=1000, mode=Timer.PERIODIC, callback=lambda t: self.led(1))
    sleep_ms(10)
    self.timer2.init(period=1000, mode=Timer.PERIODIC, callback=lambda t: self.led(0))   

def ble_irq(self, event, data):
    if event == 1:
        '''Central disconnected'''
        self.connected()
        self.led(1)
                
    elif event == 2:
        '''Central disconnected'''
        self.advertiser()
        self.disconnected()
    
    elif event == 3:
        '''New message received'''            
        buffer = self.ble.gatts_read(self.rx)
        message = buffer.decode('UTF-8').strip()
        print(message)            
        if message == 'led':
            led.value(not led.value())
            print('led', led.value())
            ble.send('led' + str(led.value()))
        if message=='hmc':
            magdat=adc_loop()
            ble.send(str(magdat))  

def register(self):        
    # Nordic UART Service (NUS)
    NUS_UUID = '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'
    RX_UUID = '6E400002-B5A3-F393-E0A9-E50E24DCCA9E'
    TX_UUID = '6E400003-B5A3-F393-E0A9-E50E24DCCA9E'
        
    BLE_NUS = ubluetooth.UUID(NUS_UUID)
    BLE_RX = (ubluetooth.UUID(RX_UUID), ubluetooth.FLAG_WRITE)
    BLE_TX = (ubluetooth.UUID(TX_UUID), ubluetooth.FLAG_NOTIFY)
        
    BLE_UART = (BLE_NUS, (BLE_TX, BLE_RX))
    SERVICES = (BLE_UART, )
    ((self.tx, self.rx,), ) = self.ble.gatts_register_services(SERVICES)

def send(self, data):
    utime.sleep(0.001)
    self.ble.gatts_notify(0, self.tx, data + '\n')

def advertiser(self):
    name = bytes(self.name, 'UTF-8')
    self.ble.gap_advertise(100, bytearray('\x02\x01\x02') + bytearray((len(name) + 1, 0x09)) + name)

#----------------------------------------
def adc_loop():
amp1 =adcamp1.read()
amp1=amp1+1000
amp2 =adcamp2.read()
amp2=amp2+1000
amp3 =adcamp3.read()
amp3=amp3+1000
bat =adcbat.read()
bat=bat+1000
magdat=[amp1]+[amp2]+[amp3]+[bat]
print(magdat)
return magdat
#--------------------------------------------------------

if name == 'main':
ble = BLE('hmc001')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.