Skip to content

GIAAIL/Smart-Bag

 
 

Repository files navigation

Smart-Bag Project


  • This repo contains the code for Smart-Bag Project in NYCU part of GIAAIL

  • For the communication of all the components in this repo, see this excalidraw diagram

  • For debbuging the MQTT Message Mechanism, it is recommanded to use tools such as MQTTBOX

  • This repo contains code for

    1. (Wemo Client) -- Arduino IDE code for connect WiFi / MQTT client / Controlling Motor and Air Vault
    2. (Config Website ) -- Device-Role Assigning Website , which provides a GUI interface for assigning positions of air-bag modules.
    3. (Controller Module) -- Controller Module that provide a python interface to directly assign power to each Vest Location (instead of device ID)
    4. ( Mosquitto MQTT Broker Script) -- Script to help you start a MQTT server Locally
    5. MQTT Control Logic ( seperated in all the modules, including controller / website / device )
    6. (Mosquitto Feedback Controll) -- An experimental side project that use PID controller to adjust the motor power with pressure feedback, see This Youtube Video for a quick demo.
  • Configuration Website is hosted by GitPage, available Here

  • Currently all components use MQTT Broker at emqx.com

contrains the source for a static website. The website use MQTT.js to communicate with each WEMO module.

The website is hosted by GitPage and is available at https://nemo1999.github.io/Smart-Bag/Config_Website/index.html Website ScreenShot

contrains python module that implements the controller for the WEMO modules, the code use paho.mqtt to communicate to Config Website, and fetch the current role configuration (correspondence between WEMO's MAC-address and role). The user of the controller only needs to specify the "role" and "pwm-power" to control the WEMO modules.

For example:

  from Controller_Package.controller import Bags_Controller
  
  controller = Bags_Controller()
  
  # Connect to MQTT broker
  controller.connect("broker.emqx.io", 1883)
  
  """
   fetch role configuration from Config_Website 
   (This step will be automatic ones connected to broker,
     so user don't need to call this function)
  """
  # controller.update_device_state()
  
  # set the air pumping power of each assigned module to 100 
  # power value control mechanism: 
  # min=1, max=255, 
  # special value 0 means "open air gate" (let pressure drops quickly) 
  for r in controller.available_roles()
      controller.set_val(r, 100)

This contains minimal script and setting to setup mosquitto broker.

start_server.sh print all the message and clients info in stdout for convinient debugging.

  • You need to setup the Arduino IDE / Enter MQTT and WiFi-AP info to make Wemo Available
  • See the README.md in the folder for more detail.
  • I implement a simple PID controller that use the feedback from pressure sensing resister to adjust the power of air pumping motor.
  • Pressure Sensor is here
  • The result can be seen in the graph below, we can we that the gray curve (Sensed Pressure Value (in scaled resister voltage)), match the blue curve (targeted control value given from the interactive controller)
  • Note that the pink curve (motor power) is constantly adjusting itself to fit the gray curve to the blue curve.
  • See a more interactive demo in this video, note that when I blocked the air hole on the airbag with my finger, the motor quickly power dropped, but the sensor pressure stay in a stable level!!

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 39.2%
  • CSS 21.2%
  • Python 16.1%
  • C++ 15.0%
  • HTML 8.1%
  • Shell 0.4%