F16: NotifyBox

From Embedded Systems Learning Academy
Revision as of 23:42, 20 December 2016 by 146 user6 (talk | contribs) (Schedule)

Jump to: navigation, search

NotifyBox

Abstract

With the rise of e-commerce, online shoppers are receiving more mail than they ever have before. This increase in online shopping will also come with an increase of mail and packages received. NotifyBox will help consumers remotely be more aware of when packages/mail has been delivered to their mailbox. NotifyBox will provide users with a notification on their phone showing when their mail has been delivered. An IR beam will be used to check when mail is received. This will be interfaced to an SJOne board. Once mail has been detected the SJOne board will send the data to another SJOne board over wireless communication. The second board will then communicate that data over Bluetooth to a phone. Every time the beam has an interference, the user will receive the notification on their phone.

Objectives & Introduction

The objective of this project is to create mailbox that will remotely notify a user when mail has been delivered. Upon mail being received in the mailbox, a notification will appear on a user's screen that mail has been received.

  • Interface infrared sensor
  • Transfer data to SJOne board
  • Communicate two SJOne boards over wireless communication
  • Send data from SJOne board using Bluetooth
  • Connect to phone via Bluetooth

Team Members & Responsibilities

  • Eric Lau
    • Bluetooth interface
    • UART communication
  • Alex Zavala
    • Infarred beam detection
    • Wifi interface

Schedule

Week# Date Task Status Date Completed Notes
1 10/21 Finalize Project Idea and Porposal Completed 10/28 Decided on idea and finalized proposal
2 10/28 Order Parts Completed 11/2 Received parts on 11/2
3 11/4 Familiarize with Datasheets Complete 11/11* *Ongoing process, will continue to familiarize datasheets
4 11/11 Design circuit diagrams and IR sensor communication Complete 11/30 Implemented using GPIO
5 11/18 Interface Bluetooth and research iOS app Complete 11/25 iOS app was started very eary (11/13) and bluetooth part was started 11/20, but not fully completed until later.
6 11/25 Interface WiFi and complete iOS app Semi-Complete 12/19 Although the WiFi was done and iOS was almost done, the app was not completed until Bluetooth was fully functioning. Concluded that it is impossible to interface HC-06 to iOS.
7 12/2 Integrating all peripherals Complete 12/19/16 Our schedule was backlogged by building an iOS app to connect Bluetooth, but all peripherals were implemented.
8 12/9 Testing Complete 12/20/16 Project is completed and working
9 12/16 Testing Complete 12/20 -

Parts List & Cost

Part Name Part Number Quantity Cost Notes
2x WiFi Transceiver Module 1MB Flash ESP8266 ESP-01 1 $9.95 For interfacing WiFi
Xbee Bluetooth Bee Iduino Xbee V2.0 (HC-06) 1 $11.99 For interfacing Bluetooth
SJOne Board with LPC1758 SJOne Board 2 $80.00 Microcontroller used to control peripherals
Jumper Wires 60 ct 1 $8.00 For connecting pins
Infrared Sensors - 3mm LEDs IR Break Beam Sensor 1 $1.95 Sensor used for sensing objects
Total $191.89
  • NOTE:
    • Bluetooth module HC-06 only works as a slave, not as a master peripheral. Will need to get an HC-05 if you would like to perform as a master and slave.
    • The Bluetooth module is also not a Bluetooth Low Energy (BLE) module. If you would like to connect to an iOS device, you need to have a BLE module.

Design & Implementation

Hardware Design

Discuss your hardware design here. Show detailed schematics, and the interface here. //will delete before finalizing

Figure 1: Block diagram

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project. // will delete before finalizing


Figure 2: Board pinout


In our block diagram, we have one infrared sensor(IR) that we will be using to determine if mail has been received. Once the IR sensor beam breaks, microcontroller 1 will receive that data. The IR sensor sends data to the microcontroller over GPIO interface. Once microcontroller 1 has the data it will package the data and then send that package to microcontroller 2 via wifi. When microcontroller 2 has received the package this will notify the user with a notification that mail has been received. The communication from microcontroller 2 to the iPhone will be done using a Bluetooth module.


Figure X: Pin description

Above is a table from the LPC 176x/5x User Manual. This table shows the pins that we used on the SJOne boards to interface the GPIO port for the Infrared sensor and the UART port to interface the Bluetooth HC-06 module.


Figure X: SJOne board 1


  • Board 1:
    • The IR sensor has a transmitter and a receiver sensor. Both transmitter and receiver have a red and a white wire. These are to power the sensor. We are using 3.3 logic for the VCC of this project.
    • The receiver has an extra white wire. This wire is used as an input for the GPIO port.
    • NOTE: The receiver wire is an open collector. This means you need a pull-up resistor in order for it to work. Connect a 10K resistor between the white wire of the receiver and the red wire of the VCC.
    • Nordic wireless was used with the wireless FreeRTOS API to send a packet of data.


Figure X: SJOne board 2



  • Board 2:
    • Nordic wireless was used with the wireless FreeRTOS API to receive a packet of data
    • UART ports are used to transfer data to the phone over the Bluetooth module. We used internal UART ports TXD2 and RXD2.









Figure x: Complete system

IR Beam Sensor

Figure 3: IR Sensor


IR (infrared) beam sensor is a sensor that detects if something is blocking the path between an emitter and a receiver. The way that this infrared break-beam sensor work is having an emitter emit an IR beam that can is received by the receiver module. When something blocks the path between the emitter and receiver, the beam is "broken".

For our project, we used the IR Beam sensor to detect if the link is active or if there is a break/interference in the infrared connect between the emitter and receiver. When mail has been delivered, the infrared link will be broken, thus changing the state of the GPIO pin to true.







xBee Bluetooth Module

Figure X: xBee Bluetooth module


The xBee Bluetooth module used is made by Iduino. It interfaces a HC-06 Slave chip. The xBee peripheral allows us to pick to use either UART2 or UART3 to communicate. UART uses a RX for serial input and TX for serial output.

For our purpose, we chose to use UART2 because

This is the datasheet reference that we used to identify where the Tx and Rx pins were on the HC-06.







Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it. // delete later

  • All the software was implemented on FreeRTOS. This is a free operating system that can be used to develop embedded systems. This Development Package is what was used to implement our project.


NOTE: We have two SJOne boards communicating to each other. Therefore, we have two design flow to illustrate two different implementations.


SJOne Board 1

Figure 4: Software flow for microcontroller1.
  • IR Sensor

The IR Sensor was implemented through a GPIO pin. The pseudocode is as follows:

init
configure GPIO Pin

gpio_task

if (GPIO Pin is set)
     no mail
else
     mail!
     send packet over nordic wireless (detailed in section below)
  • Nordic Wireless (sender)

Onboard nordic wireless chip was used to send data wirelessly to another board. Below is the pseudocode:

init

configure wireless channel
configure node address
configure node name

wireless_send

set hops
set address to send to
initialize packet to send

form packet of data to be sent
send packet


SJOne Board 2

Figure 5: Software flow for microcontroller2.
  • Nordic Wireless (receiver)

Onboard nordic wireless chip was used to receive data wirelessly from another board. This is the pseudocode:

init

configure wireless channel
configure node address
configure node name

wireless_receive

if(packet received)
    deform the packet
    save data as variables
    send data over bluetooth
  • xBee Bluetooth

Bluetooth was connected via xBee Wifly connection. Bluetooth drivers were automatically initialized. Pseudocode is as follows:

init

configure UART clock control bit 
configure Peripheral clock divider
configure RX pins
configure TX pins
configure baud rate:
     set LCR
     set DLAB bit 
calculate divider
configure DLM
configure DLL
     clear DLAB bit

UART2_send(out)

set THR to out character
while(1) //wait for character to be sent
     if(LSR is clear)
          break


  • Bluetooth Terminal (phone app)

To verify that data was sent over Bluetooth, we used the "SENA BTerm" Android app. Pseudocode for Bluetooth transfer:

init

initialize connection to HC-06 Bluetooth module

Bluetooth_receive

while(1)
     if(received)
          output data on app screen.

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.

  • NOTE: Due to using two SJOne boards we are implementing two different designs on separate laptops.


  • SJBoard 1:
  • To initialize the GPIO:
    • Enable power.
    • Initialize pin to port 2.0
    • Set direction of the pin as an input.
  • To implement Nordic wireless send
    • Create a sender function
    • Sender function will send data to a specific receiver address.
    • Data will then be formed into a packet.
    • After formed function will then send the packet.
  • Main function
    • An if-else statement in your main tasks will then be need to check to see if the IR beam has an interference.
    • If the (else) statement is executed then call the wireless send function.


  • SJBoard 2:
  • To implement Nordic wireless receive
    • Create a receive function
    • Receive function will receieve data from the sender.
    • If statement that checks to see if a packet was received.
    • Function will check if a packet was received.
    • If received will then deform the packet.
  • Main function
    • Call the receiver function. If received, send data from the packet over to the phone over Bluetooth.

Testing & Technical Challenges

Issue #1

Bluetooth implementation on the iOS app was by-far the hardest part of the project. After hours, days, weeks spent on interfacing our xBee HC-06 Bluetooth module, we found that it was impossible to have the HC-06 discoverable by iOS (iPhones, iPads, iPods). Because the HC-06 does not use with Bluetooth LE, and is not MFi certified, it was considered to be not following Apple's standards, thus not allowing any HC-06 Bluetooth modules to be able to be paired with iOS devices. We had to change our approach on our objectives. We opted to use a Bluetooth terminal app in Android to talk to our xBee HC-06 module.

Issue #2

The wireless communication gave us a very hard time to transfer the data from one board to the other. Thinking that the way that we implemented it was incorrect, we were trying to fix our code for many hours. It wasn't until we decided to try to attach antennas to our SJOne Board that it then started working properly. Our issues was instantly resolved with antennas.

Issue #3

When first trying to research about how the Infrared (IR) sensor worked, I was not able to fully understand how to implement the sensor with the SJOne board as the sensor was made for Arduino. With enough research and asking my professor what I had thought was the best way to interface the IR sensor, I was told that I was over complicating myself. Was resolved by simply interfacing with GPIO.

Issue #4

On the hardware side, the wire connections for the IR sensors were very frail and thin. Although the wires were connected, sometimes the IR sensors would not work as intended. We concluded that either we would have to wirewrap the wires onto the GPIO pins, use banana plugs for a more secure connection, or we could fold and double the wires so then it would be a thicker connection. We ended up opting for doubling the wires because it would be the most efficient and seamless way to integrate it into our project.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

In conclusion, we learned a lot from this project and this class. Using FreeRTOS's open source to implement on a microcontroller takes a little bit of time to learn but actually helps with learning more about how the hardware is designed in the board. Labs were useful but having to interface multiple peripherals We learned how to use the Nordic wireless chip on the SJOne board. We also learned how to use a Bluetooth device to send over data to a phone. As mentioned in the issues, we spent a great deal of time on the wireless and the Bluetooth interfacing.

We know can use what we learned to make several applications.

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

Professors

References Used

Appendix