Difference between revisions of "S15: Alarm Based Coffee Maker"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Design)
(Hardware Design)
Line 93: Line 93:
 
=== Hardware Design ===
 
=== Hardware Design ===
 
Discuss your hardware design here.  Show detailed schematics, and the interface here.
 
Discuss your hardware design here.  Show detailed schematics, and the interface here.
[[File:S15_Cmpe146_Coffee_Alarm_HardwareSchematic.png|200px|thumb|left|alt text]]
+
[[File:S15_Cmpe146_Coffee_Alarm_HardwareSchematic.png|200px|thumb|alt text]]
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===

Revision as of 10:28, 25 May 2015

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Alarm Based Coffee Maker

Abstract

The purpose of this project is to help make mornings easier. The goal is to upgrade an existing coffee maker to allow it to be programmed via smartphone application using an alarm application on a user's smartphone. The user syncs their alarm clock settings through a Bluetooth connection with the coffee maker to automatically start brewing coffee as soon as the preset time is reached. In addition to brewing coffee the SJSU One board will also be able to play music until the user stops it by stepping in front of the coffee maker.

Objectives & Introduction

Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.

Team Members & Responsibilities

  • Patricia Mejia
    • Android App Development
    • Bluetooth Module & Task
    • Bring up MP3 Module
    • SJSU One Board Real Time Clock Setup;
  • Alberto Reyes
    • Relay Setup
    • Alarm Task
    • Mp3 Player Task
    • Motion Sensor Task
    • Interfacing All Tasks Together

Schedule

Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.

Week# Date Task Actual
1 4/13 Set up bluetooth connection between board and smartphone. Complete
2 4/20 Complete bluetooth app and motion sensor on phone. Complete
3 4/27 Setup mp3 player on SJSU One board. Complete
4 5/4 Interface coffee maker and SJSU One board. Complete
5 5/11 Interface coffee maker and SJSU One board. Complete
6 5/18 Testeing Complete
7 5/25 Fix Bugs Half complete.

Parts List & Cost

  • Bluetooth Module:SiLabs HC-06 $7
  • Coffee Maker $20
  • Motion Sensor $ 5
  • Speakers $6
  • Mp3 Module: WIG-11029 ROHS - $50
  • Android Phone: LG L15G $40

Total Cost : $128

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here.

alt text

Hardware Interface

The Hardware communicates through UART. The Bluetooth module strips the bluetooth packets of all the wrappers and delivers a UART frame to the SJSU One Board. The smartphone sends a packet of data to the bluetooth module (through bluetooth) and the the bluetooth module relays it to the SJSU One Board. All other modules communicate through GPIO Pins, although the Mp3 player needed to be initialized using UART. The uart frame sends 8 bits of data. The start is indicated by a high-to-low transition, and a stop is indicated by a low to high transition. When a frame is not being sent, the line is held HIGH as shown in the image below. S15 Cmpe146 Coffee Alarm UartFrame.png

Software Design

The coffee maker alarm has software for two systems, the embedded system and the Android App. The embedded system is a collection of tasks that execute without user input, while the Android App gathers input from the user.

Android App

  • 1. A User selects the bluetooth device connected to their coffee maker. (Screen 1)

- We decided to allow the user to select the device instead of hardcoding a MAC address so that we could use different bluetooth modules, and allow future users to easily use our app with their own bluetooth module. - The precondition is that the BT module has been paired with the Android phone using the phones bluetooth settings. - If the BT device establishes a connection with the phone, this screen will disappear and allow the user to enter a time.

 Pseudo code:
  list_BT_devices();
  get_pairedDevice();
  create_BT_socket();
  create_connecting_Thread();
alt text
  • 2. Entering the time (Screen 2)

- A user selects the time at which they would like their coffee maker to wake them up. - A user must touch the time picker at least once for the time to be registered by the device. - Once the correct time is chosen the user clicks the button that says "send hour". This button sends 2 bytes, one representing the hour and one representing the minute.The hour is sent in 24 hr format.

   Pseudeo code:
   gethour();
   getmin();
   sendhour();
   sendmin();

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

Testing & Technical Challenges

This project brought together various modules into one system. Each unit needed specialized code to function correctly, and each module except for the relay needed troubleshooting. We had issues with the mp3 player, the motion sensor, the bluetooth module, and the Android device.


The mp3 player #1

The mp3 player that was originally chosen was the Adafruit VS1053. This module was simply a decoder and transferred data back to a microcontroller board. We attempted for 3 days to understand how to handle this data, however the transfer format was something that we were not familiar with (dual mode spi). We did not have sufficient time in this class learn about how to implement music playback from the decoded data or how to implement dual mode spi. We decided to select another module which was easier to use and communicated via UART and had an easy to read datasheet with clear instructions. The mp3 player selected was the WIG-11029 ROHS, as listed in the parts section above.

The motion sensor #2

The motion sensor gave us difficulty because it was not very sensitive at first, but became more sensitive later in the project. We had to go back and change the sensitivity of the motion sensor to get accurate data. The sensitivity was changed using a knob on the back of the motion-sensor module.

The bluetooth module and Android Device #3

We spent many weeks trying to get the bluetooth to connect with our Android phone. At first, we connected the bluetooth module with a 3rd party App, Blue SPP, from the google play store to verify that it would connect to our phone. We were able to send and receive data. After a few weeks, the module stopped establishing a connection with any bluetooth app. It would pair but not connect. We tried 3 different bluetooth modules with the same results. We also did a factory reset on the cellphone. We then came across a developer's forum stating that HTC brand phones were know to have inconsistency with bluetooth connections. They would work fine under some circumstances than the fail. We purchased a new cellphone and the bluetooth connected successfully again. We then continued to develop our own bluetooth app.

The Android Studio IDE #4

Android Studio IDE is the official IDE for developing android Apps. It intuitive to use, and look similar to Visual Basic. It also comes with a large variety of examples of different functionality. We were confident that developing an app would be simple because Android studio had a sample bluetooth chat App that worked with the bluetooth serial port profile (SPP). However, the sample app did not work. When loaded on multiple devices, it would fail to connect to our bluetooth device. We had to develop our App from scratch using the Android Developers reference pages and understand how everything worked in detail. We made multiple apps with varying degrees of functionality. It was extremely difficult to work with Android Apps because we did not have knowledge of the architecture or about creating multiple threads. We had to read a lot of forums, and debug almost every section of code. The last App that we made was stable, although by this time we were unable to make the app as visually appealing as we had hoped.

Conclusion

Overall, the project was more difficult that we could have imagined but we did learn a lot. We familiarized ourselves with developing android applications both on Android Studio and on Eclipse. We learned about interfacing bluetooth connections, including sockets and wrappers. The most significant thing that we learned was about the complexity of Android Apps. Because Android Apps work on a system that executes multiple things in the background, we need to use multiple threads to avoid blocking. We have never programmed with threads before and it was a difficult concept to grasp. It was also difficult to work with multiple classes to establish something as simple as establishing a bluetooth connection. We had difficulty working with the different classes because we only had a short time to familiarize ourselves with the IDE, and the Android architecture.

Project Video

Project Source Code

References

Acknowledgement

We would like to thank all the people that contribute to stackoverflow.com. They were our best resource for answering questions.

References Used

http://developer.android.com/index.html

Appendix

http://developer.android.com/index.html