Control your home IoT

By means of IoT lots of things can be connected and controlled by Internet such as smart homes. In this small tutorial I will discuss about personal smart home solutions and how to remotely control them. In small word “Control your Home IoT System over TOR” 🙂

Installing Raspbian Virtually

Here I will discuss about installing Raspbian virtually. It should be mentioned if you need to install Raspbian you do not need to install it on RaspberriPi, alternately you can install it virtually. But you should use special emulators for running Raspbian, since it is compiled in ARM architecture not in Intel x86 or AMD x64 or etc.

I will follow instructions from azeria labs to install virtual Raspbian on QEMU emulator on Ubuntu 16.04 x64.

Install qemu-system in Ubuntu

sudo apt-get install qemu-system

Installing QEMU Emulator

Download Raspbian and Kernel

Download Raspbian and the kernel for the emulator. For this tutorial I’ve used Raspbian Jessie from this link, QEMU rpi kernel can be downloaded from this link. I’ve downloaded 2017-07-05-raspbian-jessie.zip (Raspbian) and kernel-qemu-4.4.34-jessie (Kernel).

As you will see, the QEMU will start Raspbian. It is just like you’ve write the Raspbian image on sdcard and insert to your RaspberryPi. Now the OS is ready.

Starting the Raspbian:

Booting Raspbian

And vola:

Raspbian Jessie

You can enable ssh using

sudo service ssh start

Then you can connect using

ssh pi@127.0.0.1 -p 5022

Default user is pi and password is raspberry.

SSH to Raspbian

Remote Control Alternatives

For the aim of remote control, there are some scenarios.

1) Using MQTT like protocols. In this scenario, your Smart Home solution is behind NAT and can send data to a public MQTT server (or your private one) but you cannot send and receive massive data such as remote desktop.

2) Opening ports in your router or modem (or somthing like UPNP). But this is risky and you should open direct access to your system.

3) Another alternative to avoid port forwarding, and send large data is using TOR hidden services. It allows to connect to your IoT system indirectly behind NAT.

Installing TOR and Hidden Service on Raspbian

Raspbian is just like debian or ubuntu and its repository is full of ARM compiled software such as TOR. Install TOR on your system using the following command:

$ sudo apt-get install tor

Installing TOR in Raspbian

You may change your time zone and run following command to sych the Raspbian time:

$ sudo sntp -s time.nist.gov

After installing tor, you should config the hidden service. Edit /etc/tor/torrc with nano:

Mir Saman

I'm currently an IT PhD. candidate at Urmia University. I'm interested in Social Network Analysis, Big Data Mining, and NLP in my academical field as well as Guitar, Nature, and Android!
View all posts by Mir Saman