Futuristic Smart Lamp

Proposed By Mason Corey and Andrea Anez

Overview:

The goal of this project is to create a lamp that turns on when you sit in your chair and has adjustable intensity using a bluetooth connection to your phone. The activation that occurs when sitting in your chair will be implemented by a force sensor that is placed in the seat and senses when there is a change in force (either when sitting down or standing up). The light adjustment is implemented through a UART bluetooth connection to your phone that allows you to change the light intensity values wirelessly. Last but not least, we will connect an LED lamp through the USB micro-A-B port on the STM32 (We will need to use a USB type A to micro-A adapter).

Peripherals:

  1. Bluetooth device - HC-05 Bluetooth Module

  2. Pressure Sensor - Piezo Sensor

  3. USB Lamp (https://www.amazon.com/dp/B06XH9XR12/ref=psdc_3015418011_t1_B07Z3JZYHP)

Protocols:

  1. USB

  2. UART (Bluetooth)

Website: http://Sites.google.com/view/futuristicsmartlamp

Responsibility List:

Andrea will implement the pressure sensor that will be embedded in the chair seat and for interfacing the pressure sensor to the STM32 board. Mason will be responsible for developing the interface between the lamp and the STM32 board as well as any additional work that needs to be done in order to implement the distance sensor.

Software Structure:

There will be interrupts for both the pressure sensor and the bluetooth controller that controls the lamp. The pressure sensor will have higher priority over the bluetooth controller because turning the device on and off should have higher priority over adjusting the intensity of the light. The actual LED Lamp will be controlled through USB protocol and will have variable intensity that changes based on the amount of voltage we apply to it.

Block Diagram:


DEMO VIDEO:

IMG_1663.MOV.mp4

2/20/2020 UPDATE:

Today, we did the following:

  1. We learned that we cannot count a direct connection to the USB LED lamp as a protocol because we would only be doing Pulse Width Modulation (PWM), not actually controlling the brightness/turning off and on with data (no documentation).

  2. To make up for this, we had to research alternatives. We have decided to interface an Arduino with our STM32 board and hook them up with I2C protocol. The Arduino would be the slave and the STM32 board would be the master, with the STM32 board sending instructions to the Arduino to control the brightness of the USB LED (which will be connected to the Arduino via digital pins. We will use PWM to control brightness). Link to instructions for Arduino I2C interface: https://www.instructables.com/id/I2C-between-Arduinos/

  3. Our new idea for creating a pressure sensor that you would sit on to turn the LED on/off is to create a pad using cardboard, springs, and a button that will distribute the force equally no matter where you sit and activate the button when you sit down. This is cheaper and easier to implement than a force sensor (force sensors are hard to find or expensive when they must be rated to handle the force of a 100s of lb human sitting on them).

  4. We have ordered the USB LED and are waiting for it to arrive in a few days.

2/27/2020 UPDATE:

Today, we did the following:

  1. Created the skeleton code for our project and uploaded it to github at https://github.com/themason2011/ece153bproject

  2. We attempted to interface with the Arduino to turn on an LED on the Arduino but it still does not work. We think the issue lies in how the STM communicates with the Arduino. We will look into this next week.

  3. We decided to go with the new model for the pressure sensor from last week. We are currently constructing it.

3/5/2020 Update:

  1. Finally setup complete I2C communication between STM32 and Arduino.

2. We decided to change the sensor that decides if a person is seated to an ultrasonic distance sensor because the pressure contraption we were making became too convoluted. We will set up the distance sensor on the chair so that when somebody sits down, the STM32 will register this and turn on the LED Lamp.

3. We decided to change the LED lamp to an LED strip because it will allow us to add more features (such as flashing lights, different colors, etc). The original USB LED is now obsolete because we are using I2C to communicate commands (which go through the Arduino to control the LEDs) instead of the originally intended USB protocol. An LED strip will enable us to control more things than just PWM brightness.

4. Wrote the logic in main.c that decides what command to send to the Arduino based on inputs from the bluetooth module and the ultrasonic distance sensor.

5. The next steps are to setup the bluetooth module and ultrasonic distance sensor and ensure we can send commands properly based on their inputs. After doing this, we will program the actual controls for interfacing with the LED strip via the Arduino.

3/12/2020 UPDATE:

  1. We now have everything up and running for the project, with the exception of the lights. We are currently using an LED in substitute of the lamp because we are waiting for some Power Transistors to come in so that we can control the high-current analog light strip without blowing up our micro-controller.

2. We have written all of the code for the lamp to function except for the LED strip control code (which should be very simple). In addition, we are having a bug where our ultrasonic distance sensor will not automatically turn the light off until you send a command. This is because our USART connection over Bluetooth is receiving data via polling and waits for there to be new data (i.e. a new command) before continuing through the rest of the main code. This causes the main while loop to hang up when we are trying to read the new command if there is not one present yet. Our solution, which we are currently working on implementing, is to use interrupts for receiving USART data instead.

3. The last steps will be to first fix the USART polling problem, then set up the LED strip and write the code to control it.

3/16/2020 UPDATE:

  1. We successfully switched the USART connection from polling to interrupts, so now the distance sensor and USART commands can work together without interfering.

  2. We finished wiring the LED strip into the breadboard using power transistors, a separate 12V power supply, and digital outputs going from the arduino to the RGB inputs of the LED strip.

  3. We tested and finished the Arduino LED strip control code.

  4. We created the video and uploaded it to this website, as well as uploaded our code to Gauchospace!