Introduction: API Server - GalileoHome

Attention!

This instructable belongs to a huge project. This is just one part of it. In case you found this page first, please visit the main project https://www.instructables.com/id/GalileoHome/

The App Frontend enables to manage different devices (ventilator, door opener, lights, coffee machine) in a smart way. In other words, it´s possible to control those electrical appliances through your mobile phone and even to have your own presets with ideal temperature, light and volume. values. In this way the different devices work respectively if the command in the app is invoked or if the conditions of your home reach the preset values. Our assignment consists on how to manage the connection between the appliances and the app.

This is part of the final project named “Home automation” of the course “Multimodal Media Madness” which belongs to the Media Computing Group at the RWTH Aachen University. More information about this and previous projects can be “browsed” on the website http://hci.rwth-aachen.de/m3_ss15. The creation of innovating tools which make life easier and personal fabrication are the main topics of the project, which was possible with the use of a 3D printer, 3D-design software and an Intel Galileo board.

Step 1: Prerequisites

• Node.js

• Mosquitto Server + Clients

• C++ Standarlibraries

• Unix-compatible C++ Compiler (for example G++)

• Unix-based operating system

Step 2: Communication

Two protocols were used to make possible the communication between the app and the devices:

Protocol MQTT

We used the open Client Server MQTT protocol for the connection machine-to-machine (M2M)/Internet of Things (IoT). MQTT is based on a system of transport using two commands/instructions, publish and subscribe. This event based protocol is advantageous for applications which require a smaller amount of memory when running and for locations with scarce network bandwidth. You can find more information in the webpage of MQTT: http://mqtt.org/

MQTT creates a system where clients and server (this is called the broker) interact and interchange messages which represent data. Connections take place through TCP (Transmission Control Protocol). Messages contain data from the so-called topics which are a sort of parameters. The clients are respectively subscribed to a range of topics and they receive the messages published to those topics through the broker.

HTTP

To make possible the communication with the application it was used another protocol, the Hypertext Transfer Protocol (HTTP). HTTP uses as well the transport protocol TCP. The app sends HTTP-requests to the server. These requests are processed through the API-Server and sent to the MQTT-server. For this purpose the server API works as a device and for that reason it can publish information (messages). To get to send messages from the MQTT-server to the app the API-server subscribes to all the topics from the MQTT-server und write them in the corresponding HTTP data files. Consequently it’s possible for the app to query and represent the information through easy GET-requests.

Connections are easier to understand on the pictures.

Step 3: Management of the Rules

Die app enables that the User creates his own rules. These rules consist of a combination of values of sensors and functions of the devices. Verification and changes are effected through an event manager, which is part of the server API.

Step 4: Building Your Own Server

Installing the developer image:

  1. Download the Intel Galileo Developer image from http://iotdk.intel.com/images/iot-devkit-latest-mmcblkp0.direct.bz2
  2. Extract it with a tool of your choice
  3. Then copy the whole image onto your micro SD card for the Galileo
  4. Maybe the root partition is too small for the next step. If so, you may resize the partition with a tool of your choice (e.g. gparted)

Login vie SSH:

  1. Get the ip address and log in with ssh (ssh root@IP)
  2. Go to your home directory
  3. Pull the repository with git pull (git clone https://gitlab.com/M3-Final-Project/M3-Home-Automa...)
  4. Got to the Image directory (cd M3-Home-Automation/Image)
  5. Run the install script (./install.sh)

Make some configs

  1. Edit the config file at /etc/m3config (vi /etc/m3config)
  2. Here you can choose whether it should be a server or a client
  3. If you select server, then you must enter the current IP address of your Galileo

Comments

About This Instructable

676views

4favorites

More by M3-Home-Automation:Smartilator - GalileoHomeGalileoHomeSmarkey
Add instructable to: