Menu
Cart

Setting Up and Testing an Odroid C2 Server

Be sure your Odroid C2 is on your local network and you can access the Internet.

If you bought a pre-configured ODROID server from Engimusing you can skip down to the "Check that openHAB Works" section below.

First make sure the ODROID is up to at least Ubuntu 16.04. You can check this by running the command

lsb_release -a

In a terminal. If your ODROID is not at 16.04 or greater you will need to upgrade it before you can do the installation. Go to http://askubuntu.com/questions/110477/how-do-i-upgrade-to-a-newer-version-of-ubuntu to learn how to do this.

Next it is wise to install any updates. This can be done using the System -> Administration -> Software Updater menus.

Install and configure MQTT and  OpenHAB 

In a terminal on the ODROID type:

 wget http://engimusing.github.io/install/odroid_mqtt_openhab_installer.sh

Next change the permissions to allow execution:

chmod a+x odroid_mqtt_openhab_installer.sh

Then run the script by typing:

sudo ./mqtt_odroid_mqtt_openhab_installer.sh

The script will ask for your password and then should run to the point that it starts openHAB within a few minutes. It then waits for openHAB to start and prints out a string of period characters (..........) until it finishes starting. It can sometimes take several more minutes before openHAB starts so be patient. Then it should finish and print out "Script completed successfully" at the end.

Check that openHAB works:

After it has started you will be able to open a web browser on the ODROID and see the openHAB 2 welcome screen at:

localhost:8080

The welcome screen should also be accessible on your local network. Then get the IP address of the ODROID by typing this command (it is a capital i not a lower case L) in a terminal:

hostname -I

This should print out the ODROID's IP Address, it should look something like 192.168.1.1 although the numbers will likely be different. You can then type into another computers browser the IP address followed by :8080. So it would look something like this:

192.168.1.1:8080

You should see the welcome screen on that computer.

Check the MQTT Server:

To help you understand MQTT Mosquitto and to learn how to use it and debug problems we will use three terminal windows. If you have the monitor space arrange them so all three show.

In the first window type:    tail -f /var/log/mosquitto/mosquitto.log and you should see this:

tail command 

 What we have done is set this terminal up to follow the mosquitto log. There will generally be a few other lines that print out in addition to the line shown above.

In the next window type:  mosquitto_sub -t test/1/2 which will subscribe to the test/1/2 topic.

subscribe to test topic

Then at the third window type:  mosquitto_pub -t test/1/2 -m hi to publish a message using the test/1/2 topic with 'hi' as the payload. You will see a new message in the log window and you should see this in the publish window:

sub window has hi

You can see that the message made it from the publisher to the subscriber.

Type <CTRL>+c in the sub window and change the command to:

mosquitto_sub -d -t test/1/2

and in then in the pub window type:

mosquitto_pub -d -t test/1/2 -m 'hello'

This is debug mode and you will see more information prints that may be useful if you have a problem and need to debug things.

We usually don't need the debug mode but when you do it is very useful.

Type <CTRL>+c in the sub window and change the command to:

mosquitto_sub -v -t test/1/2

and in then in the pub window type:

mosquitto_pub -t test/1/2 -m hello world (without the -d).

verbose mode

These are the mosquitto_sub command options we use most of the time as it shows both the topic and the payload.

Now try mosquitto_sub -v -t test/# in the sub window after the <CTRL>+c.

Then type in the pub window:

mosquitto_pub -t test/1/2 -m 'mars'

mosquitto_pub -t test/2/3 -m 'venus'

wild card use

As you can see both messages were received. This is because the # symbol is a wild card. We have gone over the basics of how MQTT works. There are many tutorials on the Internet that will help you learn more.

This concludes the server set up. Next you need to configure your system for the specific devices you will be using.

Other Tips

Setup WiFi

EDIMAX EW-7811Un setup

A good Wifi USB dongle to use with the ODRIOD is EDIMAX EW-7811Un but if you use the EW-7811Un you will need to disable power management by doing the following:

Create a file 8192cu.conf in directory /etc/modprobe.d/ with the command

sudo nano /etc/modprobe.d/8192cu.conf

and add the following lines:

# Disable power management

options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

Then reboot the ODRIOD.

Auto Connect to WiFi Network

Setup the ODROID to auto connect to your home WIFI and change the setting in the general tab for the network connection to allow all users to use the connection. This will allow the connection to startup as soon as the ODRIOD is booted instead of needing to login.