Home Monitoring System
Provide a Home Monitoring System that monitors temperature to detect if it is out of range and also detects motion of the mbed application board. It stores alerts locally until a host is connected via a USB Serial connection where the host is running the host-side application. Once connected to the host application it allows the host to control the alert generation, retrieve historical information and provide full control over the device.
mbed application board sensors used to monitor temperature and compare to a threshold. mbed application board motion sensors used to detect motion of the application board. When temperature is out of range or motion is detected an LED is lit and an alert generated. If the device is connected to the host running the host application it will alert the host otherwise it stores the alerts. The host side application can control these features of the mbed application board:
- Set and Get Temperature Thresholds
- Set and Get Motion Sensitivity (vector of x, y, and z)
- Set and Get Temperature sampling period (determine how often historical temperature reading taken)
- Set and Get buffer depth for historical motion and temperature information
- Retrieve historical motion and temperature information from the board
The communication between the device and host is a simple one character based protocol. The device sends alerts, acknowledgments, and data to the host. Each command or request is acknowledged by the host or device depending on the direction of the command. All data that is passed is a fixed 7 bits wide and is padded with spaces if required. This allows communication without parsing of data.
Some example transfers:
- Host sends 'c' for connect
- Device sends 'k' for acknowledge
- Device sends 'a' for alert
- Host sends 'k' for acknowledge
- Device sends 'm' indicating motion alert ('l' for low temp, 'h' for high temp)
- Host sends 'k' for acknowledge
Data Transfer (Get temperature history from Host)
- Host sends single character command to fetch temperature history
- Device sends a 'k' for acknowledge
- Device sends 7 character integer N (padded with spaces) to indicate length of transfer
- Device sends N 7 character doubles for temperature history
- mbed LPC1768 CPU board
- mbed DEV-11695 application board
- Host PC running HomeMonitorApp (Windows Console App, code on this page)
- Two USB Cables (normal mbed connection and USB Serial Device connection to host PC)
- mbed Libraries - LM75B, MMA7660, C12832_lcd, USBDevice (USB Serial Device mode)
- Windows Console Application (base written by instructor Avnish Aggarwal, heavily modified by me) for serial communication
- Other code and classes referenced here
- LED0 - Device correctly connected to host application
- LED1 - Motion alert (cleared only when host has received alert)
- LED2 - Temperature High Alert (cleared when host receives alert)
- LED3 - Temperature Low Alert (cleared when host receives alert)
- LCD Screen - some helpful debug messages, alert generation, connected status, etc.
Pretty lame user interface for now. Just allows user to enter commands to control device parameters. When alerts are received they are displayed to the application window. When data is received from the device it is dumped to the window. A GUI, file saving features, etc. would have been nice but ran out of time.
The code listing for the host side application is here. It was done with Visual Studio Express 2010 as a Console Application. When launched it expects the COM port for the serial connection in use and the baud rate. For example if the serial port is COM6 and the baud rate is 9,600 the command line should be:
HostMonApp.exe 6 9600
- Under heavy alerts traffic there are protocol errors (still debugging) when trying to send commands at the same time an alert arrives
- Code could be cleaned up a bit and multiple threads on host and device would be nice (ran out of time)
I was down to the 11th hour, so not a lot of time to make a pretty video. It doesn't show much but gives some idea of the project.
The mbed code
1 comment on Home Monitoring System:
Please log in to post comments.