Developed by: ShuTing Guo, Joyce Cho
date: 12/10/2017
- Project Description and System Diagram
- Project Features
- File Organization
- Setup
- User Guide
- Reference Sources
With the goal in mind to get ourselves familiarized with communication on different protocols and continue to develop the QT interface, we have developed a demo that consists of two python programs, a server and a client. The server periodically interacts with the DHT22 sensors and handles temperature/humidity data acquisition as well as storage. It has a QT interface that display temperature/humidity data. When starting the connection with AWS, the server send the temperature and humidity readings to AWS IoT via MQTT every 5 seconds. In AWS, a Lambda function is created to receive the incoming temperature and humidity message and perform data processing before putting the data on a FIFO queue using the Simple Queue Service (SQS) eventually. On the other hand, the client retrieves messages from the SQS Queue and running a webpage that allows users to access the temperature/humidity data remotely. Moreover, after getting messages from Amazon Web Services, client would set up four protocols and communicate with sever back and forth. We provide a web interface to present the analysis between below 4 message protocols:
- MQTT
- COAP
- WebSocket
- AMQP
Amazon Simple Queue Service (SQS) is a fast, reliable, scalable, fully managed message queuing service. Before retrieving the messages in the queue, few more steps are implemented such as "Configure the SDK for JavaScript" and "Getting the URL for a Queue" in Javascript. AWS also provdes SDK for Javacript that can deal with the receive_message. We are using sqs.deleteMessages API to delete the messages that have been read to prevent the redundant message reading.
An open souce chart project is implemented to display the graph of the temperature/humidity data after the websocket connection is initiallized.
Flask is a micro web framework written in Python and based on the Werkzeug toolkit and Jinja2 template engine. It is implemented in this project in order to call python backend from Javascript frontend.
Bootstrap is used in this project. It includes a powerful mobile-first flexbox grid system for building layouts of all shapes and sizes. It is a front-end web framework that was originally created by developers at Twitter to provide consistency across their internal tools. Today, it’s available to everyone through GitHub as a free and open-source collection of tools containing HTML and CSS-based design templates and JavaScript (JS) extensions.
In the server side UI, HTML5 is integrated in the module stylesheet to facilitate the development and enhance the beauty of its presentation.
Hardware:
- The setup tutorial of the Raspberry Pi can be found here
- The wiring of DHT22 sensor to Raspberry Pi can be found here
The server-side software requires the installation of the packages listed below:
Note:
-
In order to install the rabbitmq, below should be done first: add the following line in /etc/apt/sources.list/: deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
-
config files for rabbitmq and mosquitto files can be found in: /etc/rabbitmq/ and /etc/mosquitto
-
Stop both mosquitto and rabbitmq-server running as background service by default: sudo /etc/init.d/rabbitmq-server stop sudo /etc/init.d/mosquitto stop
The execution of the server program requires some additional authentication files for AWS connection and interaction. Multiple command lines are needed to run the program. Thus a script is developed to smooth the process:
$ cd python_program_server/
$ ./start.sh
After setting up the hardware, go to python_program_client/ and execute the client program,
$ cd python_program_client/
$ python web.py
Reference Sources